[PATCH] kdump-lib.sh: introduce functions to return recommened mem size
by Pingfan Liu
There is requirement to decide the recommended memory size for the current
system. Ant the algorithm is based on /proc/iomem, so it can align with the
algorithm used by reserve_crashkernel() in kernel.
Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
---
V1 -> V2:
embeded in kdump-lib.sh
add check against /proc/iomem
kdump-lib.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index d2801da..6bb285d 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -823,3 +823,71 @@ prepare_cmdline()
echo ${cmdline}
}
+
+#get system memory size in the unit of GB
+get_system_size()
+{
+ result=$( cat /proc/iomem | grep "System RAM" | awk -F ":" {' print $1 '} | tr [:lower:] [:upper:] | paste -sd+ )
+ result="+$result"
+ # replace '-' with '+0x' and '+' with '-0x'
+ sum=$( echo $result | sed -e 's/-/K0x/g' | sed -e 's/+/-0x/g' | sed -e 's/K/+/g' )
+ size=$(printf "%d\n" $(($sum)))
+ let size=$size/1024/1024/1024
+
+ echo $size
+}
+
+get_recommend_size()
+{
+ local mem_size=$1
+ local _ck_cmdline=$2
+
+ last_sz=""
+ last_unit=""
+
+ IFS=','
+ for i in $_ck_cmdline
+ do
+ end=$( echo $i | awk -F "-" {' print $2 '} | awk -F ":" {' print $1 '} )
+ recommend=$( echo $i | awk -F "-" {' print $2 '} | awk -F ":" {' print $2 '} )
+ size=${end: : -1}
+ unit=${end: -1}
+ if [ $unit == 'T' ]; then
+ let size=$size*1024
+ fi
+ if [ $mem_size -lt $size ]; then
+ echo $recommend
+ unset IFS
+ return
+ fi
+ done
+ unset IFS
+}
+
+# return recommended size based on current system RAM size
+kdump_api_get_arch_recommend_size()
+{
+ 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 == "S390" ]; then
+ ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M"
+ elif [ $arch == "ARM64" ]; 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
+
+ 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
+}
--
2.29.2
1 year, 3 months
[PATCH] Revert "Append both nofail and x-systemd.before to kdump mount target"
by Kairui Song
That commit is trying to workaround a kernel VFS bug. Now,
the VFS issue should have been fixed in all recent releases, so
remove this workaround.
This reverts commit 539bff40830e961d7ef85248e39bff0e40b23c91.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
mkdumprd | 3 ---
1 file changed, 3 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index 0623940..8ba8e2a 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -86,9 +86,6 @@ to_mount() {
# drop nofail or nobootwait
_options=$(echo $_options | sed 's/\(^\|,\)nofail\($\|,\)/\1/g')
_options=$(echo $_options | sed 's/\(^\|,\)nobootwait\($\|,\)/\1/g')
- # use both nofail and x-systemd.before to ensure systemd will try best to
- # mount it before kdump starts, this is an attempt to improve robustness
- _options="$_options,nofail,x-systemd.before=initrd-fs.target"
echo "$_pdev $_new_mntpoint $_fstype $_options"
}
--
2.29.2
1 year, 3 months
[PATCH] Remove trace_buf_size and trace_event from the kernel boot
parameters of the kdump kernel
by fj1508ic@fujitsu.com
The kdump kernel uses resources for ftrace because trace_buf_size, which
specifies the ring buffer size for ftrace, and trace_event, which specifies
a valid trace event, are not removed, but the kdump kernel does not require
ftrace.
trace_buf_size is ignored if the specified size is 0, so specify 1.
Signed-off-by: Hisashi Nagaoka <fj1508ic(a)fujitsu.com>
---
kdump-lib.sh | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 0e38580..a54a650 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -827,5 +827,9 @@ prepare_cmdline()
fi
done
+ # Remove trace_buf_size, trace_event
+ cmdline=$(remove_cmdline_param "$cmdline" trace_buf_size trace_event)
+ cmdline="${cmdline} trace_buf_size=1"
+
echo ${cmdline}
}
--
2.26.2
1 year, 3 months
[PATCH] dracut-module-setup.sh: enable ForwardToConsole=yes in fadump mode
by Pingfan Liu
In fadump mode, it is also useful to observe kdump message through
console. Hence enable it.
Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
---
dracut-module-setup.sh | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 21f7105..6061dbe 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -813,13 +813,11 @@ kdump_install_systemd_conf() {
# Forward logs to console directly, and don't read Kmsg, this avoids
# unneccessary memory consumption and make console output more useful.
# Only do so for non fadump image.
- if ! is_fadump_capable; then
- mkdir -p ${initdir}/etc/systemd/journald.conf.d
- echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf
- echo "Storage=volatile" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
- echo "ReadKMsg=no" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
- echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
- fi
+ mkdir -p ${initdir}/etc/systemd/journald.conf.d
+ echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf
+ echo "Storage=volatile" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
+ echo "ReadKMsg=no" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
+ echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
}
install() {
--
2.29.2
1 year, 4 months
[PATCH v2 0/3] Fix dracut error caused by kexec-tools
by Kairui Song
Following errors are observed when kexec-tools is installed:
$ LC_ALL=C sudo rpm -ivh kernel-core-5.9.16-200.fc33.x86_64.rpm
Verifying... ########################################
Preparing... ########################################
Updating / installing...
kernel-core-5.9.16-200.fc33 ########################################
sort: fflush failed: 'standard output': Broken pipe
sort: write error
gzip: stdout: Broken pipe
gzip: stdout: Broken pipe
sort: write failed: 'standard output': Broken pipe
sort: write error
This is caused by kexec-tools' logger helper overriding dracut's helper
functions. kdumpcase and earlykdump's module-setup.sh will unconditionally
source kdump lib files, and polute dracut namespace. This series make
the module-setup.sh file only import kdump helper when building a kdump
initramfs, and don't import logger lib, as dracut module should just
use dracut's logger.
Update from V1:
V1 forgot to update earlykdump's module-setup.sh
Kairui Song (3):
logger: source the logger file individually
module-setup.sh: don't source $dracutfunctions
module-setup.sh: don't polute the namespace unnecessarily
dracut-early-kdump-module-setup.sh | 3 ++-
dracut-early-kdump.sh | 1 +
dracut-module-setup.sh | 14 +++++++++-----
kdump-dep-generator.sh | 1 +
kdump-lib-initramfs.sh | 1 +
kdump-lib.sh | 6 ------
kdumpctl | 1 +
mkdumprd | 1 +
8 files changed, 16 insertions(+), 12 deletions(-)
--
2.29.2
1 year, 4 months
[PATCH 0/3] Fix dracut error caused by kexec-tools
by Kairui Song
Following errors are observed when kexec-tools is installed:
$ LC_ALL=C sudo rpm -ivh kernel-core-5.9.16-200.fc33.x86_64.rpm
Verifying... ########################################
Preparing... ########################################
Updating / installing...
kernel-core-5.9.16-200.fc33 ########################################
sort: fflush failed: 'standard output': Broken pipe
sort: write error
gzip: stdout: Broken pipe
gzip: stdout: Broken pipe
sort: write failed: 'standard output': Broken pipe
sort: write error
This is caused by kexec-tools' logger helper overriding dracut's helper
functions. kdumpcase and earlykdump's module-setup.sh will unconditionally
source kdump lib files, and polute dracut namespace. This series make
the module-setup.sh file only import kdump helper when building a kdump
initramfs, and don't import logger lib, as dracut module should just
use dracut's logger.
Kairui Song (3):
logger: source the logger file individually
module-setup.sh: don't source $dracutfunctions
module-setup.sh: don't polute the namespace unnecessarily
dracut-early-kdump.sh | 1 +
dracut-module-setup.sh | 14 +++++++++-----
kdump-dep-generator.sh | 1 +
kdump-lib-initramfs.sh | 1 +
kdump-lib.sh | 6 ------
kdumpctl | 1 +
mkdumprd | 1 +
7 files changed, 14 insertions(+), 11 deletions(-)
--
2.29.2
1 year, 4 months
[PATCH] kdump.conf: add ipv6 example for nfs and ssh dump
by Lianbo Jiang
At present, there is no ipv6 example for nfs and ssh dump, let's
add an example to the kdump.conf.
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
kdump.conf | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kdump.conf b/kdump.conf
index e4db52e2db97..f9d0d4214881 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -166,7 +166,9 @@
#ext4 LABEL=/boot
#ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937
#nfs my.server.com:/export/tmp
+#nfs [2620:52:0:800:216:3eff:fe6a:e19e]:/export/tmp
#ssh user(a)my.server.com
+#ssh user@2620:52:0:800:216:3eff:fe6a:e19e
#sshkey /root/.ssh/kdump_id_rsa
path /var/crash
core_collector makedumpfile -l --message-level 7 -d 31
--
2.17.1
1 year, 4 months
[PATCH] fix kdump failure of saving vmcore with the scp + ipv6 method
by Lianbo Jiang
Currently, kdump will fail to save vmcore when using the scp and ipv6.
The reason is that the scp requires IPv6 addresses to be enclosed in
square brackets, but ssh doesn’t require this.
Let's enclose the ipv6 address in square brackets for scp dump.
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
dracut-kdump.sh | 32 +++++++++++++++++++++++++++++---
kdump-lib-initramfs.sh | 1 +
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 370d217cea52..3367bc5f7c63 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -111,6 +111,7 @@ dump_ssh()
local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR"
local _host=$2
local _vmcore="vmcore"
+ local _ipv6_addr="" _username=""
dinfo "saving to $_host:$_dir"
@@ -122,8 +123,17 @@ dump_ssh()
dinfo "saving vmcore"
+ if is_ipv6_address "$_host"; then
+ _username=${_host%@*}
+ _ipv6_addr="[${_host#*@}]"
+ fi
+
if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then
- scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete"
+ if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then
+ scp -q $_opt /proc/vmcore "$_username@$_ipv6_addr:$_dir/vmcore-incomplete"
+ else
+ scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete"
+ fi
_exitcode=$?
else
$CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "dd bs=512 of=$_dir/vmcore-incomplete"
@@ -143,8 +153,13 @@ dump_ssh()
derror "saving vmcore failed, _exitcode:$_exitcode"
fi
+ dinfo "saving the $KDUMP_LOG_FILE to $_host:$_dir/"
save_log
- scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/"
+ if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then
+ scp -q $_opt $KDUMP_LOG_FILE "$_username@$_ipv6_addr:$_dir/"
+ else
+ scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/"
+ fi
_ret=$?
if [ $_ret -ne 0 ]; then
derror "saving log file failed, _exitcode:$_ret"
@@ -161,6 +176,7 @@ save_opalcore_ssh() {
local _path=$1
local _opts="$2"
local _location=$3
+ local _user_name="" _ipv6addr=""
ddebug "_path=$_path _opts=$_opts _location=$_location"
@@ -173,8 +189,18 @@ save_opalcore_ssh() {
fi
fi
+ if is_ipv6_address "$_host"; then
+ _user_name=${_location%@*}
+ _ipv6addr="[${_location#*@}]"
+ fi
+
dinfo "saving opalcore:$OPALCORE to $_location:$_path"
- scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete
+
+ if [ -n "$_user_name" ] && [ -n "$_ipv6addr" ]; then
+ scp $_opts $OPALCORE $_user_name@$_ipv6addr:$_path/opalcore-incomplete
+ else
+ scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete
+ fi
if [ $? -ne 0 ]; then
derror "saving opalcore failed"
return 1
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index e766f95c7d6a..4eba3db75673 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -168,6 +168,7 @@ dump_fs()
derror "saving vmcore failed, _exitcode:$_exitcode"
fi
+ dinfo "saving the $KDUMP_LOG_FILE to $_dump_path/"
save_log
mv $KDUMP_LOG_FILE $_dump_path/
if [ $_exitcode -ne 0 ]; then
--
2.17.1
1 year, 4 months
[PATCH] Fix dump_fs mount point detection and fallback mount
by Kairui Song
Simplify the code and fix mount point detection. The code logic is now
much simpler: if $1 is not a mount point, call "mount --target $1" again
to try mount it. "mount --target" cmd itself can handle all the /etc/fstab
parsing job, so drop the buggy and complex bash code.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdump-lib-initramfs.sh | 27 ++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index a60a52a..cd9d512 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -117,26 +117,15 @@ dump_fs()
{
local _exitcode
local _mp=$1
- local _dev=$(get_mount_info SOURCE target $_mp -f)
- local _op=$(get_mount_info OPTIONS target $_mp -f)
-
- ddebug "_mp=$_mp _dev=$_dev _op=$_op"
-
- # If dump path have a corresponding device entry but not mounted, mount it.
- if [ -n "$_dev" ] && [ "$_dev" != "rootfs" ]; then
- if ! is_mounted "$_mp"; then
- dinfo "dump target $_dev is not mounted, trying to mount..."
- mkdir -p $_mp
- mount -o $_op $_dev $_mp
-
- if [ $? -ne 0 ]; then
- derror "mounting failed (mount point: $_mp, option: $_op)"
- return 1
- fi
+ ddebug "dump_fs _mp=$_mp"
+
+ if ! is_mounted "$_mp"; then
+ dinfo "dump path \"$_mp\" is not mounted, trying to mount..."
+ mount --target $_mp
+ if [ $? -ne 0 ]; then
+ derror "failed to dump to \"$_mp\", it's not a mount point!"
+ return 1
fi
- else
- derror "failed to dump to \"$_mp\", it's not a mount point!"
- return 1
fi
# Remove -F in makedumpfile case. We don't want a flat format dump here.
--
2.29.2
1 year, 4 months
[PATCH] Revert "Don's try to restart dracut-initqueue if it's already failed"
by Kairui Song
systemctl is-failed will not work after dracut isolated to the emergency
target, so this judgement is invalid. And the restart is basically
harmless, so just revert this commit.
This reverts commit ad6a93b00d85a85702bb59d15ecc81a5382a9a31.
---
kdump-lib-initramfs.sh | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index e766f95..a60a52a 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -226,8 +226,7 @@ dump_to_rootfs()
{
dinfo "Trying to bring up rootfs device"
- systemctl is-failed dracut-initqueue || systemctl start dracut-initqueue
-
+ systemctl start dracut-initqueue
dinfo "Waiting for rootfs mount, will timeout after 90 seconds"
systemctl start sysroot.mount
--
2.29.2
1 year, 4 months