The new `crashkernel.default` file in kernel package can be used as the ck_cmdline source.
Also keep the legacy code so old kernel packages will still work.
Signed-off-by: Kairui Song kasong@redhat.com --- kdump-lib.sh | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index df0aa02..4bd9751 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -952,31 +952,40 @@ get_recommend_size() }
# return recommended size based on current system RAM size +# $1: kernel version, if not set, will defaults to `uname -r` kdump_get_arch_recommend_size() { - if ! [[ -r "/proc/iomem" ]] ; then + local kernel=$1 arch + + if ! [ -r "/proc/iomem" ] ; then echo "Error, can not access /proc/iomem." return 1 fi - arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr [:lower:] [:upper:]) - - if [ $arch == "X86_64" ] || [ $arch == "S390X" ]; then - ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M" - elif [ $arch == "AARCH64" ]; then - ck_cmdline="2G-:448M" - elif [ $arch == "PPC64LE" ]; then - if is_fadump_capable; then - ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" - else - ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G" + + [ -z "$kernel" ] && kernel=$(uname -r) + ck_cmdline=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2>/dev/null) + + if [ -n "$ck_cmdline" ]; then + ck_cmdline=${ck_cmdline#crashkernel=} + else + arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr '[:lower:]' '[:upper:]') + if [ "$arch" = "X86_64" ] || [ "$arch" = "S390X" ]; then + ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M" + elif [ "$arch" = "AARCH64" ]; then + ck_cmdline="2G-:448M" + elif [ "$arch" = "PPC64LE" ]; then + if is_fadump_capable; then + ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" + else + ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G" + fi fi fi
ck_cmdline=$(echo $ck_cmdline | sed -e 's/-:/-102400T:/g') sys_mem=$(get_system_size) - result=$(get_recommend_size $sys_mem "$ck_cmdline") - echo $result - return 0 + + get_recommend_size "$sys_mem" "$ck_cmdline" }
# Print all underlying crypt devices of a block device
On Fri, Jul 2, 2021 at 1:31 AM Kairui Song kasong@redhat.com wrote:
The new `crashkernel.default` file in kernel package can be used as the ck_cmdline source.
Also keep the legacy code so old kernel packages will still work.
Signed-off-by: Kairui Song kasong@redhat.com
kdump-lib.sh | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index df0aa02..4bd9751 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -952,31 +952,40 @@ get_recommend_size() }
# return recommended size based on current system RAM size +# $1: kernel version, if not set, will defaults to `uname -r` kdump_get_arch_recommend_size() {
- if ! [[ -r "/proc/iomem" ]] ; then
- local kernel=$1 arch
- if ! [ -r "/proc/iomem" ] ; then echo "Error, can not access /proc/iomem." return 1 fi
- arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr [:lower:] [:upper:])
- if [ $arch == "X86_64" ] || [ $arch == "S390X" ]; then
ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M"
- elif [ $arch == "AARCH64" ]; then
ck_cmdline="2G-:448M"
- elif [ $arch == "PPC64LE" ]; then
if is_fadump_capable; then
ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G"
else
ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G"
[ -z "$kernel" ] && kernel=$(uname -r)
ck_cmdline=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2>/dev/null)
if [ -n "$ck_cmdline" ]; then
ck_cmdline=${ck_cmdline#crashkernel=}
else
arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr '[:lower:]' '[:upper:]')
if [ "$arch" = "X86_64" ] || [ "$arch" = "S390X" ]; then
ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M"
elif [ "$arch" = "AARCH64" ]; then
ck_cmdline="2G-:448M"
elif [ "$arch" = "PPC64LE" ]; then
if is_fadump_capable; then
ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G"
else
ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G"
fi fi
fi
ck_cmdline=$(echo $ck_cmdline | sed -e 's/-:/-102400T:/g') sys_mem=$(get_system_size)
- result=$(get_recommend_size $sys_mem "$ck_cmdline")
- echo $result
- return 0
- get_recommend_size "$sys_mem" "$ck_cmdline"
}
# Print all underlying crypt devices of a block device
2.31.1
Acked-by: Pingfan Liu piliu@redhat.com