kdumpctl: Add kdumpctl reset-crashkernel
In newer kernel, crashkernel.default will contain the default crashkernel value of a kernel build. So introduce a new sub command to help user reset kernel crashkernel size to the default value. Signed-off-by: Kairui Song <kasong@redhat.com> Acked-by: Baoquan He <bhe@redhat.com>
This commit is contained in:
parent
017903c3c4
commit
86130ec10f
41
kdumpctl
41
kdumpctl
@ -1330,6 +1330,40 @@ do_estimate() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset_crashkernel() {
|
||||||
|
local kernel=$1 entry crashkernel_default
|
||||||
|
local grub_etc_default="/etc/default/grub"
|
||||||
|
|
||||||
|
[[ -z "$kernel" ]] && kernel=$(uname -r)
|
||||||
|
crashkernel_default=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2>/dev/null)
|
||||||
|
|
||||||
|
if [[ -z "$crashkernel_default" ]]; then
|
||||||
|
derror "$kernel doesn't have a crashkernel.default"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_atomic; then
|
||||||
|
if rpm-ostree kargs | grep -q "crashkernel="; then
|
||||||
|
rpm-ostree --replace="crashkernel=$crashkernel_default"
|
||||||
|
else
|
||||||
|
rpm-ostree --append="crashkernel=$crashkernel_default"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
entry=$(grubby --info ALL | grep "^kernel=.*$kernel")
|
||||||
|
entry=${entry#kernel=}
|
||||||
|
entry=${entry#\"}
|
||||||
|
entry=${entry%\"}
|
||||||
|
|
||||||
|
if [[ -f "$grub_etc_default" ]]; then
|
||||||
|
sed -i -e "s/^\(GRUB_CMDLINE_LINUX=.*\)crashkernel=[^\ \"]*\([\ \"].*\)$/\1$crashkernel_default\2/" "$grub_etc_default"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -f /etc/zipl.conf ]] && zipl_arg="--zipl"
|
||||||
|
grubby --args "$crashkernel_default" --update-kernel "$entry" $zipl_arg
|
||||||
|
[[ $zipl_arg ]] && zipl > /dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ ! -f "$KDUMP_CONFIG_FILE" ]; then
|
if [ ! -f "$KDUMP_CONFIG_FILE" ]; then
|
||||||
derror "Error: No kdump config file found!"
|
derror "Error: No kdump config file found!"
|
||||||
exit 1
|
exit 1
|
||||||
@ -1388,8 +1422,11 @@ main ()
|
|||||||
estimate)
|
estimate)
|
||||||
do_estimate
|
do_estimate
|
||||||
;;
|
;;
|
||||||
|
reset-crashkernel)
|
||||||
|
reset_crashkernel "$2"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|propagate|showmem}"
|
dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}"
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@ -1399,6 +1436,6 @@ single_instance_lock
|
|||||||
|
|
||||||
# To avoid fd 9 leaking, we invoke a subshell, close fd 9 and call main.
|
# To avoid fd 9 leaking, we invoke a subshell, close fd 9 and call main.
|
||||||
# So that fd isn't leaking when main is invoking a subshell.
|
# So that fd isn't leaking when main is invoking a subshell.
|
||||||
(exec 9<&-; main $1)
|
(exec 9<&-; main "$@")
|
||||||
|
|
||||||
exit $?
|
exit $?
|
||||||
|
@ -49,6 +49,15 @@ Prints the size of reserved memory for crash kernel in megabytes.
|
|||||||
Estimate a suitable crashkernel value for current machine. This is a
|
Estimate a suitable crashkernel value for current machine. This is a
|
||||||
best-effort estimate. It will print a recommanded crashkernel value
|
best-effort estimate. It will print a recommanded crashkernel value
|
||||||
based on current kdump setup, and list some details of memory usage.
|
based on current kdump setup, and list some details of memory usage.
|
||||||
|
.TP
|
||||||
|
.I reset-crashkernel [KERNEL]
|
||||||
|
Reset crashkernel value to default value. kdumpctl will try to read
|
||||||
|
from /usr/lib/modules/<KERNEL>/crashkernel.default and reset specified
|
||||||
|
kernel's crashkernel cmdline value. If no kernel is
|
||||||
|
specified, will reset current running kernel's crashkernel value.
|
||||||
|
If /usr/lib/modules/<KERNEL>/crashkernel.default doesn't exist, will
|
||||||
|
simply exit return 1.
|
||||||
|
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.BR kdump.conf (5),
|
.BR kdump.conf (5),
|
||||||
|
Loading…
Reference in New Issue
Block a user