Hi everybody,
here is the second try on the series. Since the first version I've concentrated on 1) splitting out the preparation/cleanup patches into their own series so they can be applied ahead of the rest. 2) refining the new 'crashkernel' command which now has four subcommands 'add', 'estimate', 'show' and, 'set'. 3) reworking the man pages and adding the new CLI to them. This includes bumping their date to today's date for the last non-trivial change.
The series depends on the cleanup series I've posted earlier. To simplify review I've also pushed the series to branch cli_rework on https://src.fedoraproject.org/forks/prudo/rpms/kexec-tools.git.
Thanks Philipp
rfc v1 -> rfv v2: - Rebased to latest rawhide - Moved former patches 1-5 & 8-10 to separate series - Added new patches 1-3, that overhaul the man pages and convert them to RST. - Update the man pages when changing the CLI - Small changes to --help so the wording matches the man pages - Fixed bug with --verbose when no KDUMP_STDLOGLVL was defined. - Former patches 25 & 26 by new patches 20-23, to refine the new 'crashkernel' command
Philipp Rudo (23): man: Convert to RST man/kdump.conf.5: Improve the man page man/kdumpctl.8: Improve the man page kdumpctl: make all subcommands execute exactly one function kdumpctl: Restructure subcommand handling and add usage kdumpctl: Simplify fadump handling in reset_crashkernel kdumpctl: Use getopt for option parsing in reset_crashkernel kdumpctl: Add simple bash-completion for kdumpctl kdumpctl: Make --kernel a global option kdumpctl: Add global -h/--help option kdumpctl: Add --kver option kdumpctl: Reduce dependencies from grubby for --kernel kdumpctl: merge reset_crashkernel_{after_update,for_installed_kernel} kdumpctl: Allow --kernel with 'start' and 'rebuild' kdumpctl: Add --quiet/--verbose option kdumpctl: Rework the 'status' subcommand kdumpctl: Merge _upgrade_crashkernel into the upgrade hook kdumpctl: Drop special handling for CoreOS in reset_crashkernel kdumpctl: Determine "old" value within _update_kernel_cmdline kdumpctl: Replace 'get-default-crashkernel' by 'crashkernel show' kdumpctl: Replace 'reset-crashkernel' with 'crashkernel set' kdumpctl: Make 'estimate' a subcommand of 'crashkernel' kdumpctl: Add 'crashkernel add' subcommand
92-crashkernel.install | 2 +- kdump-lib.sh | 6 + kdump.conf.5 | 378 --------------- kdump.conf.5.rst | 325 +++++++++++++ kdumpctl | 988 +++++++++++++++++++++++++++------------ kdumpctl.8 | 72 --- kdumpctl.8.rst | 158 +++++++ kdumpctl.bash-completion | 125 +++++ kexec-tools.spec | 29 +- mkdumprd.8 | 39 -- mkdumprd.8.rst | 54 +++ 11 files changed, 1387 insertions(+), 789 deletions(-) delete mode 100644 kdump.conf.5 create mode 100644 kdump.conf.5.rst delete mode 100644 kdumpctl.8 create mode 100644 kdumpctl.8.rst create mode 100755 kdumpctl.bash-completion delete mode 100644 mkdumprd.8 create mode 100644 mkdumprd.8.rst
The groff formatting language used by man pages is pretty hard to read. Thus convert the man pages to reStructuredText (RST) [1] markup language which is much easier to read and for which there are many different converters for example rst2man, rst2http, rst2latex and more.
The patch doesn't change the content of the man pages. Only exception are some minor changes in formatting.
Note: There was a bug in docutils [2] that adds an empty 'manual-section' to the .TH line even when no :manual group: field is provided. This causes mandoc to not print the default section name. This bug is supposed to be fixed with docutils 0.20.
[1] https://docutils.sourceforge.io/rst.html [2] https://sourceforge.net/p/docutils/bugs/458/
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdump.conf.5 | 378 ----------------------------------------------- kdump.conf.5.rst | 334 +++++++++++++++++++++++++++++++++++++++++ kdumpctl.8 | 72 --------- kdumpctl.8.rst | 80 ++++++++++ kexec-tools.spec | 13 +- mkdumprd.8 | 39 ----- mkdumprd.8.rst | 54 +++++++ 7 files changed, 475 insertions(+), 495 deletions(-) delete mode 100644 kdump.conf.5 create mode 100644 kdump.conf.5.rst delete mode 100644 kdumpctl.8 create mode 100644 kdumpctl.8.rst delete mode 100644 mkdumprd.8 create mode 100644 mkdumprd.8.rst
diff --git a/kdump.conf.5 b/kdump.conf.5 deleted file mode 100644 index 9117aa7..0000000 --- a/kdump.conf.5 +++ /dev/null @@ -1,378 +0,0 @@ -.TH KDUMP.CONF 5 "07/23/2008" "kexec-tools" - -.SH NAME -kdump.conf - configuration file for kdump kernel. - -.SH DESCRIPTION - -kdump.conf is a configuration file for the kdump kernel crash -collection service. - -kdump.conf provides post-kexec instructions to the kdump kernel. It is -stored in the initrd file managed by the kdump service. If you change -this file and do not want to reboot in order for the changes to take -effect, restart the kdump service to rebuild the initrd. - -For most configurations, you can simply review the examples provided -in the stock /etc/kdump.conf. - -.B NOTE: -For filesystem dumps the dump target must be mounted before building -kdump initramfs. - -kdump.conf only affects the behavior of the initramfs. Please read the -kdump operational flow section of kexec-kdump-howto.txt in the docs to better -understand how this configuration file affects the behavior of kdump. - -.SH OPTIONS - -.B auto_reset_crashkernel <yes|no> -.RS -determine whether to reset kernel crashkernel parameter to the default value -or not when kexec-tools is updated or a new kernel is installed. - -.B raw <partition> -.RS -Will dd /proc/vmcore into <partition>. Use persistent device names for -partition devices, such as /dev/vg/<devname>. -.RE - -.B nfs <nfs mount> -.RS -Will mount nfs to <mnt>, and copy /proc/vmcore to <mnt>/<path>/%HOST-%DATE/, -supports DNS. Note that a fqdn should be used as the server name in the -mount point. -.RE - -.B ssh user@server -.RS -Will save /proc/vmcore through ssh pipe to user@server:<path>/%HOST-%DATE/, -supports DNS. NOTE: make sure user has necessary write permissions on -server and that a fqdn is used as the server name. -.RE - -.B sshkey <path> -.RS -Specify the path of the ssh key to use when dumping via ssh. -The default value is /root/.ssh/kdump_id_rsa. -.RE - -.B <fs type> <partition> -.RS -Will mount -t <fs type> <partition> <mnt>, and copy /proc/vmcore to -<mnt>/<path>/%HOST_IP-%DATE/. NOTE: <partition> can be a device node, label -or uuid. It's recommended to use persistent device names such as -/dev/vg/<devname>. Otherwise it's suggested to use label or uuid. -.RE - -.B path <path> -.RS -"path" represents the file system path in which vmcore will be saved. -If a dump target is specified in kdump.conf, then "path" is relative to the -specified dump target. -.PP -Interpretation of "path" changes a bit if the user didn't specify any dump -target explicitly in kdump.conf. In this case, "path" represents the -absolute path from root. The dump target and adjusted path are arrived -at automatically depending on what's mounted in the current system. -.PP -Ignored for raw device dumps. If unset, will use the default "/var/crash". -.RE - -.B core_collector <command> <options> -.RS -This allows you to specify the command to copy the vmcore. -The default is makedumpfile, which on some architectures can drastically reduce -core file size. See /sbin/makedumpfile --help for a list of options. -Note that the -i and -g options are not needed here, as the initrd -will automatically be populated with a config file appropriate -for the running kernel. -.PP -Note 1: About default core collector: -The default core_collector for raw/ssh dump is: -"makedumpfile -F -l --message-level 7 -d 31". -The default core_collector for other targets is: -"makedumpfile -l --message-level 7 -d 31". -Even if core_collector option is commented out in kdump.conf, makedumpfile -is the default core collector and kdump uses it internally. -If one does not want makedumpfile as default core_collector, then they -need to specify one using core_collector option to change the behavior. -.PP -Note 2: If "makedumpfile -F" is used then you will get a flattened format -vmcore.flat, you will need to use "makedumpfile -R" to rearrange the -dump data from standard input to a normal dumpfile (readable with analysis -tools). -ie. "makedumpfile -R vmcore < vmcore.flat" -.PP -Note 3: If specified core_collector simply copy the vmcore file to the -dump target (eg: cp, scp), the vmcore could be significantly large. -Please make sure the dump target has enough space, at leaset larger -than the system's RAM. - -.RE - -.B kdump_post <binary | script> -.RS -This directive allows you to run a specified executable -just after the vmcore dump process terminates. The exit -status of the current dump process is fed to the kdump_post -executable as its first argument($1). Executable can modify -it to indicate the new exit status of succeeding dump process, -.PP -All files under /etc/kdump/post.d are collectively sorted -and executed in lexical order, before binary or script -specified kdump_post parameter is executed. -.PP -Note that scripts written for use with this directive must use the /bin/bash -interpreter. And since these scripts run in kdump enviroment, the reference to -the storage or network device in the scripts should adhere to the section -'Supported dump target types and requirements' in kexec-kdump-howto.txt. - -.RE - -.B kdump_pre <binary | script> -.RS -Works just like the "kdump_post" directive, but instead -of running after the dump process, runs immediately -before. Exit status of this binary is interpreted -as follows: -.PP -0 - continue with dump process as usual -.PP -non 0 - run the final action (reboot/poweroff/halt) -.PP -All files under /etc/kdump/pre.d are collectively sorted and -executed in lexical order, after binary or script specified -kdump_pre parameter is executed. -Even if the binary or script in /etc/kdump/pre.d directory -returns non 0 exit status, the processing is continued. -.PP -Note that scripts written for use with this directive must use the /bin/bash -interpreter. And since these scripts run in kdump enviroment, the reference to -the storage or network device in the scripts should adhere to the section -'Supported dump target types and requirements' in kexec-kdump-howto.txt. - -.RE - -.B extra_bins <binaries | shell scripts> -.RS -This directive allows you to specify additional -binaries or shell scripts you'd like to include in -your kdump initrd. Generally only useful in -conjunction with a kdump_post binary or script that -relies on other binaries or scripts. -.RE - -.B extra_modules <module(s)> -.RS -This directive allows you to specify extra kernel -modules that you want to be loaded in the kdump -initrd, typically used to set up access to -non-boot-path dump targets that might otherwise -not be accessible in the kdump environment. Multiple -modules can be listed, separated by spaces, and any -dependent modules will automatically be included. -.RE - -.B failure_action <reboot | halt | poweroff | shell | dump_to_rootfs> -.RS -Action to perform in case dumping to the intended target fails. The default is "reboot". -reboot: Reboot the system (this is what most people will want, as it returns the system -to a normal state). halt: Halt the system and lose the vmcore. poweroff: The system -will be powered down. shell: Drop to a shell session inside the initramfs, from which -you can manually perform additional recovery actions. Exiting this shell reboots the -system by default or performs "final_action". -Note: kdump uses bash as the default shell. dump_to_rootfs: If non-root dump -target is specified, the failure action can be set as dump_to_rootfs. That means when -dumping to target fails, dump vmcore to rootfs from initramfs context and reboot -by default or perform "final_action". -.RE - -.B default <reboot | halt | poweroff | shell | dump_to_rootfs> -.RS -Same as the "failure_action" directive above, but this directive is obsolete -and will be removed in the future. -.RE - -.B final_action <reboot | halt | poweroff> -.RS -Action to perform in case dumping to the intended target succeeds. -Also performed when "shell" or "dump_to_rootfs" failure action finishes. -Each action is same as the "failure_action" directive above. -The default is "reboot". -.RE - -.B force_rebuild <0 | 1> -.RS -By default, kdump initrd will only be rebuilt when necessary. -Specify 1 to force rebuilding kdump initrd every time when kdump service starts. -.RE - -.B force_no_rebuild <0 | 1> -.RS -By default, kdump initrd will be rebuilt when necessary. -Specify 1 to bypass rebuilding of kdump initrd. - -.PP -force_no_rebuild and force_rebuild options are mutually exclusive and -they should not be set to 1 simultaneously. -.RE - -.B dracut_args <arg(s)> -.RS -Kdump uses dracut to generate initramfs for second kernel. This option -allows a user to pass arguments to dracut directly. -.RE - - -.B fence_kdump_args <arg(s)> -.RS -Command line arguments for fence_kdump_send (it can contain all valid -arguments except hosts to send notification to). -.RE - - -.B fence_kdump_nodes <node(s)> -.RS -List of cluster node(s) except localhost, separated by spaces, to send fence_kdump notification -to (this option is mandatory to enable fence_kdump). -.RE - - -.SH DEPRECATED OPTIONS - -.B net <nfs mount>|user@server -.RS -net option is replaced by nfs and ssh options. Use nfs or ssh options -directly. -.RE - -.B options <module> <option list> -.RS -Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump to add module options as -kernel command line parameters. For example, specify 'loop.max_loop=1' to limit -maximum loop devices to 1. -.RE - -.B link_delay <seconds> -.RS -link_delay was used to wait for a network device to initialize before using it. -Now dracut network module takes care of this issue automatically. -.RE - -.B disk_timeout <seconds> -.RS -Similar to link_delay, dracut ensures disks are ready before kdump uses them. -.RE - -.B debug_mem_level <0-3> -.RS -Turn on verbose debug output of kdump scripts regarding free/used memory at -various points of execution. This feature has been -moved to dracut now. -Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump and -append dracut cmdline param rd.memdebug=[0-3] to enable the debug output. - -Higher level means more debugging output. -.PP -0 - no output -.PP -1 - partial /proc/meminfo -.PP -2 - /proc/meminfo -.PP -3 - /proc/meminfo + /proc/slabinfo -.RE - -.B blacklist <list of kernel modules> -.RS -blacklist option was recently being used to prevent loading modules in -initramfs. General terminology for blacklist has been that module is -present in initramfs but it is not actually loaded in kernel. Hence -retaining blacklist option creates more confusing behavior. It has been -deprecated. -.PP -Instead, use rd.driver.blacklist option on second kernel to blacklist -a certain module. One can edit /etc/sysconfig/kdump.conf and edit -KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer -to dracut.cmdline man page for more details on module blacklist option. -.RE - -.RE - -.SH EXAMPLES -Here are some examples for core_collector option: -.PP -Core collector command format depends on dump target type. Typically for -filesystem (local/remote), core_collector should accept two arguments. -First one is source file and second one is target file. For ex. -.TP -ex1. -core_collector "cp --sparse=always" - -Above will effectively be translated to: - -cp --sparse=always /proc/vmcore <dest-path>/vmcore -.TP -ex2. -core_collector "makedumpfile -l --message-level 7 -d 31" - -Above will effectively be translated to: - -makedumpfile -l --message-level 7 -d 31 /proc/vmcore <dest-path>/vmcore -.PP -For dump targets like raw and ssh, in general, core collector should expect -one argument (source file) and should output the processed core on standard -output (There is one exception of "scp", discussed later). This standard -output will be saved to destination using appropriate commands. - -raw dumps examples: -.TP -ex3. -core_collector "cat" - -Above will effectively be translated to. - -cat /proc/vmcore | dd of=<target-device> -.TP -ex4. -core_collector "makedumpfile -F -l --message-level 7 -d 31" - -Above will effectively be translated to. - -makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device> -.PP -ssh dumps examples -.TP -ex5. -core_collector "cat" - -Above will effectively be translated to. - -cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore" -.TP -ex6. -core_collector "makedumpfile -F -l --message-level 7 -d 31" - -Above will effectively be translated to. - -makedumpfile -F -l --message-level 7 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore" - -There is one exception to standard output rule for ssh dumps. And that is -scp. As scp can handle ssh destinations for file transfers, one can -specify "scp" as core collector for ssh targets (no output on stdout). -.TP -ex7. -core_collector "scp" - -Above will effectively be translated to. - -scp /proc/vmcore user@host:path/vmcore - -.PP -examples for other options please see -.I /etc/kdump.conf - -.SH SEE ALSO - -kexec(8) mkdumprd(8) dracut.cmdline(7) diff --git a/kdump.conf.5.rst b/kdump.conf.5.rst new file mode 100644 index 0000000..7dd06b0 --- /dev/null +++ b/kdump.conf.5.rst @@ -0,0 +1,334 @@ +========== +kdump.conf +========== + +------------------------------------ +configuration file for kdump kernel. +------------------------------------ + +:Date: 2008-07-23 +:Manual section: 5 +:Version: kexec-tools + +DESCRIPTION +=========== + +kdump.conf is a configuration file for the kdump kernel crash +collection service. + +kdump.conf provides post-kexec instructions to the kdump kernel. It is +stored in the initrd file managed by the kdump service. If you change +this file and do not want to reboot in order for the changes to take +effect, restart the kdump service to rebuild the initrd. + +For most configurations, you can simply review the examples provided +in the stock /etc/kdump.conf. + +.. note:: For filesystem dumps the dump target must be mounted before building + kdump initramfs. + +kdump.conf only affects the behavior of the initramfs. Please read the +kdump operational flow section of kexec-kdump-howto.txt in the docs to better +understand how this configuration file affects the behavior of kdump. + +OPTIONS +======= + +auto_reset_crashkernel <yes|no> + Determine whether to reset kernel crashkernel parameter to the default value + or not when kexec-tools is updated or a new kernel is installed. + +raw <partition> + Will dd /proc/vmcore into <partition>. Use persistent device names for + partition devices, such as /dev/vg/<devname>. + +nfs <nfs mount> + Will mount nfs to <mnt>, and copy /proc/vmcore to <mnt>/<path>/%HOST-%DATE/, + supports DNS. + + .. note:: A fqdn should be used as the server name in the mount point. + +ssh user@server + Will save /proc/vmcore through ssh pipe to user@server:<path>/%HOST-%DATE/, + supports DNS. + + .. note:: Make sure user has necessary write permissions on server and that a + fqdn is used as the server name. + +sshkey <path> + Specify the path of the ssh key to use when dumping via ssh. The default + value is /root/.ssh/kdump_id_rsa. + +<fs type> <partition> + Will mount -t <fs type> <partition> <mnt>, and copy /proc/vmcore to + <mnt>/<path>/%HOST_IP-%DATE/. + + .. note:: <partition> can be a device node, label or uuid. It's recommended + to use persistent device names such as /dev/vg/<devname>. Otherwise it's + suggested to use label or uuid. + +path <path> + "path" represents the file system path in which vmcore will be saved. If a + dump target is specified in kdump.conf, then "path" is relative to the + specified dump target. + + Interpretation of "path" changes a bit if the user didn't specify any dump + target explicitly in kdump.conf. In this case, "path" represents the absolute + path from root. The dump target and adjusted path are arrived at + automatically depending on what's mounted in the current system. + + Ignored for raw device dumps. If unset, will use the default "/var/crash". + +core_collector <command> <options> + This allows you to specify the command to copy the vmcore. The default is + makedumpfile, which on some architectures can drastically reduce core file + size. See /sbin/makedumpfile --help for a list of options. Note that the -i + and -g options are not needed here, as the initrd will automatically be + populated with a config file appropriate for the running kernel. + + .. note:: The default core_collector for raw/ssh dump is: "makedumpfile -F -l + --message-level 7 -d 31". The default core_collector for other targets is: + "makedumpfile -l --message-level 7 -d 31". Even if core_collector option + is commented out in kdump.conf, makedumpfile is the default core collector + and kdump uses it internally. If one does not want makedumpfile as default + core_collector, then they need to specify one using core_collector option + to change the behavior. + + .. note:: If "makedumpfile -F" is used then you will get a flattened format + vmcore.flat, you will need to use "makedumpfile -R" to rearrange the dump + data from standard input to a normal dumpfile (readable with analysis + tools). ie. "makedumpfile -R vmcore < vmcore.flat" + + .. note:: If specified core_collector simply copy the vmcore file to the dump + target (eg: cp, scp), the vmcore could be significantly large. Please make + sure the dump target has enough space, at leaset larger than the system's + RAM. + +kdump_post <binary | script> + This directive allows you to run a specified executable just after the vmcore + dump process terminates. The exit status of the current dump process is fed + to the kdump_post executable as its first argument($1). Executable can + modify it to indicate the new exit status of succeeding dump process, + + All files under /etc/kdump/post.d are collectively sorted and executed in + lexical order, before binary or script specified kdump_post parameter is + executed. + + .. note:: All scripts written for use with this directive must use the + /bin/bash interpreter. And since these scripts run in kdump enviroment, the + reference to the storage or network device in the scripts should adhere to + the section 'Supported dump target types and requirements' in + kexec-kdump-howto.txt. + +kdump_pre <binary | script> + Works just like the "kdump_post" directive, but instead of running after the + dump process, runs immediately before. Exit status of this binary is + interpreted as follows: + + 0 - continue with dump process as usual + + non 0 - run the final action (reboot/poweroff/halt) + + All files under /etc/kdump/pre.d are collectively sorted and executed in + lexical order, after binary or script specified kdump_pre parameter is + executed. Even if the binary or script in /etc/kdump/pre.d directory returns + non 0 exit status, the processing is continued. + + .. note:: All scripts written for use with this directive must use the + /bin/bash interpreter. And since these scripts run in kdump enviroment, the + reference to the storage or network device in the scripts should adhere to + the section 'Supported dump target types and requirements' in + kexec-kdump-howto.txt. + +extra_bins <binaries | shell scripts> + This directive allows you to specify additional binaries or shell scripts + you'd like to include in your kdump initrd. Generally only useful in + conjunction with a kdump_post binary or script that relies on other binaries + or scripts. + +extra_modules <module(s)> + This directive allows you to specify extra kernel modules that you want to be + loaded in the kdump initrd, typically used to set up access to non-boot-path + dump targets that might otherwise not be accessible in the kdump environment. + Multiple modules can be listed, separated by spaces, and any dependent + modules will automatically be included. + +failure_action <reboot | halt | poweroff | shell | dump_to_rootfs> + Action to perform in case dumping to the intended target fails. The default + is "reboot". + + * reboot: Reboot the system (this is what most people will want, as it + returns the system to a normal state). + * halt: Halt the system and lose the vmcore. + * poweroff: The system will be powered down. + * shell: Drop to a shell session inside the initramfs, from which you can + manually perform additional recovery actions. Exiting this shell reboots + the system by default or performs "final_action". + + .. note:: kdump uses bash as the default shell. + + * dump_to_rootfs: If non-root dump target is specified, the failure action + can be set as dump_to_rootfs. That means when dumping to target fails, + dump vmcore to rootfs from initramfs context and reboot by default or + perform "final_action". + +default <reboot | halt | poweroff | shell | dump_to_rootfs> + Same as the "failure_action" directive above, but this directive is obsolete + and will be removed in the future. + +final_action <reboot | halt | poweroff> + Action to perform in case dumping to the intended target succeeds. Also + performed when "shell" or "dump_to_rootfs" failure action finishes. Each + action is same as the "failure_action" directive above. The default is + "reboot". + +force_rebuild <0 | 1> + By default, kdump initrd will only be rebuilt when necessary. Specify 1 to + force rebuilding kdump initrd every time when kdump service starts. + +force_no_rebuild <0 | 1> + By default, kdump initrd will be rebuilt when necessary. Specify 1 to bypass + rebuilding of kdump initrd. + + force_no_rebuild and force_rebuild options are mutually exclusive and they + should not be set to 1 simultaneously. + +dracut_args <arg(s)> + Kdump uses dracut to generate initramfs for second kernel. This option allows + a user to pass arguments to dracut directly. + + +fence_kdump_args <arg(s)> + Command line arguments for fence_kdump_send (it can contain all valid + arguments except hosts to send notification to). + + +fence_kdump_nodes <node(s)> + List of cluster node(s) except localhost, separated by spaces, to send + fence_kdump notification to (this option is mandatory to enable fence_kdump). + + +DEPRECATED OPTIONS +================== + +net <nfs mount>|user@server + net option is replaced by nfs and ssh options. Use nfs or ssh options + directly. + +options <module> <option list> + Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump to add module options as + kernel command line parameters. For example, specify 'loop.max_loop=1' to + limit maximum loop devices to 1. + +link_delay <seconds> + link_delay was used to wait for a network device to initialize before using + it. Now dracut network module takes care of this issue automatically. + +disk_timeout <seconds> + Similar to link_delay, dracut ensures disks are ready before kdump uses them. + +debug_mem_level <0-3> + Turn on verbose debug output of kdump scripts regarding free/used memory at + various points of execution. This feature has been moved to dracut now. Use + KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump and append dracut cmdline + param rd.memdebug=[0-3] to enable the debug output. + + Higher level means more debugging output. + + 0 - no output + + 1 - partial /proc/meminfo + + 2 - /proc/meminfo + + 3 - /proc/meminfo + /proc/slabinfo + +blacklist <list of kernel modules> + blacklist option was recently being used to prevent loading modules in + initramfs. General terminology for blacklist has been that module is present + in initramfs but it is not actually loaded in kernel. Hence retaining + blacklist option creates more confusing behavior. It has been deprecated. + + Instead, use rd.driver.blacklist option on second kernel to blacklist a + certain module. One can edit /etc/sysconfig/kdump.conf and edit + KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer to + dracut.cmdline man page for more details on module blacklist option. + +EXAMPLES +======== + +Here are some examples for core_collector option: + +Core collector command format depends on dump target type. Typically for +filesystem (local/remote), core_collector should accept two arguments. +First one is source file and second one is target file. For ex. + + Example 1 + core_collector "cp --sparse=always" + + Above will effectively be translated to: + + cp --sparse=always /proc/vmcore <dest-path>/vmcore + + Example 2 + core_collector "makedumpfile -l --message-level 7 -d 31" + + Above will effectively be translated to: + + makedumpfile -l --message-level 7 -d 31 /proc/vmcore <dest-path>/vmcore + +For dump targets like raw and ssh, in general, core collector should expect one +argument (source file) and should output the processed core on standard output +(There is one exception of "scp", discussed later). This standard output will +be saved to destination using appropriate commands. + +raw dumps examples: + + Example 3 + core_collector "cat" + + Above will effectively be translated to. + + cat /proc/vmcore | dd of=<target-device> + + Example 4 + core_collector "makedumpfile -F -l --message-level 7 -d 31" + + Above will effectively be translated to. + + makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device> + +ssh dumps examples + + Example 5 + core_collector "cat" + + Above will effectively be translated to. + + cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore" + + Example 6 + core_collector "makedumpfile -F -l --message-level 7 -d 31" + + Above will effectively be translated to. + + makedumpfile -F -l --message-level 7 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore" + + There is one exception to standard output rule for ssh dumps. And that is + scp. As scp can handle ssh destinations for file transfers, one can specify + "scp" as core collector for ssh targets (no output on stdout). + + Example 7 + core_collector "scp" + + Above will effectively be translated to. + + scp /proc/vmcore user@host:path/vmcore + + +examples for other options please see */etc/kdump.conf* + +SEE ALSO +======== + +**dracut.cmdline(7)**, **kexec(8)**, **makedumpfile(8)** diff --git a/kdumpctl.8 b/kdumpctl.8 deleted file mode 100644 index 33c1115..0000000 --- a/kdumpctl.8 +++ /dev/null @@ -1,72 +0,0 @@ -.TH KDUMPCTL 8 2015-07-13 kexec-tools - -.SH NAME -kdumpctl - control interface for kdump - -.SH SYNOPSIS -.B kdumpctl -.I COMMAND - -.SH DESCRIPTION -.B kdumpctl -is used to check or control the kdump service. -In most cases, you should use -.B systemctl -to start / stop / enable kdump service instead. However, -.B kdumpctl -provides more details for debugging and a helper to set up ssh key authentication. - -.SH COMMANDS -.TP -.I start -Start the service. -.TP -.I stop -Stop the service. -.TP -.I status -Prints the current status of kdump service. -It returns a non-zero value if kdump is not operational. -.TP -.I restart -Is equal to -.I start; stop -.TP -.I reload -reload the crash kernel image and initramfs without triggering a rebuild. -.TP -.I rebuild -rebuild the crash kernel initramfs. -.TP -.I propagate -Helps to setup key authentication for ssh storage since it's -impossible to use password authentication during kdump. -.TP -.I showmem -Prints the size of reserved memory for the crash kernel in megabytes. -.TP -.I estimate -Estimate a suitable crashkernel value for the current machine. This is a -best-effort estimate. It will print a recommended crashkernel value -based on the current kdump setup, and list some details of memory usage. -.TP -.I get-default-crashkernel -Return the default crashkernel value provided by kexec-tools. -.TP -.I reset-crashkernel [--kernel=path_to_kernel] [--reboot] -Reset crashkernel to default value recommended by kexec-tools. If no kernel -is specified, will reset KDUMP_KERNELVER if it's defined in /etc/sysconfig/kdump -or the current running kernel's crashkernel value if KDUMP_KERNELVER is empty. You can -also specify --kernel=ALL and --kernel=DEFAULT which have the same meaning as -grubby's kernel-path=ALL and kernel-path=DEFAULT. ppc64le supports FADump and -supports an additional [--fadump=[on|off|nocma]] parameter to toggle FADump -on/off. - -Note: The memory requirements for kdump varies heavily depending on the -used hardware and system configuration. Thus the recommended -crashkernel might not work for your specific setup. Please test if -kdump works after resetting the crashkernel value. - -.SH "SEE ALSO" -.BR kdump.conf (5), -.BR mkdumprd (8) diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst new file mode 100644 index 0000000..3488af4 --- /dev/null +++ b/kdumpctl.8.rst @@ -0,0 +1,80 @@ +======== +kdumpctl +======== + +--------------------------- +control interface for kdump +--------------------------- + +:Date: 2015-07-13 +:Manual section: 8 +:Version: kexec-tools + +SYNOPSIS +======== + +**kdumpctl** *COMMAND* + +DESCRIPTION +=========== + +**kdumpctl** is used to check or control the kdump service. In most cases, you +should use **systemctl** to start / stop / enable kdump service instead. +However, **kdumpctl** provides more details for debugging and a helper to set +up ssh key authentication. + +COMMANDS +======== + +start + Start the service. + +stop + Stop the service. + +status + Prints the current status of kdump service. It returns a non-zero value if + kdump is not operational. + +restart + Is equal to **start; stop** + +reload + Reload the crash kernel image and initramfs without triggering a rebuild. + +rebuild + Rebuild the crash kernel initramfs. + +propagate + Helps to setup key authentication for ssh storage since it's impossible to + use password authentication during kdump. + +showmem + Prints the size of reserved memory for the crash kernel in megabytes. + +estimate + Estimate a suitable crashkernel value for the current machine. This is a + best-effort estimate. It will print a recommended crashkernel value based on + the current kdump setup, and list some details of memory usage. + +get-default-crashkernel + Return the default crashkernel value provided by kexec-tools. + +reset-crashkernel [--kernel=path_to_kernel] [--reboot] + Reset crashkernel to default value recommended by kexec-tools. If no kernel + is specified, will reset **KDUMP_KERNELVER** if it is defined in + */etc/sysconfig/kdump* or the current running kernels crashkernel value if + KDUMP_KERNELVER is empty. You can also specify **--kernel=ALL** and + **--kernel=DEFAULT** which have the same meaning as grubbys kernel-path=ALL + and kernel-path=DEFAULT. ppc64le supports FADump and supports an additional + [**--fadump=[on|off|nocma]**] parameter to toggle FADump on/off. + + .. note:: The memory requirements for kdump varies heavily depending on the + used hardware and system configuration. Thus the recommended + crashkernel might not work for your specific setup. Please test if + kdump works after resetting the crashkernel value. + +SEE ALSO +======== + +**kdump.conf (5)**, **mkdumprd (8)** diff --git a/kexec-tools.spec b/kexec-tools.spec index ca3179e..6b2eac4 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -17,17 +17,17 @@ Source7: mkdumprd Source9: https://github.com/makedumpfile/makedumpfile/archive/%%7Bmkdf_ver%7D/makedum... Source10: kexec-kdump-howto.txt Source11: fadump-howto.txt -Source12: mkdumprd.8 +Source12: mkdumprd.8.rst Source13: 98-kexec.rules Source14: 98-kexec.rules.ppc64 -Source15: kdump.conf.5 +Source15: kdump.conf.5.rst Source16: kdump.service Source19: https://github.com/lucchouina/eppic/archive/%%7Beppic_ver%7D/eppic-%%7Beppic... Source20: kdump-lib.sh Source21: kdump-in-cluster-environment.txt Source22: kdump-dep-generator.sh Source23: kdump-lib-initramfs.sh -Source25: kdumpctl.8 +Source25: kdumpctl.8.rst Source26: live-image-kdump-howto.txt Source27: early-kdump-howto.txt Source28: kdump-udev-throttler @@ -75,6 +75,7 @@ BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel b BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-rpm-macros BuildRequires: automake autoconf libtool +BuildRequires: python3-docutils
%ifnarch s390x Requires: systemd-udev%{?_isa} @@ -187,8 +188,8 @@ install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd install -m 644 kdump.conf $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf install -m 644 kdump.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 -install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 -install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 +rst2man %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 +rst2man %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh install -m 755 %{SOURCE31} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-logger.sh @@ -209,7 +210,7 @@ install -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules install -m 755 -D %{SOURCE37} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-fadump.install %endif -install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 +rst2man %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh install -m 755 -D %{SOURCE30} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-kdump.install diff --git a/mkdumprd.8 b/mkdumprd.8 deleted file mode 100644 index 2ac3d5a..0000000 --- a/mkdumprd.8 +++ /dev/null @@ -1,39 +0,0 @@ -.TH MKDUMRD 8 "Fri Feb 9 2007" -.SH NAME -mkdumprd - creates initial ramdisk images for kdump crash recovery -.SH SYNOPSIS -\fBmkdumprd\fR [OPTION] - -.SH DESCRIPTION -\fBmkdumprd\fR creates an initial ram file system for use in conjunction with -the booting of a kernel within the kdump framework for crash recovery. -\fBmkdumprds\fR purpose is to create an initial ram filesystem capable of copying -the crashed systems vmcore image to a location specified in \fI/etc/kdump.conf - -\fBmkdumprd\fR interrogates the running system to understand what modules need to -be loaded in the initramfs (based on configuration retrieved from -\fI/etc/kdump.conf)\fR - -\fBmkdumprd\fR add a new \fBdracut\fR module 99kdumpbase and use \fBdracut\fR -utility to generate the initramfs. When generating a kdump initramfs, \fBmkdumprd\fR -will determine how much disk space is available, if the dump target's available -space is not greater than the total system memory, \fBmkdumprd\fR will print a -warning to remind that there might not be enough space to save a vmcore. The -warning covers extreme scenarios such as the slab explodes with non-zero data or -a full vmcore, etc. Therefore, need to prevent users from having minimum disk -space for crash dump. - -\fBmkdumprd\fR was not intended for casual use outside of the service -initialization script for the kdump utility, and should not be run manually. If -you require a custom kdump initramfs image, it is suggested that you use the -kdump service infrastructure to create one, and then manually unpack, modify and -repack the image. - - -.SH OPTIONS -.TP -All options here are passed to dracut directly, please refer \fBdracut\fR docs -for the info. - -.SH "SEE ALSO" -.BR dracut (8) diff --git a/mkdumprd.8.rst b/mkdumprd.8.rst new file mode 100644 index 0000000..1b2c2d2 --- /dev/null +++ b/mkdumprd.8.rst @@ -0,0 +1,54 @@ +======== +mkdumprd +======== + +------------------------------------------------------- +creates initial ramdisk images for kdump crash recovery +------------------------------------------------------- + +:Date: 2007-02-09 +:Manual Section: 8 + +SYNOPSIS +======== + +**mkdumprd** [OPTION] + +DESCRIPTION +=========== + +**mkdumprd** creates an initial ram file system for use in conjunction with +the booting of a kernel within the kdump framework for crash recovery. +**mkdumprds** purpose is to create an initial ram filesystem capable of copying +the crashed systems vmcore image to a location specified in */etc/kdump.conf* + +**mkdumprd** interrogates the running system to understand what modules need to +be loaded in the initramfs (based on configuration retrieved from +*/etc/kdump.conf*) + +**mkdumprd** add a new **dracut** module 99kdumpbase and use **dracut** +utility to generate the initramfs. When generating a kdump initramfs, **mkdumprd** +will determine how much disk space is available, if the dump target's available +space is not greater than the total system memory, **mkdumprd** will print a +warning to remind that there might not be enough space to save a vmcore. The +warning covers extreme scenarios such as the slab explodes with non-zero data or +a full vmcore, etc. Therefore, need to prevent users from having minimum disk +space for crash dump. + +**mkdumprd** was not intended for casual use outside of the service +initialization script for the kdump utility, and should not be run manually. If +you require a custom kdump initramfs image, it is suggested that you use the +kdump service infrastructure to create one, and then manually unpack, modify and +repack the image. + + +OPTIONS +======= + +All options here are passed to dracut directly, please refer **dracut** docs +for the info. + +SEE ALSO +======== + +**dracut (8)**
On Fri, Jul 21, 2023 at 10:26 PM Philipp Rudo prudo@redhat.com wrote:
The groff formatting language used by man pages is pretty hard to read. Thus convert the man pages to reStructuredText (RST) [1] markup language which is much easier to read and for which there are many different converters for example rst2man, rst2http, rst2latex and more.
I saw the use of rst2man in this patch. But in the converse direction, how was the patch formed. I had a try with 'pandoc' on kdump.conf.5, but got several difference from the one in this patch.
Could you pay some words on it, so I can verify it.
Thanks,
Pingfan
The patch doesn't change the content of the man pages. Only exception are some minor changes in formatting.
Note: There was a bug in docutils [2] that adds an empty 'manual-section' to the .TH line even when no :manual group: field is provided. This causes mandoc to not print the default section name. This bug is supposed to be fixed with docutils 0.20.
[1] https://docutils.sourceforge.io/rst.html [2] https://sourceforge.net/p/docutils/bugs/458/
Signed-off-by: Philipp Rudo prudo@redhat.com
kdump.conf.5 | 378 ----------------------------------------------- kdump.conf.5.rst | 334 +++++++++++++++++++++++++++++++++++++++++ kdumpctl.8 | 72 --------- kdumpctl.8.rst | 80 ++++++++++ kexec-tools.spec | 13 +- mkdumprd.8 | 39 ----- mkdumprd.8.rst | 54 +++++++ 7 files changed, 475 insertions(+), 495 deletions(-) delete mode 100644 kdump.conf.5 create mode 100644 kdump.conf.5.rst delete mode 100644 kdumpctl.8 create mode 100644 kdumpctl.8.rst delete mode 100644 mkdumprd.8 create mode 100644 mkdumprd.8.rst
diff --git a/kdump.conf.5 b/kdump.conf.5 deleted file mode 100644 index 9117aa7..0000000 --- a/kdump.conf.5 +++ /dev/null @@ -1,378 +0,0 @@ -.TH KDUMP.CONF 5 "07/23/2008" "kexec-tools"
-.SH NAME -kdump.conf - configuration file for kdump kernel.
-.SH DESCRIPTION
-kdump.conf is a configuration file for the kdump kernel crash -collection service.
-kdump.conf provides post-kexec instructions to the kdump kernel. It is -stored in the initrd file managed by the kdump service. If you change -this file and do not want to reboot in order for the changes to take -effect, restart the kdump service to rebuild the initrd.
-For most configurations, you can simply review the examples provided -in the stock /etc/kdump.conf.
-.B NOTE: -For filesystem dumps the dump target must be mounted before building -kdump initramfs.
-kdump.conf only affects the behavior of the initramfs. Please read the -kdump operational flow section of kexec-kdump-howto.txt in the docs to better -understand how this configuration file affects the behavior of kdump.
-.SH OPTIONS
-.B auto_reset_crashkernel <yes|no> -.RS -determine whether to reset kernel crashkernel parameter to the default value -or not when kexec-tools is updated or a new kernel is installed.
-.B raw <partition> -.RS -Will dd /proc/vmcore into <partition>. Use persistent device names for -partition devices, such as /dev/vg/<devname>. -.RE
-.B nfs <nfs mount> -.RS -Will mount nfs to <mnt>, and copy /proc/vmcore to <mnt>/<path>/%HOST-%DATE/, -supports DNS. Note that a fqdn should be used as the server name in the -mount point. -.RE
-.B ssh user@server -.RS -Will save /proc/vmcore through ssh pipe to user@server:<path>/%HOST-%DATE/, -supports DNS. NOTE: make sure user has necessary write permissions on -server and that a fqdn is used as the server name. -.RE
-.B sshkey <path> -.RS -Specify the path of the ssh key to use when dumping via ssh. -The default value is /root/.ssh/kdump_id_rsa. -.RE
-.B <fs type> <partition> -.RS -Will mount -t <fs type> <partition> <mnt>, and copy /proc/vmcore to -<mnt>/<path>/%HOST_IP-%DATE/. NOTE: <partition> can be a device node, label -or uuid. It's recommended to use persistent device names such as -/dev/vg/<devname>. Otherwise it's suggested to use label or uuid. -.RE
-.B path <path> -.RS -"path" represents the file system path in which vmcore will be saved. -If a dump target is specified in kdump.conf, then "path" is relative to the -specified dump target. -.PP -Interpretation of "path" changes a bit if the user didn't specify any dump -target explicitly in kdump.conf. In this case, "path" represents the -absolute path from root. The dump target and adjusted path are arrived -at automatically depending on what's mounted in the current system. -.PP -Ignored for raw device dumps. If unset, will use the default "/var/crash". -.RE
-.B core_collector <command> <options> -.RS -This allows you to specify the command to copy the vmcore. -The default is makedumpfile, which on some architectures can drastically reduce -core file size. See /sbin/makedumpfile --help for a list of options. -Note that the -i and -g options are not needed here, as the initrd -will automatically be populated with a config file appropriate -for the running kernel. -.PP -Note 1: About default core collector: -The default core_collector for raw/ssh dump is: -"makedumpfile -F -l --message-level 7 -d 31". -The default core_collector for other targets is: -"makedumpfile -l --message-level 7 -d 31". -Even if core_collector option is commented out in kdump.conf, makedumpfile -is the default core collector and kdump uses it internally. -If one does not want makedumpfile as default core_collector, then they -need to specify one using core_collector option to change the behavior. -.PP -Note 2: If "makedumpfile -F" is used then you will get a flattened format -vmcore.flat, you will need to use "makedumpfile -R" to rearrange the -dump data from standard input to a normal dumpfile (readable with analysis -tools). -ie. "makedumpfile -R vmcore < vmcore.flat" -.PP -Note 3: If specified core_collector simply copy the vmcore file to the -dump target (eg: cp, scp), the vmcore could be significantly large. -Please make sure the dump target has enough space, at leaset larger -than the system's RAM.
-.RE
-.B kdump_post <binary | script> -.RS -This directive allows you to run a specified executable -just after the vmcore dump process terminates. The exit -status of the current dump process is fed to the kdump_post -executable as its first argument($1). Executable can modify -it to indicate the new exit status of succeeding dump process, -.PP -All files under /etc/kdump/post.d are collectively sorted -and executed in lexical order, before binary or script -specified kdump_post parameter is executed. -.PP -Note that scripts written for use with this directive must use the /bin/bash -interpreter. And since these scripts run in kdump enviroment, the reference to -the storage or network device in the scripts should adhere to the section -'Supported dump target types and requirements' in kexec-kdump-howto.txt.
-.RE
-.B kdump_pre <binary | script> -.RS -Works just like the "kdump_post" directive, but instead -of running after the dump process, runs immediately -before. Exit status of this binary is interpreted -as follows: -.PP -0 - continue with dump process as usual -.PP -non 0 - run the final action (reboot/poweroff/halt) -.PP -All files under /etc/kdump/pre.d are collectively sorted and -executed in lexical order, after binary or script specified -kdump_pre parameter is executed. -Even if the binary or script in /etc/kdump/pre.d directory -returns non 0 exit status, the processing is continued. -.PP -Note that scripts written for use with this directive must use the /bin/bash -interpreter. And since these scripts run in kdump enviroment, the reference to -the storage or network device in the scripts should adhere to the section -'Supported dump target types and requirements' in kexec-kdump-howto.txt.
-.RE
-.B extra_bins <binaries | shell scripts> -.RS -This directive allows you to specify additional -binaries or shell scripts you'd like to include in -your kdump initrd. Generally only useful in -conjunction with a kdump_post binary or script that -relies on other binaries or scripts. -.RE
-.B extra_modules <module(s)> -.RS -This directive allows you to specify extra kernel -modules that you want to be loaded in the kdump -initrd, typically used to set up access to -non-boot-path dump targets that might otherwise -not be accessible in the kdump environment. Multiple -modules can be listed, separated by spaces, and any -dependent modules will automatically be included. -.RE
-.B failure_action <reboot | halt | poweroff | shell | dump_to_rootfs> -.RS -Action to perform in case dumping to the intended target fails. The default is "reboot". -reboot: Reboot the system (this is what most people will want, as it returns the system -to a normal state). halt: Halt the system and lose the vmcore. poweroff: The system -will be powered down. shell: Drop to a shell session inside the initramfs, from which -you can manually perform additional recovery actions. Exiting this shell reboots the -system by default or performs "final_action". -Note: kdump uses bash as the default shell. dump_to_rootfs: If non-root dump -target is specified, the failure action can be set as dump_to_rootfs. That means when -dumping to target fails, dump vmcore to rootfs from initramfs context and reboot -by default or perform "final_action". -.RE
-.B default <reboot | halt | poweroff | shell | dump_to_rootfs> -.RS -Same as the "failure_action" directive above, but this directive is obsolete -and will be removed in the future. -.RE
-.B final_action <reboot | halt | poweroff> -.RS -Action to perform in case dumping to the intended target succeeds. -Also performed when "shell" or "dump_to_rootfs" failure action finishes. -Each action is same as the "failure_action" directive above. -The default is "reboot". -.RE
-.B force_rebuild <0 | 1> -.RS -By default, kdump initrd will only be rebuilt when necessary. -Specify 1 to force rebuilding kdump initrd every time when kdump service starts. -.RE
-.B force_no_rebuild <0 | 1> -.RS -By default, kdump initrd will be rebuilt when necessary. -Specify 1 to bypass rebuilding of kdump initrd.
-.PP -force_no_rebuild and force_rebuild options are mutually exclusive and -they should not be set to 1 simultaneously. -.RE
-.B dracut_args <arg(s)> -.RS -Kdump uses dracut to generate initramfs for second kernel. This option -allows a user to pass arguments to dracut directly. -.RE
-.B fence_kdump_args <arg(s)> -.RS -Command line arguments for fence_kdump_send (it can contain all valid -arguments except hosts to send notification to). -.RE
-.B fence_kdump_nodes <node(s)> -.RS -List of cluster node(s) except localhost, separated by spaces, to send fence_kdump notification -to (this option is mandatory to enable fence_kdump). -.RE
-.SH DEPRECATED OPTIONS
-.B net <nfs mount>|user@server -.RS -net option is replaced by nfs and ssh options. Use nfs or ssh options -directly. -.RE
-.B options <module> <option list> -.RS -Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump to add module options as -kernel command line parameters. For example, specify 'loop.max_loop=1' to limit -maximum loop devices to 1. -.RE
-.B link_delay <seconds> -.RS -link_delay was used to wait for a network device to initialize before using it. -Now dracut network module takes care of this issue automatically. -.RE
-.B disk_timeout <seconds> -.RS -Similar to link_delay, dracut ensures disks are ready before kdump uses them. -.RE
-.B debug_mem_level <0-3> -.RS -Turn on verbose debug output of kdump scripts regarding free/used memory at -various points of execution. This feature has been -moved to dracut now. -Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump and -append dracut cmdline param rd.memdebug=[0-3] to enable the debug output.
-Higher level means more debugging output. -.PP -0 - no output -.PP -1 - partial /proc/meminfo -.PP -2 - /proc/meminfo -.PP -3 - /proc/meminfo + /proc/slabinfo -.RE
-.B blacklist <list of kernel modules> -.RS -blacklist option was recently being used to prevent loading modules in -initramfs. General terminology for blacklist has been that module is -present in initramfs but it is not actually loaded in kernel. Hence -retaining blacklist option creates more confusing behavior. It has been -deprecated. -.PP -Instead, use rd.driver.blacklist option on second kernel to blacklist -a certain module. One can edit /etc/sysconfig/kdump.conf and edit -KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer -to dracut.cmdline man page for more details on module blacklist option. -.RE
-.RE
-.SH EXAMPLES -Here are some examples for core_collector option: -.PP -Core collector command format depends on dump target type. Typically for -filesystem (local/remote), core_collector should accept two arguments. -First one is source file and second one is target file. For ex. -.TP -ex1. -core_collector "cp --sparse=always"
-Above will effectively be translated to:
-cp --sparse=always /proc/vmcore <dest-path>/vmcore -.TP -ex2. -core_collector "makedumpfile -l --message-level 7 -d 31"
-Above will effectively be translated to:
-makedumpfile -l --message-level 7 -d 31 /proc/vmcore <dest-path>/vmcore -.PP -For dump targets like raw and ssh, in general, core collector should expect -one argument (source file) and should output the processed core on standard -output (There is one exception of "scp", discussed later). This standard -output will be saved to destination using appropriate commands.
-raw dumps examples: -.TP -ex3. -core_collector "cat"
-Above will effectively be translated to.
-cat /proc/vmcore | dd of=<target-device> -.TP -ex4. -core_collector "makedumpfile -F -l --message-level 7 -d 31"
-Above will effectively be translated to.
-makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device> -.PP -ssh dumps examples -.TP -ex5. -core_collector "cat"
-Above will effectively be translated to.
-cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore" -.TP -ex6. -core_collector "makedumpfile -F -l --message-level 7 -d 31"
-Above will effectively be translated to.
-makedumpfile -F -l --message-level 7 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
-There is one exception to standard output rule for ssh dumps. And that is -scp. As scp can handle ssh destinations for file transfers, one can -specify "scp" as core collector for ssh targets (no output on stdout). -.TP -ex7. -core_collector "scp"
-Above will effectively be translated to.
-scp /proc/vmcore user@host:path/vmcore
-.PP -examples for other options please see -.I /etc/kdump.conf
-.SH SEE ALSO
-kexec(8) mkdumprd(8) dracut.cmdline(7) diff --git a/kdump.conf.5.rst b/kdump.conf.5.rst new file mode 100644 index 0000000..7dd06b0 --- /dev/null +++ b/kdump.conf.5.rst @@ -0,0 +1,334 @@ +========== +kdump.conf +==========
+------------------------------------ +configuration file for kdump kernel. +------------------------------------
+:Date: 2008-07-23 +:Manual section: 5 +:Version: kexec-tools
+DESCRIPTION +===========
+kdump.conf is a configuration file for the kdump kernel crash +collection service.
+kdump.conf provides post-kexec instructions to the kdump kernel. It is +stored in the initrd file managed by the kdump service. If you change +this file and do not want to reboot in order for the changes to take +effect, restart the kdump service to rebuild the initrd.
+For most configurations, you can simply review the examples provided +in the stock /etc/kdump.conf.
+.. note:: For filesystem dumps the dump target must be mounted before building
- kdump initramfs.
+kdump.conf only affects the behavior of the initramfs. Please read the +kdump operational flow section of kexec-kdump-howto.txt in the docs to better +understand how this configuration file affects the behavior of kdump.
+OPTIONS +=======
+auto_reset_crashkernel <yes|no>
- Determine whether to reset kernel crashkernel parameter to the default value
- or not when kexec-tools is updated or a new kernel is installed.
+raw <partition>
- Will dd /proc/vmcore into <partition>. Use persistent device names for
- partition devices, such as /dev/vg/<devname>.
+nfs <nfs mount>
- Will mount nfs to <mnt>, and copy /proc/vmcore to <mnt>/<path>/%HOST-%DATE/,
- supports DNS.
- .. note:: A fqdn should be used as the server name in the mount point.
+ssh user@server
- Will save /proc/vmcore through ssh pipe to user@server:<path>/%HOST-%DATE/,
- supports DNS.
- .. note:: Make sure user has necessary write permissions on server and that a
- fqdn is used as the server name.
+sshkey <path>
- Specify the path of the ssh key to use when dumping via ssh. The default
- value is /root/.ssh/kdump_id_rsa.
+<fs type> <partition>
- Will mount -t <fs type> <partition> <mnt>, and copy /proc/vmcore to
- <mnt>/<path>/%HOST_IP-%DATE/.
- .. note:: <partition> can be a device node, label or uuid. It's recommended
- to use persistent device names such as /dev/vg/<devname>. Otherwise it's
- suggested to use label or uuid.
+path <path>
- "path" represents the file system path in which vmcore will be saved. If a
- dump target is specified in kdump.conf, then "path" is relative to the
- specified dump target.
- Interpretation of "path" changes a bit if the user didn't specify any dump
- target explicitly in kdump.conf. In this case, "path" represents the absolute
- path from root. The dump target and adjusted path are arrived at
- automatically depending on what's mounted in the current system.
- Ignored for raw device dumps. If unset, will use the default "/var/crash".
+core_collector <command> <options>
- This allows you to specify the command to copy the vmcore. The default is
- makedumpfile, which on some architectures can drastically reduce core file
- size. See /sbin/makedumpfile --help for a list of options. Note that the -i
- and -g options are not needed here, as the initrd will automatically be
- populated with a config file appropriate for the running kernel.
- .. note:: The default core_collector for raw/ssh dump is: "makedumpfile -F -l
- --message-level 7 -d 31". The default core_collector for other targets is:
- "makedumpfile -l --message-level 7 -d 31". Even if core_collector option
- is commented out in kdump.conf, makedumpfile is the default core collector
- and kdump uses it internally. If one does not want makedumpfile as default
- core_collector, then they need to specify one using core_collector option
- to change the behavior.
- .. note:: If "makedumpfile -F" is used then you will get a flattened format
- vmcore.flat, you will need to use "makedumpfile -R" to rearrange the dump
- data from standard input to a normal dumpfile (readable with analysis
- tools). ie. "makedumpfile -R vmcore < vmcore.flat"
- .. note:: If specified core_collector simply copy the vmcore file to the dump
- target (eg: cp, scp), the vmcore could be significantly large. Please make
- sure the dump target has enough space, at leaset larger than the system's
- RAM.
+kdump_post <binary | script>
- This directive allows you to run a specified executable just after the vmcore
- dump process terminates. The exit status of the current dump process is fed
- to the kdump_post executable as its first argument($1). Executable can
- modify it to indicate the new exit status of succeeding dump process,
- All files under /etc/kdump/post.d are collectively sorted and executed in
- lexical order, before binary or script specified kdump_post parameter is
- executed.
- .. note:: All scripts written for use with this directive must use the
- /bin/bash interpreter. And since these scripts run in kdump enviroment, the
- reference to the storage or network device in the scripts should adhere to
- the section 'Supported dump target types and requirements' in
- kexec-kdump-howto.txt.
+kdump_pre <binary | script>
- Works just like the "kdump_post" directive, but instead of running after the
- dump process, runs immediately before. Exit status of this binary is
- interpreted as follows:
- 0 - continue with dump process as usual
- non 0 - run the final action (reboot/poweroff/halt)
- All files under /etc/kdump/pre.d are collectively sorted and executed in
- lexical order, after binary or script specified kdump_pre parameter is
- executed. Even if the binary or script in /etc/kdump/pre.d directory returns
- non 0 exit status, the processing is continued.
- .. note:: All scripts written for use with this directive must use the
- /bin/bash interpreter. And since these scripts run in kdump enviroment, the
- reference to the storage or network device in the scripts should adhere to
- the section 'Supported dump target types and requirements' in
- kexec-kdump-howto.txt.
+extra_bins <binaries | shell scripts>
- This directive allows you to specify additional binaries or shell scripts
- you'd like to include in your kdump initrd. Generally only useful in
- conjunction with a kdump_post binary or script that relies on other binaries
- or scripts.
+extra_modules <module(s)>
- This directive allows you to specify extra kernel modules that you want to be
- loaded in the kdump initrd, typically used to set up access to non-boot-path
- dump targets that might otherwise not be accessible in the kdump environment.
- Multiple modules can be listed, separated by spaces, and any dependent
- modules will automatically be included.
+failure_action <reboot | halt | poweroff | shell | dump_to_rootfs>
- Action to perform in case dumping to the intended target fails. The default
- is "reboot".
- reboot: Reboot the system (this is what most people will want, as it
returns the system to a normal state).
- halt: Halt the system and lose the vmcore.
- poweroff: The system will be powered down.
- shell: Drop to a shell session inside the initramfs, from which you can
manually perform additional recovery actions. Exiting this shell reboots
the system by default or performs "final_action".
.. note:: kdump uses bash as the default shell.
- dump_to_rootfs: If non-root dump target is specified, the failure action
can be set as dump_to_rootfs. That means when dumping to target fails,
dump vmcore to rootfs from initramfs context and reboot by default or
perform "final_action".
+default <reboot | halt | poweroff | shell | dump_to_rootfs>
- Same as the "failure_action" directive above, but this directive is obsolete
- and will be removed in the future.
+final_action <reboot | halt | poweroff>
- Action to perform in case dumping to the intended target succeeds. Also
- performed when "shell" or "dump_to_rootfs" failure action finishes. Each
- action is same as the "failure_action" directive above. The default is
- "reboot".
+force_rebuild <0 | 1>
- By default, kdump initrd will only be rebuilt when necessary. Specify 1 to
- force rebuilding kdump initrd every time when kdump service starts.
+force_no_rebuild <0 | 1>
- By default, kdump initrd will be rebuilt when necessary. Specify 1 to bypass
- rebuilding of kdump initrd.
- force_no_rebuild and force_rebuild options are mutually exclusive and they
- should not be set to 1 simultaneously.
+dracut_args <arg(s)>
- Kdump uses dracut to generate initramfs for second kernel. This option allows
- a user to pass arguments to dracut directly.
+fence_kdump_args <arg(s)>
- Command line arguments for fence_kdump_send (it can contain all valid
- arguments except hosts to send notification to).
+fence_kdump_nodes <node(s)>
- List of cluster node(s) except localhost, separated by spaces, to send
- fence_kdump notification to (this option is mandatory to enable fence_kdump).
+DEPRECATED OPTIONS +==================
+net <nfs mount>|user@server
- net option is replaced by nfs and ssh options. Use nfs or ssh options
- directly.
+options <module> <option list>
- Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump to add module options as
- kernel command line parameters. For example, specify 'loop.max_loop=1' to
- limit maximum loop devices to 1.
+link_delay <seconds>
- link_delay was used to wait for a network device to initialize before using
- it. Now dracut network module takes care of this issue automatically.
+disk_timeout <seconds>
- Similar to link_delay, dracut ensures disks are ready before kdump uses them.
+debug_mem_level <0-3>
- Turn on verbose debug output of kdump scripts regarding free/used memory at
- various points of execution. This feature has been moved to dracut now. Use
- KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump and append dracut cmdline
- param rd.memdebug=[0-3] to enable the debug output.
- Higher level means more debugging output.
- 0 - no output
- 1 - partial /proc/meminfo
- 2 - /proc/meminfo
- 3 - /proc/meminfo + /proc/slabinfo
+blacklist <list of kernel modules>
- blacklist option was recently being used to prevent loading modules in
- initramfs. General terminology for blacklist has been that module is present
- in initramfs but it is not actually loaded in kernel. Hence retaining
- blacklist option creates more confusing behavior. It has been deprecated.
- Instead, use rd.driver.blacklist option on second kernel to blacklist a
- certain module. One can edit /etc/sysconfig/kdump.conf and edit
- KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer to
- dracut.cmdline man page for more details on module blacklist option.
+EXAMPLES +========
+Here are some examples for core_collector option:
+Core collector command format depends on dump target type. Typically for +filesystem (local/remote), core_collector should accept two arguments. +First one is source file and second one is target file. For ex.
- Example 1
- core_collector "cp --sparse=always"
- Above will effectively be translated to:
- cp --sparse=always /proc/vmcore <dest-path>/vmcore
- Example 2
- core_collector "makedumpfile -l --message-level 7 -d 31"
- Above will effectively be translated to:
- makedumpfile -l --message-level 7 -d 31 /proc/vmcore <dest-path>/vmcore
+For dump targets like raw and ssh, in general, core collector should expect one +argument (source file) and should output the processed core on standard output +(There is one exception of "scp", discussed later). This standard output will +be saved to destination using appropriate commands.
+raw dumps examples:
- Example 3
- core_collector "cat"
- Above will effectively be translated to.
- cat /proc/vmcore | dd of=<target-device>
- Example 4
- core_collector "makedumpfile -F -l --message-level 7 -d 31"
- Above will effectively be translated to.
- makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device>
+ssh dumps examples
- Example 5
- core_collector "cat"
- Above will effectively be translated to.
- cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore"
- Example 6
- core_collector "makedumpfile -F -l --message-level 7 -d 31"
- Above will effectively be translated to.
- makedumpfile -F -l --message-level 7 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
- There is one exception to standard output rule for ssh dumps. And that is
- scp. As scp can handle ssh destinations for file transfers, one can specify
- "scp" as core collector for ssh targets (no output on stdout).
- Example 7
- core_collector "scp"
- Above will effectively be translated to.
- scp /proc/vmcore user@host:path/vmcore
+examples for other options please see */etc/kdump.conf*
+SEE ALSO +========
+**dracut.cmdline(7)**, **kexec(8)**, **makedumpfile(8)** diff --git a/kdumpctl.8 b/kdumpctl.8 deleted file mode 100644 index 33c1115..0000000 --- a/kdumpctl.8 +++ /dev/null @@ -1,72 +0,0 @@ -.TH KDUMPCTL 8 2015-07-13 kexec-tools
-.SH NAME -kdumpctl - control interface for kdump
-.SH SYNOPSIS -.B kdumpctl -.I COMMAND
-.SH DESCRIPTION -.B kdumpctl -is used to check or control the kdump service. -In most cases, you should use -.B systemctl -to start / stop / enable kdump service instead. However, -.B kdumpctl -provides more details for debugging and a helper to set up ssh key authentication.
-.SH COMMANDS -.TP -.I start -Start the service. -.TP -.I stop -Stop the service. -.TP -.I status -Prints the current status of kdump service. -It returns a non-zero value if kdump is not operational. -.TP -.I restart -Is equal to -.I start; stop -.TP -.I reload -reload the crash kernel image and initramfs without triggering a rebuild. -.TP -.I rebuild -rebuild the crash kernel initramfs. -.TP -.I propagate -Helps to setup key authentication for ssh storage since it's -impossible to use password authentication during kdump. -.TP -.I showmem -Prints the size of reserved memory for the crash kernel in megabytes. -.TP -.I estimate -Estimate a suitable crashkernel value for the current machine. This is a -best-effort estimate. It will print a recommended crashkernel value -based on the current kdump setup, and list some details of memory usage. -.TP -.I get-default-crashkernel -Return the default crashkernel value provided by kexec-tools. -.TP -.I reset-crashkernel [--kernel=path_to_kernel] [--reboot] -Reset crashkernel to default value recommended by kexec-tools. If no kernel -is specified, will reset KDUMP_KERNELVER if it's defined in /etc/sysconfig/kdump -or the current running kernel's crashkernel value if KDUMP_KERNELVER is empty. You can -also specify --kernel=ALL and --kernel=DEFAULT which have the same meaning as -grubby's kernel-path=ALL and kernel-path=DEFAULT. ppc64le supports FADump and -supports an additional [--fadump=[on|off|nocma]] parameter to toggle FADump -on/off.
-Note: The memory requirements for kdump varies heavily depending on the -used hardware and system configuration. Thus the recommended -crashkernel might not work for your specific setup. Please test if -kdump works after resetting the crashkernel value.
-.SH "SEE ALSO" -.BR kdump.conf (5), -.BR mkdumprd (8) diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst new file mode 100644 index 0000000..3488af4 --- /dev/null +++ b/kdumpctl.8.rst @@ -0,0 +1,80 @@ +======== +kdumpctl +========
+--------------------------- +control interface for kdump +---------------------------
+:Date: 2015-07-13 +:Manual section: 8 +:Version: kexec-tools
+SYNOPSIS +========
+**kdumpctl** *COMMAND*
+DESCRIPTION +===========
+**kdumpctl** is used to check or control the kdump service. In most cases, you +should use **systemctl** to start / stop / enable kdump service instead. +However, **kdumpctl** provides more details for debugging and a helper to set +up ssh key authentication.
+COMMANDS +========
+start
- Start the service.
+stop
- Stop the service.
+status
- Prints the current status of kdump service. It returns a non-zero value if
- kdump is not operational.
+restart
- Is equal to **start; stop**
+reload
- Reload the crash kernel image and initramfs without triggering a rebuild.
+rebuild
- Rebuild the crash kernel initramfs.
+propagate
- Helps to setup key authentication for ssh storage since it's impossible to
- use password authentication during kdump.
+showmem
- Prints the size of reserved memory for the crash kernel in megabytes.
+estimate
- Estimate a suitable crashkernel value for the current machine. This is a
- best-effort estimate. It will print a recommended crashkernel value based on
- the current kdump setup, and list some details of memory usage.
+get-default-crashkernel
- Return the default crashkernel value provided by kexec-tools.
+reset-crashkernel [--kernel=path_to_kernel] [--reboot]
- Reset crashkernel to default value recommended by kexec-tools. If no kernel
- is specified, will reset **KDUMP_KERNELVER** if it is defined in
- */etc/sysconfig/kdump* or the current running kernels crashkernel value if
- KDUMP_KERNELVER is empty. You can also specify **--kernel=ALL** and
- **--kernel=DEFAULT** which have the same meaning as grubbys kernel-path=ALL
- and kernel-path=DEFAULT. ppc64le supports FADump and supports an additional
- [**--fadump=[on|off|nocma]**] parameter to toggle FADump on/off.
- .. note:: The memory requirements for kdump varies heavily depending on the
used hardware and system configuration. Thus the recommended
crashkernel might not work for your specific setup. Please test if
kdump works after resetting the crashkernel value.
+SEE ALSO +========
+**kdump.conf (5)**, **mkdumprd (8)** diff --git a/kexec-tools.spec b/kexec-tools.spec index ca3179e..6b2eac4 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -17,17 +17,17 @@ Source7: mkdumprd Source9: https://github.com/makedumpfile/makedumpfile/archive/%%7Bmkdf_ver%7D/makedum... Source10: kexec-kdump-howto.txt Source11: fadump-howto.txt -Source12: mkdumprd.8 +Source12: mkdumprd.8.rst Source13: 98-kexec.rules Source14: 98-kexec.rules.ppc64 -Source15: kdump.conf.5 +Source15: kdump.conf.5.rst Source16: kdump.service Source19: https://github.com/lucchouina/eppic/archive/%%7Beppic_ver%7D/eppic-%%7Beppic... Source20: kdump-lib.sh Source21: kdump-in-cluster-environment.txt Source22: kdump-dep-generator.sh Source23: kdump-lib-initramfs.sh -Source25: kdumpctl.8 +Source25: kdumpctl.8.rst Source26: live-image-kdump-howto.txt Source27: early-kdump-howto.txt Source28: kdump-udev-throttler @@ -75,6 +75,7 @@ BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel b BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-rpm-macros BuildRequires: automake autoconf libtool +BuildRequires: python3-docutils
%ifnarch s390x Requires: systemd-udev%{?_isa} @@ -187,8 +188,8 @@ install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd install -m 644 kdump.conf $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf install -m 644 kdump.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 -install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 -install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 +rst2man %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 +rst2man %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh install -m 755 %{SOURCE31} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-logger.sh @@ -209,7 +210,7 @@ install -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules install -m 755 -D %{SOURCE37} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-fadump.install %endif -install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 +rst2man %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh install -m 755 -D %{SOURCE30} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-kdump.install diff --git a/mkdumprd.8 b/mkdumprd.8 deleted file mode 100644 index 2ac3d5a..0000000 --- a/mkdumprd.8 +++ /dev/null @@ -1,39 +0,0 @@ -.TH MKDUMRD 8 "Fri Feb 9 2007" -.SH NAME -mkdumprd - creates initial ramdisk images for kdump crash recovery -.SH SYNOPSIS -\fBmkdumprd\fR [OPTION]
-.SH DESCRIPTION -\fBmkdumprd\fR creates an initial ram file system for use in conjunction with -the booting of a kernel within the kdump framework for crash recovery. -\fBmkdumprds\fR purpose is to create an initial ram filesystem capable of copying -the crashed systems vmcore image to a location specified in \fI/etc/kdump.conf
-\fBmkdumprd\fR interrogates the running system to understand what modules need to -be loaded in the initramfs (based on configuration retrieved from -\fI/etc/kdump.conf)\fR
-\fBmkdumprd\fR add a new \fBdracut\fR module 99kdumpbase and use \fBdracut\fR -utility to generate the initramfs. When generating a kdump initramfs, \fBmkdumprd\fR -will determine how much disk space is available, if the dump target's available -space is not greater than the total system memory, \fBmkdumprd\fR will print a -warning to remind that there might not be enough space to save a vmcore. The -warning covers extreme scenarios such as the slab explodes with non-zero data or -a full vmcore, etc. Therefore, need to prevent users from having minimum disk -space for crash dump.
-\fBmkdumprd\fR was not intended for casual use outside of the service -initialization script for the kdump utility, and should not be run manually. If -you require a custom kdump initramfs image, it is suggested that you use the -kdump service infrastructure to create one, and then manually unpack, modify and -repack the image.
-.SH OPTIONS -.TP -All options here are passed to dracut directly, please refer \fBdracut\fR docs -for the info.
-.SH "SEE ALSO" -.BR dracut (8) diff --git a/mkdumprd.8.rst b/mkdumprd.8.rst new file mode 100644 index 0000000..1b2c2d2 --- /dev/null +++ b/mkdumprd.8.rst @@ -0,0 +1,54 @@ +======== +mkdumprd +========
+------------------------------------------------------- +creates initial ramdisk images for kdump crash recovery +-------------------------------------------------------
+:Date: 2007-02-09 +:Manual Section: 8
+SYNOPSIS +========
+**mkdumprd** [OPTION]
+DESCRIPTION +===========
+**mkdumprd** creates an initial ram file system for use in conjunction with +the booting of a kernel within the kdump framework for crash recovery. +**mkdumprds** purpose is to create an initial ram filesystem capable of copying +the crashed systems vmcore image to a location specified in */etc/kdump.conf*
+**mkdumprd** interrogates the running system to understand what modules need to +be loaded in the initramfs (based on configuration retrieved from +*/etc/kdump.conf*)
+**mkdumprd** add a new **dracut** module 99kdumpbase and use **dracut** +utility to generate the initramfs. When generating a kdump initramfs, **mkdumprd** +will determine how much disk space is available, if the dump target's available +space is not greater than the total system memory, **mkdumprd** will print a +warning to remind that there might not be enough space to save a vmcore. The +warning covers extreme scenarios such as the slab explodes with non-zero data or +a full vmcore, etc. Therefore, need to prevent users from having minimum disk +space for crash dump.
+**mkdumprd** was not intended for casual use outside of the service +initialization script for the kdump utility, and should not be run manually. If +you require a custom kdump initramfs image, it is suggested that you use the +kdump service infrastructure to create one, and then manually unpack, modify and +repack the image.
+OPTIONS +=======
+All options here are passed to dracut directly, please refer **dracut** docs +for the info.
+SEE ALSO +========
+**dracut (8)**
2.40.0
Hi Pingfan,
On Mon, 31 Jul 2023 21:15:19 +0800 Pingfan Liu piliu@redhat.com wrote:
On Fri, Jul 21, 2023 at 10:26 PM Philipp Rudo prudo@redhat.com wrote:
The groff formatting language used by man pages is pretty hard to read. Thus convert the man pages to reStructuredText (RST) [1] markup language which is much easier to read and for which there are many different converters for example rst2man, rst2http, rst2latex and more.
I saw the use of rst2man in this patch. But in the converse direction, how was the patch formed. I had a try with 'pandoc' on kdump.conf.5, but got several difference from the one in this patch.
Could you pay some words on it, so I can verify it.
I've converted them manually (I forgot about pandoc...). While converting I verified that the old and new version is the same by simply looking at the output side by side.
Thanks Philipp
Thanks,
Pingfan
The patch doesn't change the content of the man pages. Only exception are some minor changes in formatting.
Note: There was a bug in docutils [2] that adds an empty 'manual-section' to the .TH line even when no :manual group: field is provided. This causes mandoc to not print the default section name. This bug is supposed to be fixed with docutils 0.20.
[1] https://docutils.sourceforge.io/rst.html [2] https://sourceforge.net/p/docutils/bugs/458/
Signed-off-by: Philipp Rudo prudo@redhat.com
kdump.conf.5 | 378 ----------------------------------------------- kdump.conf.5.rst | 334 +++++++++++++++++++++++++++++++++++++++++ kdumpctl.8 | 72 --------- kdumpctl.8.rst | 80 ++++++++++ kexec-tools.spec | 13 +- mkdumprd.8 | 39 ----- mkdumprd.8.rst | 54 +++++++ 7 files changed, 475 insertions(+), 495 deletions(-) delete mode 100644 kdump.conf.5 create mode 100644 kdump.conf.5.rst delete mode 100644 kdumpctl.8 create mode 100644 kdumpctl.8.rst delete mode 100644 mkdumprd.8 create mode 100644 mkdumprd.8.rst
diff --git a/kdump.conf.5 b/kdump.conf.5 deleted file mode 100644 index 9117aa7..0000000 --- a/kdump.conf.5 +++ /dev/null @@ -1,378 +0,0 @@ -.TH KDUMP.CONF 5 "07/23/2008" "kexec-tools"
-.SH NAME -kdump.conf - configuration file for kdump kernel.
-.SH DESCRIPTION
-kdump.conf is a configuration file for the kdump kernel crash -collection service.
-kdump.conf provides post-kexec instructions to the kdump kernel. It is -stored in the initrd file managed by the kdump service. If you change -this file and do not want to reboot in order for the changes to take -effect, restart the kdump service to rebuild the initrd.
-For most configurations, you can simply review the examples provided -in the stock /etc/kdump.conf.
-.B NOTE: -For filesystem dumps the dump target must be mounted before building -kdump initramfs.
-kdump.conf only affects the behavior of the initramfs. Please read the -kdump operational flow section of kexec-kdump-howto.txt in the docs to better -understand how this configuration file affects the behavior of kdump.
-.SH OPTIONS
-.B auto_reset_crashkernel <yes|no> -.RS -determine whether to reset kernel crashkernel parameter to the default value -or not when kexec-tools is updated or a new kernel is installed.
-.B raw <partition> -.RS -Will dd /proc/vmcore into <partition>. Use persistent device names for -partition devices, such as /dev/vg/<devname>. -.RE
-.B nfs <nfs mount> -.RS -Will mount nfs to <mnt>, and copy /proc/vmcore to <mnt>/<path>/%HOST-%DATE/, -supports DNS. Note that a fqdn should be used as the server name in the -mount point. -.RE
-.B ssh user@server -.RS -Will save /proc/vmcore through ssh pipe to user@server:<path>/%HOST-%DATE/, -supports DNS. NOTE: make sure user has necessary write permissions on -server and that a fqdn is used as the server name. -.RE
-.B sshkey <path> -.RS -Specify the path of the ssh key to use when dumping via ssh. -The default value is /root/.ssh/kdump_id_rsa. -.RE
-.B <fs type> <partition> -.RS -Will mount -t <fs type> <partition> <mnt>, and copy /proc/vmcore to -<mnt>/<path>/%HOST_IP-%DATE/. NOTE: <partition> can be a device node, label -or uuid. It's recommended to use persistent device names such as -/dev/vg/<devname>. Otherwise it's suggested to use label or uuid. -.RE
-.B path <path> -.RS -"path" represents the file system path in which vmcore will be saved. -If a dump target is specified in kdump.conf, then "path" is relative to the -specified dump target. -.PP -Interpretation of "path" changes a bit if the user didn't specify any dump -target explicitly in kdump.conf. In this case, "path" represents the -absolute path from root. The dump target and adjusted path are arrived -at automatically depending on what's mounted in the current system. -.PP -Ignored for raw device dumps. If unset, will use the default "/var/crash". -.RE
-.B core_collector <command> <options> -.RS -This allows you to specify the command to copy the vmcore. -The default is makedumpfile, which on some architectures can drastically reduce -core file size. See /sbin/makedumpfile --help for a list of options. -Note that the -i and -g options are not needed here, as the initrd -will automatically be populated with a config file appropriate -for the running kernel. -.PP -Note 1: About default core collector: -The default core_collector for raw/ssh dump is: -"makedumpfile -F -l --message-level 7 -d 31". -The default core_collector for other targets is: -"makedumpfile -l --message-level 7 -d 31". -Even if core_collector option is commented out in kdump.conf, makedumpfile -is the default core collector and kdump uses it internally. -If one does not want makedumpfile as default core_collector, then they -need to specify one using core_collector option to change the behavior. -.PP -Note 2: If "makedumpfile -F" is used then you will get a flattened format -vmcore.flat, you will need to use "makedumpfile -R" to rearrange the -dump data from standard input to a normal dumpfile (readable with analysis -tools). -ie. "makedumpfile -R vmcore < vmcore.flat" -.PP -Note 3: If specified core_collector simply copy the vmcore file to the -dump target (eg: cp, scp), the vmcore could be significantly large. -Please make sure the dump target has enough space, at leaset larger -than the system's RAM.
-.RE
-.B kdump_post <binary | script> -.RS -This directive allows you to run a specified executable -just after the vmcore dump process terminates. The exit -status of the current dump process is fed to the kdump_post -executable as its first argument($1). Executable can modify -it to indicate the new exit status of succeeding dump process, -.PP -All files under /etc/kdump/post.d are collectively sorted -and executed in lexical order, before binary or script -specified kdump_post parameter is executed. -.PP -Note that scripts written for use with this directive must use the /bin/bash -interpreter. And since these scripts run in kdump enviroment, the reference to -the storage or network device in the scripts should adhere to the section -'Supported dump target types and requirements' in kexec-kdump-howto.txt.
-.RE
-.B kdump_pre <binary | script> -.RS -Works just like the "kdump_post" directive, but instead -of running after the dump process, runs immediately -before. Exit status of this binary is interpreted -as follows: -.PP -0 - continue with dump process as usual -.PP -non 0 - run the final action (reboot/poweroff/halt) -.PP -All files under /etc/kdump/pre.d are collectively sorted and -executed in lexical order, after binary or script specified -kdump_pre parameter is executed. -Even if the binary or script in /etc/kdump/pre.d directory -returns non 0 exit status, the processing is continued. -.PP -Note that scripts written for use with this directive must use the /bin/bash -interpreter. And since these scripts run in kdump enviroment, the reference to -the storage or network device in the scripts should adhere to the section -'Supported dump target types and requirements' in kexec-kdump-howto.txt.
-.RE
-.B extra_bins <binaries | shell scripts> -.RS -This directive allows you to specify additional -binaries or shell scripts you'd like to include in -your kdump initrd. Generally only useful in -conjunction with a kdump_post binary or script that -relies on other binaries or scripts. -.RE
-.B extra_modules <module(s)> -.RS -This directive allows you to specify extra kernel -modules that you want to be loaded in the kdump -initrd, typically used to set up access to -non-boot-path dump targets that might otherwise -not be accessible in the kdump environment. Multiple -modules can be listed, separated by spaces, and any -dependent modules will automatically be included. -.RE
-.B failure_action <reboot | halt | poweroff | shell | dump_to_rootfs> -.RS -Action to perform in case dumping to the intended target fails. The default is "reboot". -reboot: Reboot the system (this is what most people will want, as it returns the system -to a normal state). halt: Halt the system and lose the vmcore. poweroff: The system -will be powered down. shell: Drop to a shell session inside the initramfs, from which -you can manually perform additional recovery actions. Exiting this shell reboots the -system by default or performs "final_action". -Note: kdump uses bash as the default shell. dump_to_rootfs: If non-root dump -target is specified, the failure action can be set as dump_to_rootfs. That means when -dumping to target fails, dump vmcore to rootfs from initramfs context and reboot -by default or perform "final_action". -.RE
-.B default <reboot | halt | poweroff | shell | dump_to_rootfs> -.RS -Same as the "failure_action" directive above, but this directive is obsolete -and will be removed in the future. -.RE
-.B final_action <reboot | halt | poweroff> -.RS -Action to perform in case dumping to the intended target succeeds. -Also performed when "shell" or "dump_to_rootfs" failure action finishes. -Each action is same as the "failure_action" directive above. -The default is "reboot". -.RE
-.B force_rebuild <0 | 1> -.RS -By default, kdump initrd will only be rebuilt when necessary. -Specify 1 to force rebuilding kdump initrd every time when kdump service starts. -.RE
-.B force_no_rebuild <0 | 1> -.RS -By default, kdump initrd will be rebuilt when necessary. -Specify 1 to bypass rebuilding of kdump initrd.
-.PP -force_no_rebuild and force_rebuild options are mutually exclusive and -they should not be set to 1 simultaneously. -.RE
-.B dracut_args <arg(s)> -.RS -Kdump uses dracut to generate initramfs for second kernel. This option -allows a user to pass arguments to dracut directly. -.RE
-.B fence_kdump_args <arg(s)> -.RS -Command line arguments for fence_kdump_send (it can contain all valid -arguments except hosts to send notification to). -.RE
-.B fence_kdump_nodes <node(s)> -.RS -List of cluster node(s) except localhost, separated by spaces, to send fence_kdump notification -to (this option is mandatory to enable fence_kdump). -.RE
-.SH DEPRECATED OPTIONS
-.B net <nfs mount>|user@server -.RS -net option is replaced by nfs and ssh options. Use nfs or ssh options -directly. -.RE
-.B options <module> <option list> -.RS -Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump to add module options as -kernel command line parameters. For example, specify 'loop.max_loop=1' to limit -maximum loop devices to 1. -.RE
-.B link_delay <seconds> -.RS -link_delay was used to wait for a network device to initialize before using it. -Now dracut network module takes care of this issue automatically. -.RE
-.B disk_timeout <seconds> -.RS -Similar to link_delay, dracut ensures disks are ready before kdump uses them. -.RE
-.B debug_mem_level <0-3> -.RS -Turn on verbose debug output of kdump scripts regarding free/used memory at -various points of execution. This feature has been -moved to dracut now. -Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump and -append dracut cmdline param rd.memdebug=[0-3] to enable the debug output.
-Higher level means more debugging output. -.PP -0 - no output -.PP -1 - partial /proc/meminfo -.PP -2 - /proc/meminfo -.PP -3 - /proc/meminfo + /proc/slabinfo -.RE
-.B blacklist <list of kernel modules> -.RS -blacklist option was recently being used to prevent loading modules in -initramfs. General terminology for blacklist has been that module is -present in initramfs but it is not actually loaded in kernel. Hence -retaining blacklist option creates more confusing behavior. It has been -deprecated. -.PP -Instead, use rd.driver.blacklist option on second kernel to blacklist -a certain module. One can edit /etc/sysconfig/kdump.conf and edit -KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer -to dracut.cmdline man page for more details on module blacklist option. -.RE
-.RE
-.SH EXAMPLES -Here are some examples for core_collector option: -.PP -Core collector command format depends on dump target type. Typically for -filesystem (local/remote), core_collector should accept two arguments. -First one is source file and second one is target file. For ex. -.TP -ex1. -core_collector "cp --sparse=always"
-Above will effectively be translated to:
-cp --sparse=always /proc/vmcore <dest-path>/vmcore -.TP -ex2. -core_collector "makedumpfile -l --message-level 7 -d 31"
-Above will effectively be translated to:
-makedumpfile -l --message-level 7 -d 31 /proc/vmcore <dest-path>/vmcore -.PP -For dump targets like raw and ssh, in general, core collector should expect -one argument (source file) and should output the processed core on standard -output (There is one exception of "scp", discussed later). This standard -output will be saved to destination using appropriate commands.
-raw dumps examples: -.TP -ex3. -core_collector "cat"
-Above will effectively be translated to.
-cat /proc/vmcore | dd of=<target-device> -.TP -ex4. -core_collector "makedumpfile -F -l --message-level 7 -d 31"
-Above will effectively be translated to.
-makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device> -.PP -ssh dumps examples -.TP -ex5. -core_collector "cat"
-Above will effectively be translated to.
-cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore" -.TP -ex6. -core_collector "makedumpfile -F -l --message-level 7 -d 31"
-Above will effectively be translated to.
-makedumpfile -F -l --message-level 7 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
-There is one exception to standard output rule for ssh dumps. And that is -scp. As scp can handle ssh destinations for file transfers, one can -specify "scp" as core collector for ssh targets (no output on stdout). -.TP -ex7. -core_collector "scp"
-Above will effectively be translated to.
-scp /proc/vmcore user@host:path/vmcore
-.PP -examples for other options please see -.I /etc/kdump.conf
-.SH SEE ALSO
-kexec(8) mkdumprd(8) dracut.cmdline(7) diff --git a/kdump.conf.5.rst b/kdump.conf.5.rst new file mode 100644 index 0000000..7dd06b0 --- /dev/null +++ b/kdump.conf.5.rst @@ -0,0 +1,334 @@ +========== +kdump.conf +==========
+------------------------------------ +configuration file for kdump kernel. +------------------------------------
+:Date: 2008-07-23 +:Manual section: 5 +:Version: kexec-tools
+DESCRIPTION +===========
+kdump.conf is a configuration file for the kdump kernel crash +collection service.
+kdump.conf provides post-kexec instructions to the kdump kernel. It is +stored in the initrd file managed by the kdump service. If you change +this file and do not want to reboot in order for the changes to take +effect, restart the kdump service to rebuild the initrd.
+For most configurations, you can simply review the examples provided +in the stock /etc/kdump.conf.
+.. note:: For filesystem dumps the dump target must be mounted before building
- kdump initramfs.
+kdump.conf only affects the behavior of the initramfs. Please read the +kdump operational flow section of kexec-kdump-howto.txt in the docs to better +understand how this configuration file affects the behavior of kdump.
+OPTIONS +=======
+auto_reset_crashkernel <yes|no>
- Determine whether to reset kernel crashkernel parameter to the default value
- or not when kexec-tools is updated or a new kernel is installed.
+raw <partition>
- Will dd /proc/vmcore into <partition>. Use persistent device names for
- partition devices, such as /dev/vg/<devname>.
+nfs <nfs mount>
- Will mount nfs to <mnt>, and copy /proc/vmcore to <mnt>/<path>/%HOST-%DATE/,
- supports DNS.
- .. note:: A fqdn should be used as the server name in the mount point.
+ssh user@server
- Will save /proc/vmcore through ssh pipe to user@server:<path>/%HOST-%DATE/,
- supports DNS.
- .. note:: Make sure user has necessary write permissions on server and that a
- fqdn is used as the server name.
+sshkey <path>
- Specify the path of the ssh key to use when dumping via ssh. The default
- value is /root/.ssh/kdump_id_rsa.
+<fs type> <partition>
- Will mount -t <fs type> <partition> <mnt>, and copy /proc/vmcore to
- <mnt>/<path>/%HOST_IP-%DATE/.
- .. note:: <partition> can be a device node, label or uuid. It's recommended
- to use persistent device names such as /dev/vg/<devname>. Otherwise it's
- suggested to use label or uuid.
+path <path>
- "path" represents the file system path in which vmcore will be saved. If a
- dump target is specified in kdump.conf, then "path" is relative to the
- specified dump target.
- Interpretation of "path" changes a bit if the user didn't specify any dump
- target explicitly in kdump.conf. In this case, "path" represents the absolute
- path from root. The dump target and adjusted path are arrived at
- automatically depending on what's mounted in the current system.
- Ignored for raw device dumps. If unset, will use the default "/var/crash".
+core_collector <command> <options>
- This allows you to specify the command to copy the vmcore. The default is
- makedumpfile, which on some architectures can drastically reduce core file
- size. See /sbin/makedumpfile --help for a list of options. Note that the -i
- and -g options are not needed here, as the initrd will automatically be
- populated with a config file appropriate for the running kernel.
- .. note:: The default core_collector for raw/ssh dump is: "makedumpfile -F -l
- --message-level 7 -d 31". The default core_collector for other targets is:
- "makedumpfile -l --message-level 7 -d 31". Even if core_collector option
- is commented out in kdump.conf, makedumpfile is the default core collector
- and kdump uses it internally. If one does not want makedumpfile as default
- core_collector, then they need to specify one using core_collector option
- to change the behavior.
- .. note:: If "makedumpfile -F" is used then you will get a flattened format
- vmcore.flat, you will need to use "makedumpfile -R" to rearrange the dump
- data from standard input to a normal dumpfile (readable with analysis
- tools). ie. "makedumpfile -R vmcore < vmcore.flat"
- .. note:: If specified core_collector simply copy the vmcore file to the dump
- target (eg: cp, scp), the vmcore could be significantly large. Please make
- sure the dump target has enough space, at leaset larger than the system's
- RAM.
+kdump_post <binary | script>
- This directive allows you to run a specified executable just after the vmcore
- dump process terminates. The exit status of the current dump process is fed
- to the kdump_post executable as its first argument($1). Executable can
- modify it to indicate the new exit status of succeeding dump process,
- All files under /etc/kdump/post.d are collectively sorted and executed in
- lexical order, before binary or script specified kdump_post parameter is
- executed.
- .. note:: All scripts written for use with this directive must use the
- /bin/bash interpreter. And since these scripts run in kdump enviroment, the
- reference to the storage or network device in the scripts should adhere to
- the section 'Supported dump target types and requirements' in
- kexec-kdump-howto.txt.
+kdump_pre <binary | script>
- Works just like the "kdump_post" directive, but instead of running after the
- dump process, runs immediately before. Exit status of this binary is
- interpreted as follows:
- 0 - continue with dump process as usual
- non 0 - run the final action (reboot/poweroff/halt)
- All files under /etc/kdump/pre.d are collectively sorted and executed in
- lexical order, after binary or script specified kdump_pre parameter is
- executed. Even if the binary or script in /etc/kdump/pre.d directory returns
- non 0 exit status, the processing is continued.
- .. note:: All scripts written for use with this directive must use the
- /bin/bash interpreter. And since these scripts run in kdump enviroment, the
- reference to the storage or network device in the scripts should adhere to
- the section 'Supported dump target types and requirements' in
- kexec-kdump-howto.txt.
+extra_bins <binaries | shell scripts>
- This directive allows you to specify additional binaries or shell scripts
- you'd like to include in your kdump initrd. Generally only useful in
- conjunction with a kdump_post binary or script that relies on other binaries
- or scripts.
+extra_modules <module(s)>
- This directive allows you to specify extra kernel modules that you want to be
- loaded in the kdump initrd, typically used to set up access to non-boot-path
- dump targets that might otherwise not be accessible in the kdump environment.
- Multiple modules can be listed, separated by spaces, and any dependent
- modules will automatically be included.
+failure_action <reboot | halt | poweroff | shell | dump_to_rootfs>
- Action to perform in case dumping to the intended target fails. The default
- is "reboot".
- reboot: Reboot the system (this is what most people will want, as it
returns the system to a normal state).
- halt: Halt the system and lose the vmcore.
- poweroff: The system will be powered down.
- shell: Drop to a shell session inside the initramfs, from which you can
manually perform additional recovery actions. Exiting this shell reboots
the system by default or performs "final_action".
.. note:: kdump uses bash as the default shell.
- dump_to_rootfs: If non-root dump target is specified, the failure action
can be set as dump_to_rootfs. That means when dumping to target fails,
dump vmcore to rootfs from initramfs context and reboot by default or
perform "final_action".
+default <reboot | halt | poweroff | shell | dump_to_rootfs>
- Same as the "failure_action" directive above, but this directive is obsolete
- and will be removed in the future.
+final_action <reboot | halt | poweroff>
- Action to perform in case dumping to the intended target succeeds. Also
- performed when "shell" or "dump_to_rootfs" failure action finishes. Each
- action is same as the "failure_action" directive above. The default is
- "reboot".
+force_rebuild <0 | 1>
- By default, kdump initrd will only be rebuilt when necessary. Specify 1 to
- force rebuilding kdump initrd every time when kdump service starts.
+force_no_rebuild <0 | 1>
- By default, kdump initrd will be rebuilt when necessary. Specify 1 to bypass
- rebuilding of kdump initrd.
- force_no_rebuild and force_rebuild options are mutually exclusive and they
- should not be set to 1 simultaneously.
+dracut_args <arg(s)>
- Kdump uses dracut to generate initramfs for second kernel. This option allows
- a user to pass arguments to dracut directly.
+fence_kdump_args <arg(s)>
- Command line arguments for fence_kdump_send (it can contain all valid
- arguments except hosts to send notification to).
+fence_kdump_nodes <node(s)>
- List of cluster node(s) except localhost, separated by spaces, to send
- fence_kdump notification to (this option is mandatory to enable fence_kdump).
+DEPRECATED OPTIONS +==================
+net <nfs mount>|user@server
- net option is replaced by nfs and ssh options. Use nfs or ssh options
- directly.
+options <module> <option list>
- Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump to add module options as
- kernel command line parameters. For example, specify 'loop.max_loop=1' to
- limit maximum loop devices to 1.
+link_delay <seconds>
- link_delay was used to wait for a network device to initialize before using
- it. Now dracut network module takes care of this issue automatically.
+disk_timeout <seconds>
- Similar to link_delay, dracut ensures disks are ready before kdump uses them.
+debug_mem_level <0-3>
- Turn on verbose debug output of kdump scripts regarding free/used memory at
- various points of execution. This feature has been moved to dracut now. Use
- KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump and append dracut cmdline
- param rd.memdebug=[0-3] to enable the debug output.
- Higher level means more debugging output.
- 0 - no output
- 1 - partial /proc/meminfo
- 2 - /proc/meminfo
- 3 - /proc/meminfo + /proc/slabinfo
+blacklist <list of kernel modules>
- blacklist option was recently being used to prevent loading modules in
- initramfs. General terminology for blacklist has been that module is present
- in initramfs but it is not actually loaded in kernel. Hence retaining
- blacklist option creates more confusing behavior. It has been deprecated.
- Instead, use rd.driver.blacklist option on second kernel to blacklist a
- certain module. One can edit /etc/sysconfig/kdump.conf and edit
- KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer to
- dracut.cmdline man page for more details on module blacklist option.
+EXAMPLES +========
+Here are some examples for core_collector option:
+Core collector command format depends on dump target type. Typically for +filesystem (local/remote), core_collector should accept two arguments. +First one is source file and second one is target file. For ex.
- Example 1
- core_collector "cp --sparse=always"
- Above will effectively be translated to:
- cp --sparse=always /proc/vmcore <dest-path>/vmcore
- Example 2
- core_collector "makedumpfile -l --message-level 7 -d 31"
- Above will effectively be translated to:
- makedumpfile -l --message-level 7 -d 31 /proc/vmcore <dest-path>/vmcore
+For dump targets like raw and ssh, in general, core collector should expect one +argument (source file) and should output the processed core on standard output +(There is one exception of "scp", discussed later). This standard output will +be saved to destination using appropriate commands.
+raw dumps examples:
- Example 3
- core_collector "cat"
- Above will effectively be translated to.
- cat /proc/vmcore | dd of=<target-device>
- Example 4
- core_collector "makedumpfile -F -l --message-level 7 -d 31"
- Above will effectively be translated to.
- makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device>
+ssh dumps examples
- Example 5
- core_collector "cat"
- Above will effectively be translated to.
- cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore"
- Example 6
- core_collector "makedumpfile -F -l --message-level 7 -d 31"
- Above will effectively be translated to.
- makedumpfile -F -l --message-level 7 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
- There is one exception to standard output rule for ssh dumps. And that is
- scp. As scp can handle ssh destinations for file transfers, one can specify
- "scp" as core collector for ssh targets (no output on stdout).
- Example 7
- core_collector "scp"
- Above will effectively be translated to.
- scp /proc/vmcore user@host:path/vmcore
+examples for other options please see */etc/kdump.conf*
+SEE ALSO +========
+**dracut.cmdline(7)**, **kexec(8)**, **makedumpfile(8)** diff --git a/kdumpctl.8 b/kdumpctl.8 deleted file mode 100644 index 33c1115..0000000 --- a/kdumpctl.8 +++ /dev/null @@ -1,72 +0,0 @@ -.TH KDUMPCTL 8 2015-07-13 kexec-tools
-.SH NAME -kdumpctl - control interface for kdump
-.SH SYNOPSIS -.B kdumpctl -.I COMMAND
-.SH DESCRIPTION -.B kdumpctl -is used to check or control the kdump service. -In most cases, you should use -.B systemctl -to start / stop / enable kdump service instead. However, -.B kdumpctl -provides more details for debugging and a helper to set up ssh key authentication.
-.SH COMMANDS -.TP -.I start -Start the service. -.TP -.I stop -Stop the service. -.TP -.I status -Prints the current status of kdump service. -It returns a non-zero value if kdump is not operational. -.TP -.I restart -Is equal to -.I start; stop -.TP -.I reload -reload the crash kernel image and initramfs without triggering a rebuild. -.TP -.I rebuild -rebuild the crash kernel initramfs. -.TP -.I propagate -Helps to setup key authentication for ssh storage since it's -impossible to use password authentication during kdump. -.TP -.I showmem -Prints the size of reserved memory for the crash kernel in megabytes. -.TP -.I estimate -Estimate a suitable crashkernel value for the current machine. This is a -best-effort estimate. It will print a recommended crashkernel value -based on the current kdump setup, and list some details of memory usage. -.TP -.I get-default-crashkernel -Return the default crashkernel value provided by kexec-tools. -.TP -.I reset-crashkernel [--kernel=path_to_kernel] [--reboot] -Reset crashkernel to default value recommended by kexec-tools. If no kernel -is specified, will reset KDUMP_KERNELVER if it's defined in /etc/sysconfig/kdump -or the current running kernel's crashkernel value if KDUMP_KERNELVER is empty. You can -also specify --kernel=ALL and --kernel=DEFAULT which have the same meaning as -grubby's kernel-path=ALL and kernel-path=DEFAULT. ppc64le supports FADump and -supports an additional [--fadump=[on|off|nocma]] parameter to toggle FADump -on/off.
-Note: The memory requirements for kdump varies heavily depending on the -used hardware and system configuration. Thus the recommended -crashkernel might not work for your specific setup. Please test if -kdump works after resetting the crashkernel value.
-.SH "SEE ALSO" -.BR kdump.conf (5), -.BR mkdumprd (8) diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst new file mode 100644 index 0000000..3488af4 --- /dev/null +++ b/kdumpctl.8.rst @@ -0,0 +1,80 @@ +======== +kdumpctl +========
+--------------------------- +control interface for kdump +---------------------------
+:Date: 2015-07-13 +:Manual section: 8 +:Version: kexec-tools
+SYNOPSIS +========
+**kdumpctl** *COMMAND*
+DESCRIPTION +===========
+**kdumpctl** is used to check or control the kdump service. In most cases, you +should use **systemctl** to start / stop / enable kdump service instead. +However, **kdumpctl** provides more details for debugging and a helper to set +up ssh key authentication.
+COMMANDS +========
+start
- Start the service.
+stop
- Stop the service.
+status
- Prints the current status of kdump service. It returns a non-zero value if
- kdump is not operational.
+restart
- Is equal to **start; stop**
+reload
- Reload the crash kernel image and initramfs without triggering a rebuild.
+rebuild
- Rebuild the crash kernel initramfs.
+propagate
- Helps to setup key authentication for ssh storage since it's impossible to
- use password authentication during kdump.
+showmem
- Prints the size of reserved memory for the crash kernel in megabytes.
+estimate
- Estimate a suitable crashkernel value for the current machine. This is a
- best-effort estimate. It will print a recommended crashkernel value based on
- the current kdump setup, and list some details of memory usage.
+get-default-crashkernel
- Return the default crashkernel value provided by kexec-tools.
+reset-crashkernel [--kernel=path_to_kernel] [--reboot]
- Reset crashkernel to default value recommended by kexec-tools. If no kernel
- is specified, will reset **KDUMP_KERNELVER** if it is defined in
- */etc/sysconfig/kdump* or the current running kernels crashkernel value if
- KDUMP_KERNELVER is empty. You can also specify **--kernel=ALL** and
- **--kernel=DEFAULT** which have the same meaning as grubbys kernel-path=ALL
- and kernel-path=DEFAULT. ppc64le supports FADump and supports an additional
- [**--fadump=[on|off|nocma]**] parameter to toggle FADump on/off.
- .. note:: The memory requirements for kdump varies heavily depending on the
used hardware and system configuration. Thus the recommended
crashkernel might not work for your specific setup. Please test if
kdump works after resetting the crashkernel value.
+SEE ALSO +========
+**kdump.conf (5)**, **mkdumprd (8)** diff --git a/kexec-tools.spec b/kexec-tools.spec index ca3179e..6b2eac4 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -17,17 +17,17 @@ Source7: mkdumprd Source9: https://github.com/makedumpfile/makedumpfile/archive/%%7Bmkdf_ver%7D/makedum... Source10: kexec-kdump-howto.txt Source11: fadump-howto.txt -Source12: mkdumprd.8 +Source12: mkdumprd.8.rst Source13: 98-kexec.rules Source14: 98-kexec.rules.ppc64 -Source15: kdump.conf.5 +Source15: kdump.conf.5.rst Source16: kdump.service Source19: https://github.com/lucchouina/eppic/archive/%%7Beppic_ver%7D/eppic-%%7Beppic... Source20: kdump-lib.sh Source21: kdump-in-cluster-environment.txt Source22: kdump-dep-generator.sh Source23: kdump-lib-initramfs.sh -Source25: kdumpctl.8 +Source25: kdumpctl.8.rst Source26: live-image-kdump-howto.txt Source27: early-kdump-howto.txt Source28: kdump-udev-throttler @@ -75,6 +75,7 @@ BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel b BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-rpm-macros BuildRequires: automake autoconf libtool +BuildRequires: python3-docutils
%ifnarch s390x Requires: systemd-udev%{?_isa} @@ -187,8 +188,8 @@ install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd install -m 644 kdump.conf $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf install -m 644 kdump.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 -install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 -install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 +rst2man %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 +rst2man %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh install -m 755 %{SOURCE31} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-logger.sh @@ -209,7 +210,7 @@ install -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules install -m 755 -D %{SOURCE37} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-fadump.install %endif -install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 +rst2man %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh install -m 755 -D %{SOURCE30} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-kdump.install diff --git a/mkdumprd.8 b/mkdumprd.8 deleted file mode 100644 index 2ac3d5a..0000000 --- a/mkdumprd.8 +++ /dev/null @@ -1,39 +0,0 @@ -.TH MKDUMRD 8 "Fri Feb 9 2007" -.SH NAME -mkdumprd - creates initial ramdisk images for kdump crash recovery -.SH SYNOPSIS -\fBmkdumprd\fR [OPTION]
-.SH DESCRIPTION -\fBmkdumprd\fR creates an initial ram file system for use in conjunction with -the booting of a kernel within the kdump framework for crash recovery. -\fBmkdumprds\fR purpose is to create an initial ram filesystem capable of copying -the crashed systems vmcore image to a location specified in \fI/etc/kdump.conf
-\fBmkdumprd\fR interrogates the running system to understand what modules need to -be loaded in the initramfs (based on configuration retrieved from -\fI/etc/kdump.conf)\fR
-\fBmkdumprd\fR add a new \fBdracut\fR module 99kdumpbase and use \fBdracut\fR -utility to generate the initramfs. When generating a kdump initramfs, \fBmkdumprd\fR -will determine how much disk space is available, if the dump target's available -space is not greater than the total system memory, \fBmkdumprd\fR will print a -warning to remind that there might not be enough space to save a vmcore. The -warning covers extreme scenarios such as the slab explodes with non-zero data or -a full vmcore, etc. Therefore, need to prevent users from having minimum disk -space for crash dump.
-\fBmkdumprd\fR was not intended for casual use outside of the service -initialization script for the kdump utility, and should not be run manually. If -you require a custom kdump initramfs image, it is suggested that you use the -kdump service infrastructure to create one, and then manually unpack, modify and -repack the image.
-.SH OPTIONS -.TP -All options here are passed to dracut directly, please refer \fBdracut\fR docs -for the info.
-.SH "SEE ALSO" -.BR dracut (8) diff --git a/mkdumprd.8.rst b/mkdumprd.8.rst new file mode 100644 index 0000000..1b2c2d2 --- /dev/null +++ b/mkdumprd.8.rst @@ -0,0 +1,54 @@ +======== +mkdumprd +========
+------------------------------------------------------- +creates initial ramdisk images for kdump crash recovery +-------------------------------------------------------
+:Date: 2007-02-09 +:Manual Section: 8
+SYNOPSIS +========
+**mkdumprd** [OPTION]
+DESCRIPTION +===========
+**mkdumprd** creates an initial ram file system for use in conjunction with +the booting of a kernel within the kdump framework for crash recovery. +**mkdumprds** purpose is to create an initial ram filesystem capable of copying +the crashed systems vmcore image to a location specified in */etc/kdump.conf*
+**mkdumprd** interrogates the running system to understand what modules need to +be loaded in the initramfs (based on configuration retrieved from +*/etc/kdump.conf*)
+**mkdumprd** add a new **dracut** module 99kdumpbase and use **dracut** +utility to generate the initramfs. When generating a kdump initramfs, **mkdumprd** +will determine how much disk space is available, if the dump target's available +space is not greater than the total system memory, **mkdumprd** will print a +warning to remind that there might not be enough space to save a vmcore. The +warning covers extreme scenarios such as the slab explodes with non-zero data or +a full vmcore, etc. Therefore, need to prevent users from having minimum disk +space for crash dump.
+**mkdumprd** was not intended for casual use outside of the service +initialization script for the kdump utility, and should not be run manually. If +you require a custom kdump initramfs image, it is suggested that you use the +kdump service infrastructure to create one, and then manually unpack, modify and +repack the image.
+OPTIONS +=======
+All options here are passed to dracut directly, please refer **dracut** docs +for the info.
+SEE ALSO +========
+**dracut (8)**
2.40.0
There are many small inconsistencies, typos and out dated information in the man page. Fix them all at once.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdump.conf.5.rst | 487 +++++++++++++++++++++++------------------------ 1 file changed, 239 insertions(+), 248 deletions(-)
diff --git a/kdump.conf.5.rst b/kdump.conf.5.rst index 7dd06b0..1e73dc2 100644 --- a/kdump.conf.5.rst +++ b/kdump.conf.5.rst @@ -6,327 +6,318 @@ kdump.conf configuration file for kdump kernel. ------------------------------------
-:Date: 2008-07-23 +:Date: 2023-07-21 :Manual section: 5 :Version: kexec-tools
+ DESCRIPTION ===========
-kdump.conf is a configuration file for the kdump kernel crash -collection service. +**kdump.conf** is a configuration file for the kdump kernel crash collection +service. + +Each option is described on a separate line. Lines starting with '#' are +comments. Blank lines are ignored.
-kdump.conf provides post-kexec instructions to the kdump kernel. It is -stored in the initrd file managed by the kdump service. If you change -this file and do not want to reboot in order for the changes to take -effect, restart the kdump service to rebuild the initrd. +**kdump.conf** provides post-kexec instructions to the kdump kernel and is +stored in its initramfs. Changes made to **kdump.conf** require a restart of +the kdump service to take effect.
-For most configurations, you can simply review the examples provided -in the stock /etc/kdump.conf. +You can find additional examples in */etc/kdump.conf* provided with this +package.
.. note:: For filesystem dumps the dump target must be mounted before building - kdump initramfs. + kdump initramfs. + +Please see */usr/share/doc/kexec-tools/kexec-kdump-howto.txt* for an in depth +description how kdump works and how this configuration file affects the +behavior of kdump.
-kdump.conf only affects the behavior of the initramfs. Please read the -kdump operational flow section of kexec-kdump-howto.txt in the docs to better -understand how this configuration file affects the behavior of kdump.
OPTIONS =======
-auto_reset_crashkernel <yes|no> - Determine whether to reset kernel crashkernel parameter to the default value +auto_reset_crashkernel [yes|no] + Determines whether to reset kernel crashkernel parameter to the default value or not when kexec-tools is updated or a new kernel is installed.
-raw <partition> - Will dd /proc/vmcore into <partition>. Use persistent device names for - partition devices, such as /dev/vg/<devname>. +raw *partition* + Defines the dump target to be a raw dump to *partition*. This will + effectively **dd** */proc/vmcore* into *partition*. Use persistent device + names for partition devices, such as */dev/vg/xyz*.
-nfs <nfs mount> - Will mount nfs to <mnt>, and copy /proc/vmcore to <mnt>/<path>/%HOST-%DATE/, - supports DNS. +nfs *nfs_mount* + Defines the dump target to be a nfs mount. This will mount *nfs_mount*, + and copy */proc/vmcore* to */mnt/<path>/%HOST-%DATE/*, supports DNS.
- .. note:: A fqdn should be used as the server name in the mount point. + .. note:: A fqdn should be used as the hostname in the mount point.
-ssh user@server - Will save /proc/vmcore through ssh pipe to user@server:<path>/%HOST-%DATE/, +ssh *user@host* + Defines the dump target to be a remote ssh host. This will save + */proc/vmcore* to *user@host:<path>/%HOST-%DATE/* using a **ssh** pipe, supports DNS.
- .. note:: Make sure user has necessary write permissions on server and that a - fqdn is used as the server name. - -sshkey <path> - Specify the path of the ssh key to use when dumping via ssh. The default - value is /root/.ssh/kdump_id_rsa. - -<fs type> <partition> - Will mount -t <fs type> <partition> <mnt>, and copy /proc/vmcore to - <mnt>/<path>/%HOST_IP-%DATE/. - - .. note:: <partition> can be a device node, label or uuid. It's recommended - to use persistent device names such as /dev/vg/<devname>. Otherwise it's - suggested to use label or uuid. - -path <path> - "path" represents the file system path in which vmcore will be saved. If a - dump target is specified in kdump.conf, then "path" is relative to the - specified dump target. - - Interpretation of "path" changes a bit if the user didn't specify any dump - target explicitly in kdump.conf. In this case, "path" represents the absolute - path from root. The dump target and adjusted path are arrived at - automatically depending on what's mounted in the current system. - - Ignored for raw device dumps. If unset, will use the default "/var/crash". - -core_collector <command> <options> - This allows you to specify the command to copy the vmcore. The default is - makedumpfile, which on some architectures can drastically reduce core file - size. See /sbin/makedumpfile --help for a list of options. Note that the -i - and -g options are not needed here, as the initrd will automatically be - populated with a config file appropriate for the running kernel. - - .. note:: The default core_collector for raw/ssh dump is: "makedumpfile -F -l - --message-level 7 -d 31". The default core_collector for other targets is: - "makedumpfile -l --message-level 7 -d 31". Even if core_collector option - is commented out in kdump.conf, makedumpfile is the default core collector - and kdump uses it internally. If one does not want makedumpfile as default - core_collector, then they need to specify one using core_collector option - to change the behavior. - - .. note:: If "makedumpfile -F" is used then you will get a flattened format - vmcore.flat, you will need to use "makedumpfile -R" to rearrange the dump - data from standard input to a normal dumpfile (readable with analysis - tools). ie. "makedumpfile -R vmcore < vmcore.flat" - - .. note:: If specified core_collector simply copy the vmcore file to the dump - target (eg: cp, scp), the vmcore could be significantly large. Please make - sure the dump target has enough space, at leaset larger than the system's - RAM. - -kdump_post <binary | script> - This directive allows you to run a specified executable just after the vmcore - dump process terminates. The exit status of the current dump process is fed - to the kdump_post executable as its first argument($1). Executable can - modify it to indicate the new exit status of succeeding dump process, - - All files under /etc/kdump/post.d are collectively sorted and executed in - lexical order, before binary or script specified kdump_post parameter is - executed. - - .. note:: All scripts written for use with this directive must use the - /bin/bash interpreter. And since these scripts run in kdump enviroment, the - reference to the storage or network device in the scripts should adhere to - the section 'Supported dump target types and requirements' in - kexec-kdump-howto.txt. - -kdump_pre <binary | script> - Works just like the "kdump_post" directive, but instead of running after the - dump process, runs immediately before. Exit status of this binary is - interpreted as follows: - - 0 - continue with dump process as usual - - non 0 - run the final action (reboot/poweroff/halt) - - All files under /etc/kdump/pre.d are collectively sorted and executed in - lexical order, after binary or script specified kdump_pre parameter is - executed. Even if the binary or script in /etc/kdump/pre.d directory returns - non 0 exit status, the processing is continued. - - .. note:: All scripts written for use with this directive must use the - /bin/bash interpreter. And since these scripts run in kdump enviroment, the - reference to the storage or network device in the scripts should adhere to - the section 'Supported dump target types and requirements' in - kexec-kdump-howto.txt. - -extra_bins <binaries | shell scripts> - This directive allows you to specify additional binaries or shell scripts - you'd like to include in your kdump initrd. Generally only useful in - conjunction with a kdump_post binary or script that relies on other binaries - or scripts. - -extra_modules <module(s)> - This directive allows you to specify extra kernel modules that you want to be - loaded in the kdump initrd, typically used to set up access to non-boot-path - dump targets that might otherwise not be accessible in the kdump environment. - Multiple modules can be listed, separated by spaces, and any dependent - modules will automatically be included. - -failure_action <reboot | halt | poweroff | shell | dump_to_rootfs> - Action to perform in case dumping to the intended target fails. The default - is "reboot". - - * reboot: Reboot the system (this is what most people will want, as it - returns the system to a normal state). - * halt: Halt the system and lose the vmcore. - * poweroff: The system will be powered down. - * shell: Drop to a shell session inside the initramfs, from which you can - manually perform additional recovery actions. Exiting this shell reboots - the system by default or performs "final_action". - - .. note:: kdump uses bash as the default shell. - - * dump_to_rootfs: If non-root dump target is specified, the failure action - can be set as dump_to_rootfs. That means when dumping to target fails, - dump vmcore to rootfs from initramfs context and reboot by default or - perform "final_action". - -default <reboot | halt | poweroff | shell | dump_to_rootfs> - Same as the "failure_action" directive above, but this directive is obsolete - and will be removed in the future. - -final_action <reboot | halt | poweroff> - Action to perform in case dumping to the intended target succeeds. Also - performed when "shell" or "dump_to_rootfs" failure action finishes. Each - action is same as the "failure_action" directive above. The default is - "reboot". - -force_rebuild <0 | 1> - By default, kdump initrd will only be rebuilt when necessary. Specify 1 to - force rebuilding kdump initrd every time when kdump service starts. - -force_no_rebuild <0 | 1> - By default, kdump initrd will be rebuilt when necessary. Specify 1 to bypass - rebuilding of kdump initrd. - - force_no_rebuild and force_rebuild options are mutually exclusive and they - should not be set to 1 simultaneously. - -dracut_args <arg(s)> - Kdump uses dracut to generate initramfs for second kernel. This option allows - a user to pass arguments to dracut directly. - - -fence_kdump_args <arg(s)> - Command line arguments for fence_kdump_send (it can contain all valid - arguments except hosts to send notification to). - - -fence_kdump_nodes <node(s)> - List of cluster node(s) except localhost, separated by spaces, to send - fence_kdump notification to (this option is mandatory to enable fence_kdump). + .. note:: Make sure the user has all necessary write permissions on the host + and that a fqdn is used as hostname. + +sshkey *path* + Specifies the pathname of the ssh key to use when dumping via ssh. The + default value is */root/.ssh/kdump_id_rsa*. + +*fs_type* *partition* + Defines the dump target to be a local partition. This will ``mount -t + `` *fs_type* *partition* ``/mnt``, and copy */proc/vmcore* to + */mnt/<path>/%HOST_IP-%DATE/*. + + Valid *fs_type* are: ext[234], minix, btrfs, xfs and, virtiofs. + + .. note:: *partition* can be a device node, label or uuid. It is + recommended to use a persistent device specifier like a label or + uuid. + +path *path* + Specifies the pathname to save the vmcore to. *path* has two slightly + different interpretations: + + 1. If an explicit dump target is specified, then *path* is relative to + the specified dump target. + + 2. If *no* explicit dump target is specified, then *path* is the absolute + path on the current root filesystem. In that case the dump target and + relative path are determined by whatever is mounted on the current + system. + + This option is ignored for raw device dumps. Default is */var/crash*. + +core_collector *command* + Specifies the command to be used to copy the vmcore. See the EXAMPLES_ + below on how different **core_collectors** are used. Default is + ``makedumpfile -l --message-level 7 -d 31``. Using **makedumpfile** helps + reducing the vmcore size drastically. See the **makedumpfile (8)** for more + details. + + .. note:: For raw and ssh dump targets the **-F** option is added to the + default value. This turns on the flatten dump format and the + resulting dumpfile is called *vmcore.flat*. You can convert the + *vmcore.flat* back to a normal dumpfile (readable by analysis + tools) with ``makedumpfile -R vmcore < vmcore.flat``. + + .. note:: If a **core_collector** other than **makedumpfile** is used the + vmcore will be significantly larger. Especially if you choose a + **core_collector** that simply copies */proc/vmcore*, like **cp** + or **scp**, the resulting dump will have a size close to the + systems RAM available. Please make sure the dump target has enough + free space. + +kdump_post *path* + Specifies a script or executable that is executed right after the dump + process finished. The exit status of the current dump process is passed + to the executable as its first argument. + + If there are additional executables under */etc/kdump/post.d* they are + executed in lexical order before the executable specified in **kdump_post** + is executed. + + .. note:: The scripts/executables provided with **kdump_post** are run in the + initramfs which comes with some limitations. For example only a + limited number of programs and libraries are available. In + particular it cannot be guaranteed that the Bash interpreter is + included. Thus it is recommended only to use statically linked + executables and POSIX compatiple shell scripts with **kdump_post**. + +kdump_pre *path* + Same like **kdump_post**, but runs before the dump process instead of after. + If the executable exits with a return code other than 0 the dump process will + be aborted and the **final_action** run instead. + + If there are additional executables under */etc/kdump/pre.d* they are + executed in lexical order after the executable specified in **kdump_pre** + is executed. + + .. note:: The scripts/executables provided with **kdump_pre** are run in the + initramfs which comes with some limitations. For example only a + limited number of programs and libraries are available. In + particular it cannot be guaranteed that the Bash interpreter is + included. Thus it is recommended only to use statically linked + executables and POSIX compatiple shell scripts with **kdump_pre**. + +extra_bins *path ...* + Specifies additional scripts and executables to be included in the kdump + initramfs. This option is useful to provide dependencies needed by + scripts/executables given with **kdump_post** or **kdump_pre**. Multiple + executables - separated by a space - can be provided. + +extra_modules *module ...* + Specifies additional kernel modules to be included in the kdump initramfs. + This option is useful if scripts/executables given with **kdump_post** or + **kdump_pre** need to access devices other than the dump target. Multiple + modules - separated by a space - can be provided. Module dependencies will be + included automatically. + +failure_action [reboot|halt|poweroff|shell|dump_to_rootfs] + Specifies the action performed in case dumping to the target fails. Valid + arguments are: + + reboot + Reboot the system (default, the vmcore is lost). + + halt + Halt the system (the vmcore is lost). + + poweroff + Power down the system (the vmcore is lost). + + shell + Drop to a shell session inside the initramfs. From there you can try to + manually recover the system. Exiting this shell performs the + **final_action** and reboots the system. + + dump_to_rootfs + Retry to dump to the rootfs and perform **final_action**. Only valid if a + dump target other than the rootfs is defined. + +final_action [reboot|halt|poweroff] + Specifies the action performed after dumping to the target succeeds or the + **shell** or **dump_to_rootfs** **failure_action** finished. The options have + the same meaning as for **failure_action** described above. Default is + **reboot**. + +force_rebuild [0|1] + By default, the kdump initramfs is only rebuilt when necessary. Specify 1 to + force rebuilding kdump initramfs every time when kdump service starts. + + This option cannot be used together with **force_no_rebuild**. + +force_no_rebuild [0|1] + By default, the kdump initramfs will be rebuilt when necessary. Specify 1 to + skip rebuilding the kdump initramfs. + + This option cannot be used together with **force_rebuild**. + +dracut_args *arguments* + Specifies additional arguments passed to **dracut** when creating the kdump + initramfs. + +fence_kdump_args *arguments* + Command line arguments for **fence_kdump_send** (it can contain all valid + arguments except hostnames to send notification to). + + +fence_kdump_nodes *node ...* + List of cluster nodes - separated by space - to send **fence_kdump** + notification to. This option is mandatory to enable **fence_kdump**. The list + must not contain the **localhost**.
DEPRECATED OPTIONS ==================
-net <nfs mount>|user@server - net option is replaced by nfs and ssh options. Use nfs or ssh options - directly. - -options <module> <option list> - Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump to add module options as - kernel command line parameters. For example, specify 'loop.max_loop=1' to - limit maximum loop devices to 1. - -link_delay <seconds> - link_delay was used to wait for a network device to initialize before using - it. Now dracut network module takes care of this issue automatically. +default [reboot|halt|poweroff|shell|dump_to_rootfs] + Replaced by **failure_action** option.
-disk_timeout <seconds> - Similar to link_delay, dracut ensures disks are ready before kdump uses them. +net [*nfs_mount*|*user@host*] + Replaced by **nfs** and **ssh** options.
-debug_mem_level <0-3> - Turn on verbose debug output of kdump scripts regarding free/used memory at - various points of execution. This feature has been moved to dracut now. Use - KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump and append dracut cmdline - param rd.memdebug=[0-3] to enable the debug output. +options *module option(s)* + Add the module options to **KDUMP_COMMANDLINE_APPEND** in + */etc/sysconfig/kdump* instead.
- Higher level means more debugging output. +link_delay *seconds* + Dropped since **dracut** ensures that network devices are initialized before + using them.
- 0 - no output +disk_timeout *seconds* + Dropped since **dracut** ensures that disks are initialized before using + them.
- 1 - partial /proc/meminfo +debug_mem_level [0-5] + Feature moved to **dracut**. Add **rd.memdebug=[0-5]** to + **KDUMP_COMMANDLINE_APPEND** in */etc/sysconfig/kdump* in order to use it. + See the **dracut.cmdline (7)** for details.
- 2 - /proc/meminfo +blacklist *module ...* + Feature moved to **dracut**. Add **rd.driver.blacklist** to + **KDUMP_COMMANDLINE_APPEND** in */etc/sysconfig/kdump.conf* in order to use + it. See the **dracut.cmdline (7)** for details.
- 3 - /proc/meminfo + /proc/slabinfo - -blacklist <list of kernel modules> - blacklist option was recently being used to prevent loading modules in - initramfs. General terminology for blacklist has been that module is present - in initramfs but it is not actually loaded in kernel. Hence retaining - blacklist option creates more confusing behavior. It has been deprecated. - - Instead, use rd.driver.blacklist option on second kernel to blacklist a - certain module. One can edit /etc/sysconfig/kdump.conf and edit - KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer to - dracut.cmdline man page for more details on module blacklist option.
EXAMPLES ========
-Here are some examples for core_collector option: +The *command* provided to the **core_collector** option is used differently +depending on the dump target used. It must behave like shown in the examples +below.
-Core collector command format depends on dump target type. Typically for -filesystem (local/remote), core_collector should accept two arguments. -First one is source file and second one is target file. For ex. +In most cases *command* is passed two arguments. The first one is the source +file, i.e. where to read from, and the second one is the destination file, i.e. +where to write to. For example
Example 1 - core_collector "cp --sparse=always" + ``core_collector "cp --sparse=always"``
- Above will effectively be translated to: + Will translate to:
- cp --sparse=always /proc/vmcore <dest-path>/vmcore + ``cp --sparse=always /proc/vmcore <path>/vmcore``
Example 2 - core_collector "makedumpfile -l --message-level 7 -d 31" + ``core_collector "makedumpfile -l --message-level 7 -d 31"``
- Above will effectively be translated to: + Will translate to:
- makedumpfile -l --message-level 7 -d 31 /proc/vmcore <dest-path>/vmcore + ``makedumpfile -l --message-level 7 -d 31 /proc/vmcore <path>/vmcore``
-For dump targets like raw and ssh, in general, core collector should expect one -argument (source file) and should output the processed core on standard output -(There is one exception of "scp", discussed later). This standard output will -be saved to destination using appropriate commands. +Exception to the rule above are the **raw** and **ssh** dump targets. In these +two cases *command* is only passed one argument, the source file. Furthermore, +it is expected that the *command* writes the processed vmcore to standard +output which then gets piped to the appropriate command. In particular:
-raw dumps examples: +For **raw** dump targets:
Example 3 - core_collector "cat" + ``core_collector "cat"``
- Above will effectively be translated to. + Will translate to:
- cat /proc/vmcore | dd of=<target-device> + ``cat /proc/vmcore | dd of=<raw>``
Example 4 - core_collector "makedumpfile -F -l --message-level 7 -d 31" + ``core_collector "makedumpfile -F -l --message-level 7 -d 31"``
- Above will effectively be translated to. + Will translate to:
- makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device> + ``makedumpfile -F -l --message-level 7 -d 31 | dd of=<raw>``
-ssh dumps examples +For **ssh** dump targets:
Example 5 - core_collector "cat" + ``core_collector "cat"``
- Above will effectively be translated to. + Will translate to:
- cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore" + ``cat /proc/vmcore | ssh <ssh> "dd of=<path>/vmcore"``
Example 6 - core_collector "makedumpfile -F -l --message-level 7 -d 31" + ``core_collector "makedumpfile -F -l --message-level 7 -d 31"``
- Above will effectively be translated to. + Will translate to:
- makedumpfile -F -l --message-level 7 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore" + ``makedumpfile -F -l --message-level 7 -d 31 | ssh <ssh> "dd of=<path>/vmcore"``
- There is one exception to standard output rule for ssh dumps. And that is - scp. As scp can handle ssh destinations for file transfers, one can specify - "scp" as core collector for ssh targets (no output on stdout). +There is one exception to the exception described above. If the dump target is +**ssh** and the **<command>** is **scp**, then the **<command>** +is used similar to the filesystem case. In particular:
Example 7 - core_collector "scp" + ``core_collector "scp"`` + + Will translate to:
- Above will effectively be translated to. + ``scp /proc/vmcore <ssh>:<path>/vmcore``
- scp /proc/vmcore user@host:path/vmcore
+Please see */etc/kdump.conf* for additional examples.
-examples for other options please see */etc/kdump.conf*
SEE ALSO ========
There are many small inconsistencies, typos and out dated information in the man page. Fix them all at once.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl.8.rst | 78 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 31 deletions(-)
diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst index 3488af4..c6eeeb8 100644 --- a/kdumpctl.8.rst +++ b/kdumpctl.8.rst @@ -2,79 +2,95 @@ kdumpctl ========
---------------------------- -control interface for kdump ---------------------------- +----------------------------------------------------- +Control interface for the kdump kernel dump mechanism +-----------------------------------------------------
-:Date: 2015-07-13 +:Date: 2023-07-21 :Manual section: 8 :Version: kexec-tools
+ SYNOPSIS ========
**kdumpctl** *COMMAND*
+ DESCRIPTION ===========
-**kdumpctl** is used to check or control the kdump service. In most cases, you -should use **systemctl** to start / stop / enable kdump service instead. -However, **kdumpctl** provides more details for debugging and a helper to set -up ssh key authentication. +**kdumpctl** may be used to enable and configure the kdump dump mechanism. +**kdumpctl** is also used as the backend for the **systemd** kdump.service. + +.. note:: If you have the **systemd** kdump.service enabled, which should be + true for most installations, it is recommended to use **systemctl** + over **kdumpctl** to start/stop kdump. Otherwise situations might + occure where ``systemctl status`` and the system log no longer show + the true state of the service. + +Please see */usr/share/doc/kexec-tools/kexec-kdump-howto.txt* for an in depth +description how kdump works. +
COMMANDS ========
start - Start the service. + Start the service. Rebuilds the kdump initramfs if necessary.
stop Stop the service.
-status - Prints the current status of kdump service. It returns a non-zero value if - kdump is not operational. - restart - Is equal to **start; stop** - -reload - Reload the crash kernel image and initramfs without triggering a rebuild. + Restart the service. Equal to ``kdumpctl stop; kdumpctl start``
rebuild - Rebuild the crash kernel initramfs. + Rebuild the kdump initramfs.
-propagate - Helps to setup key authentication for ssh storage since it's impossible to - use password authentication during kdump. +reload + Reload the kdump kernel and initramfs without triggering a rebuild. + +status + Prints the current status of kdump. Returns zero if kdump is operational, + nonzero otherwise.
showmem - Prints the size of reserved memory for the crash kernel in megabytes. + Prints the size of reserved crash kernel memory in Megabytes. + +propagate + Helper to setup key authentication for ssh dump targets.
estimate - Estimate a suitable crashkernel value for the current machine. This is a - best-effort estimate. It will print a recommended crashkernel value based on - the current kdump setup, and list some details of memory usage. + Estimate the required size of the crash kernel memory for the current + configuration and system. + + .. note:: The memory requirements for kdump varies heavily depending on the + used hardware and system configuration and cannot be predicted + acurately. Thus the estimated crash kernel memory size might not + work for your specific setup. Always test if kdump works after + changing the crashkernel parameter on the kernel command line.
get-default-crashkernel Return the default crashkernel value provided by kexec-tools.
-reset-crashkernel [--kernel=path_to_kernel] [--reboot] +reset-crashkernel [--kernel=*kernel_path*] [--reboot] Reset crashkernel to default value recommended by kexec-tools. If no kernel is specified, will reset **KDUMP_KERNELVER** if it is defined in */etc/sysconfig/kdump* or the current running kernels crashkernel value if KDUMP_KERNELVER is empty. You can also specify **--kernel=ALL** and **--kernel=DEFAULT** which have the same meaning as grubbys kernel-path=ALL and kernel-path=DEFAULT. ppc64le supports FADump and supports an additional - [**--fadump=[on|off|nocma]**] parameter to toggle FADump on/off. + [**--fadump=on|off|nocma**] parameter to toggle FADump on/off.
.. note:: The memory requirements for kdump varies heavily depending on the - used hardware and system configuration. Thus the recommended - crashkernel might not work for your specific setup. Please test if - kdump works after resetting the crashkernel value. + used hardware and system configuration and cannot be predicted + acurately. Thus the recommanded crash kernel memory size might not + work for your specific setup. Always test if kdump works after + changing the crashkernel parameter on the kernel command line. +
SEE ALSO ========
-**kdump.conf (5)**, **mkdumprd (8)** +**systemctl (1)**, **kdump.conf (5)**, **mkdumprd (8)**
This allows to restructure the subcommand handling later on which is a prereq to introduce the new CLI parsing.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 102 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 43 deletions(-)
diff --git a/kdumpctl b/kdumpctl index ce58cc9..6da5500 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1031,7 +1031,7 @@ check_final_action_config() esac }
-start() +__start() { check_dump_feasibility || return parse_config || return @@ -1067,7 +1067,32 @@ start() return 0 }
-reload() +_start() +{ + if ! __start; then + derror "Starting kdump: [FAILED]" + exit 1 + fi +} + +_status() +{ + EXIT_CODE=0 + is_kernel_loaded "$DEFAULT_DUMP_MODE" + case "$?" in + 0) + dinfo "Kdump is operational" + EXIT_CODE=0 + ;; + 1) + dinfo "Kdump is not operational" + EXIT_CODE=3 + ;; + esac + exit $EXIT_CODE +} + +_reload() { if ! is_kernel_loaded "$DEFAULT_DUMP_MODE"; then dwarn "Kdump was not running: [WARNING]" @@ -1146,7 +1171,7 @@ reload_fadump() return 1 }
-stop() +__stop() { if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then stop_fadump || return @@ -1158,7 +1183,21 @@ stop() return 0 }
-rebuild() +_stop() +{ + if ! _stop; then + derror "Stopping kdump: [FAILED]" + exit 1 + fi +} + +_restart() +{ + _start + _stop +} + +_rebuild() { parse_config || return 1 check_and_wait_network_ready || return 1 @@ -1607,12 +1646,14 @@ _update_crashkernel() fi }
- -# shellcheck disable=SC2154 # false positive when dereferencing an array reset_crashkernel_after_update() { local _kernel
+ if [[ $(kdump_get_conf_val auto_reset_crashkernel) != yes ]]; then + return + fi + if ! _is_bootloader_installed; then return fi @@ -1645,6 +1686,10 @@ reset_crashkernel_for_installed_kernel() { local _installed_kernel
+ if [[ $(kdump_get_conf_val auto_reset_crashkernel) != yes ]]; then + return + fi + # During package install, only try to reset crashkernel for osbuild # thus to avoid calling grubby when installing os via anaconda if ! _is_bootloader_installed && ! _is_osbuild; then @@ -1672,47 +1717,22 @@ main()
case "$1" in start) - if ! start; then - derror "Starting kdump: [FAILED]" - exit 1 - fi + _start ;; stop) - if ! stop; then - derror "Stopping kdump: [FAILED]" - exit 1 - fi + _stop ;; status) - EXIT_CODE=0 - is_kernel_loaded "$DEFAULT_DUMP_MODE" - case "$?" in - 0) - dinfo "Kdump is operational" - EXIT_CODE=0 - ;; - 1) - dinfo "Kdump is not operational" - EXIT_CODE=3 - ;; - esac - exit $EXIT_CODE + _status ;; reload) - reload + _reload ;; restart) - if ! stop; then - derror "Stopping kdump: [FAILED]" - exit 1 - fi - if ! start; then - derror "Starting kdump: [FAILED]" - exit 1 - fi + _restart ;; rebuild) - rebuild + _rebuild ;; propagate) propagate_ssh_key @@ -1731,14 +1751,10 @@ main() reset_crashkernel "$@" ;; _reset-crashkernel-after-update) - if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then - reset_crashkernel_after_update - fi + reset_crashkernel_after_update ;; _reset-crashkernel-for-installed_kernel) - if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then - reset_crashkernel_for_installed_kernel "$2" - fi + reset_crashkernel_for_installed_kernel "$2" ;; *) dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}"
On Fri, Jul 21, 2023 at 10:26 PM Philipp Rudo prudo@redhat.com wrote:
This allows to restructure the subcommand handling later on which is a prereq to introduce the new CLI parsing.
Signed-off-by: Philipp Rudo prudo@redhat.com
kdumpctl | 102 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 43 deletions(-)
diff --git a/kdumpctl b/kdumpctl index ce58cc9..6da5500 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1031,7 +1031,7 @@ check_final_action_config() esac }
-start() +__start() { check_dump_feasibility || return parse_config || return @@ -1067,7 +1067,32 @@ start() return 0 }
-reload() +_start() +{
if ! __start; then
derror "Starting kdump: [FAILED]"
exit 1
fi
+}
+_status() +{
EXIT_CODE=0
is_kernel_loaded "$DEFAULT_DUMP_MODE"
case "$?" in
0)
dinfo "Kdump is operational"
EXIT_CODE=0
;;
1)
dinfo "Kdump is not operational"
EXIT_CODE=3
;;
esac
exit $EXIT_CODE
+}
+_reload() { if ! is_kernel_loaded "$DEFAULT_DUMP_MODE"; then dwarn "Kdump was not running: [WARNING]" @@ -1146,7 +1171,7 @@ reload_fadump() return 1 }
-stop() +__stop() { if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then stop_fadump || return @@ -1158,7 +1183,21 @@ stop() return 0 }
-rebuild() +_stop() +{
if ! _stop; then
derror "Stopping kdump: [FAILED]"
exit 1
fi
+}
+_restart() +{
_start
_stop
+}
+_rebuild() { parse_config || return 1 check_and_wait_network_ready || return 1 @@ -1607,12 +1646,14 @@ _update_crashkernel() fi }
-# shellcheck disable=SC2154 # false positive when dereferencing an array reset_crashkernel_after_update() { local _kernel
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != yes ]]; then
return
fi
if ! _is_bootloader_installed; then return fi
@@ -1645,6 +1686,10 @@ reset_crashkernel_for_installed_kernel() { local _installed_kernel
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != yes ]]; then
return
fi
# During package install, only try to reset crashkernel for osbuild # thus to avoid calling grubby when installing os via anaconda if ! _is_bootloader_installed && ! _is_osbuild; then
@@ -1672,47 +1717,22 @@ main()
case "$1" in start)
if ! start; then
derror "Starting kdump: [FAILED]"
exit 1
fi
_start ;; stop)
if ! stop; then
derror "Stopping kdump: [FAILED]"
exit 1
fi
_stop ;; status)
EXIT_CODE=0
is_kernel_loaded "$DEFAULT_DUMP_MODE"
case "$?" in
0)
dinfo "Kdump is operational"
EXIT_CODE=0
;;
1)
dinfo "Kdump is not operational"
EXIT_CODE=3
;;
esac
exit $EXIT_CODE
_status ;; reload)
reload
_reload ;; restart)
if ! stop; then
derror "Stopping kdump: [FAILED]"
exit 1
fi
if ! start; then
derror "Starting kdump: [FAILED]"
exit 1
fi
_restart ;; rebuild)
rebuild
_rebuild ;; propagate) propagate_ssh_key
@@ -1731,14 +1751,10 @@ main() reset_crashkernel "$@" ;; _reset-crashkernel-after-update)
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then
reset_crashkernel_after_update
fi
reset_crashkernel_after_update ;; _reset-crashkernel-for-installed_kernel)
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then
reset_crashkernel_for_installed_kernel "$2"
fi
reset_crashkernel_for_installed_kernel "$2" ;; *) dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}"
-- 2.40.0
Reviewed-by: Pingfan Liu piliu@redhat.com
Collect all functions executed for the subcommands in an array. This is a prereq to restructure the CLI parsing later on.
While at it introduce a usage function to give the user a consistent feedback on user errors.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 82 ++++++++++++++++++++++++-------------------------------- 1 file changed, 35 insertions(+), 47 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 6da5500..dcd9f60 100755 --- a/kdumpctl +++ b/kdumpctl @@ -16,6 +16,7 @@ KDUMP_INITRD="" TARGET_INITRD="" #kdump shall be the default dump mode DEFAULT_DUMP_MODE="kdump" +PROGNAME=${0##*/}
standard_kexec_args="-d -p"
@@ -24,6 +25,23 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug"
declare -A OPT
+declare -A cmds_global +cmds_global=() +cmds_global[start]=_start +cmds_global[stop]=_stop +cmds_global[status]=_status +cmds_global[reload]=_reload +cmds_global[restart]=_restart +cmds_global[rebuild]=_rebuild +cmds_global[propagate]=propagate_ssh_key +cmds_global[showmem]=show_reserved_mem +cmds_global[estimate]=do_estimate +cmds_global[get-default-crashkernel]=get_default_crashkernel +cmds_global[reset-crashkernel]=reset_crashkernel +cmds_global[_reset-crashkernel-after-update]=reset_crashkernel_after_update +# shellcheck disable=SC2034 +cmds_global[_reset-crashkernel-for-installed_kernel]=reset_crashkernel_for_installed_kernel + if [[ -f /etc/sysconfig/kdump ]]; then . /etc/sysconfig/kdump fi @@ -55,6 +73,15 @@ trap ' exit $ret; ' EXIT
+_usage() +{ + [[ -n "$*" ]] && dinfo "$*" + dinfo "Usage: $PROGNAME [OPTIONS] COMMAND" + dinfo "See '$PROGNAME --help' or 'man $PROGNAME' for more details" + + exit 1 +} + _get_dracut_arg() { local shortopt longopt n tmp @@ -1712,55 +1739,16 @@ reset_crashkernel_for_installed_kernel()
main() { + local cmd + + [[ -n $1 ]] || _usage "No sub-command provided" + cmd=${cmds_global[$1]} + [[ -n $cmd ]] || _usage "Unknown option or sub-command '$1' provided" + shift + # Determine if the dump mode is kdump or fadump determine_dump_mode - - case "$1" in - start) - _start - ;; - stop) - _stop - ;; - status) - _status - ;; - reload) - _reload - ;; - restart) - _restart - ;; - rebuild) - _rebuild - ;; - propagate) - propagate_ssh_key - ;; - showmem) - show_reserved_mem - ;; - estimate) - do_estimate - ;; - get-default-crashkernel) - get_default_crashkernel "$2" - ;; - reset-crashkernel) - shift - reset_crashkernel "$@" - ;; - _reset-crashkernel-after-update) - reset_crashkernel_after_update - ;; - _reset-crashkernel-for-installed_kernel) - reset_crashkernel_for_installed_kernel "$2" - ;; - *) - dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}" - exit 1 - ;; - esac + $cmd "$@" }
if [[ ${__SOURCED__:+x} ]]; then
On Fri, Jul 21, 2023 at 10:26 PM Philipp Rudo prudo@redhat.com wrote:
Collect all functions executed for the subcommands in an array. This is a prereq to restructure the CLI parsing later on.
While at it introduce a usage function to give the user a consistent feedback on user errors.
Signed-off-by: Philipp Rudo prudo@redhat.com
kdumpctl | 82 ++++++++++++++++++++++++-------------------------------- 1 file changed, 35 insertions(+), 47 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 6da5500..dcd9f60 100755 --- a/kdumpctl +++ b/kdumpctl @@ -16,6 +16,7 @@ KDUMP_INITRD="" TARGET_INITRD="" #kdump shall be the default dump mode DEFAULT_DUMP_MODE="kdump" +PROGNAME=${0##*/}
standard_kexec_args="-d -p"
@@ -24,6 +25,23 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug"
declare -A OPT
+declare -A cmds_global +cmds_global=() +cmds_global[start]=_start +cmds_global[stop]=_stop +cmds_global[status]=_status +cmds_global[reload]=_reload +cmds_global[restart]=_restart +cmds_global[rebuild]=_rebuild +cmds_global[propagate]=propagate_ssh_key +cmds_global[showmem]=show_reserved_mem +cmds_global[estimate]=do_estimate +cmds_global[get-default-crashkernel]=get_default_crashkernel +cmds_global[reset-crashkernel]=reset_crashkernel +cmds_global[_reset-crashkernel-after-update]=reset_crashkernel_after_update +# shellcheck disable=SC2034 +cmds_global[_reset-crashkernel-for-installed_kernel]=reset_crashkernel_for_installed_kernel
if [[ -f /etc/sysconfig/kdump ]]; then . /etc/sysconfig/kdump fi @@ -55,6 +73,15 @@ trap ' exit $ret; ' EXIT
+_usage() +{
[[ -n "$*" ]] && dinfo "$*"
dinfo "Usage: $PROGNAME [OPTIONS] COMMAND"
dinfo "See '$PROGNAME --help' or 'man $PROGNAME' for more details"
exit 1
+}
_get_dracut_arg() { local shortopt longopt n tmp @@ -1712,55 +1739,16 @@ reset_crashkernel_for_installed_kernel()
main() {
local cmd
[[ -n $1 ]] || _usage "No sub-command provided"
cmd=${cmds_global[$1]}
[[ -n $cmd ]] || _usage "Unknown option or sub-command '$1' provided"
shift
# Determine if the dump mode is kdump or fadump determine_dump_mode
case "$1" in
start)
_start
;;
stop)
_stop
;;
status)
_status
;;
reload)
_reload
;;
restart)
_restart
;;
rebuild)
_rebuild
;;
propagate)
propagate_ssh_key
;;
showmem)
show_reserved_mem
;;
estimate)
do_estimate
;;
get-default-crashkernel)
get_default_crashkernel "$2"
;;
reset-crashkernel)
shift
reset_crashkernel "$@"
;;
_reset-crashkernel-after-update)
reset_crashkernel_after_update
;;
_reset-crashkernel-for-installed_kernel)
reset_crashkernel_for_installed_kernel "$2"
;;
*)
dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}"
exit 1
;;
esac
$cmd "$@"
}
if [[ ${__SOURCED__:+x} ]]; then
2.40.0
Reviewed-by: Pingfan Liu piliu@redhat.com
When handling fadump there are three cases we need to consider
1) When running on non-ppc64le systems In this case _dump_mode=kdump and _new_fadump='' always. In other words we don't need to care updating the fadump parameter on the kernel command line. We could always remove it like the code did so far. But should we remove it when we never set it? In particular as that might overwrite a change explicitly made by the user (for whatever reason)
2) When running on ppc64le and the user provided --fadump option In this case _new_fadump and _dump_mode are set accordingly to what the user provided. Thus we need to update both the crashkernel (in case fadump was turned on/off) and the fadump (in case the fadump mode changed) parameters.
3) When running on ppc64le but the user did not provide --fadump option In this case both _new_fadump='' and _dump_mode=''. In this case we take over the previously set fadump parameter. Which means that we don't need to update the fadump parameter at all. We do need to check whether the _new_dump_mode is fadump or kdump though so we use the correct (new) default crashkernel value.
In the three cases only the second one needs to update the fadump parameter. Reflect this discussion in code.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/kdumpctl b/kdumpctl index dcd9f60..6d0e180 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1549,10 +1549,10 @@ _get_all_kernels_from_grubby() reset_crashkernel() { local _opt _val _reboot _grubby_kernel_path _kernel _kernels - local _dump_mode _new_dump_mode + local _dump_mode local _has_changed _needs_reboot local _old_ck _new_ck - local _old_fadump _new_fadump + local _old_fadump _new_fadump _opt_fadump
for _opt in "$@"; do case "$_opt" in @@ -1561,12 +1561,11 @@ reset_crashkernel() derror "Option --fadump only valid on PPC" exit 1 fi - _new_fadump=${_opt#*=} - if ! _dump_mode=$(get_dump_mode_by_fadump_val $_new_fadump); then + _opt_fadump=${_opt#*=} + if ! _dump_mode=$(get_dump_mode_by_fadump_val $_opt_fadump); then derror "failed to determine dump mode" exit fi - [[ "$_new_fadump" == off ]] && _new_fadump="" ;; --kernel=*) _val=${_opt#*=} @@ -1601,8 +1600,6 @@ reset_crashkernel() return fi
- [[ $(uname -m) != ppc64le ]] && _dump_mode=kdump - # If kernel-path not specified, either # - use KDUMP_KERNELVER if it's defined # - use current running kernel @@ -1618,19 +1615,28 @@ reset_crashkernel()
for _kernel in $_kernels; do _has_changed="" - if [[ -z $_dump_mode ]]; then - _new_dump_mode=$(get_dump_mode_by_kernel "$_kernel") - _new_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump) + if [[ $(uname -m) == ppc64le ]]; then + if [[ -n "$_opt_fadump" ]]; then + _new_ck=$(kdump_get_arch_recommend_crashkernel "$_dump_mode") + _old_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump) + _new_fadump="$_opt_fadump" + [[ "$_new_fadump" == off ]] && _new_fadump="" + if _update_kernel_cmdline "$_kernel" fadump "$_old_fadump" "$_new_fadump"; then + if [[ -n "$_new_fadump" ]]; then + _has_changed="Updated fadump=$_new_fadump" + else + _has_changed="Removed fadump" + fi + fi + else + _dump_mode="$(get_dump_mode_by_kernel "$_kernel")" + _new_ck=$(kdump_get_arch_recommend_crashkernel "$_dump_mode") + fi else - _new_dump_mode=$_dump_mode + _new_ck=$(kdump_get_arch_recommend_crashkernel kdump) fi
_old_ck=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) - _new_ck=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode") - _old_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump) - if _update_kernel_cmdline "$_kernel" fadump "$_old_fadump" "$_new_fadump"; then - _has_changed="Updated fadump=$_new_fadump" - fi if _update_kernel_cmdline "$_kernel" crashkernel "$_old_ck" "$_new_ck"; then _has_changed="Updated crashkernel=$_new_ck" fi
On Fri, Jul 21, 2023 at 10:26 PM Philipp Rudo prudo@redhat.com wrote:
When handling fadump there are three cases we need to consider
When running on non-ppc64le systems In this case _dump_mode=kdump and _new_fadump='' always. In other words we don't need to care updating the fadump parameter on the kernel command line. We could always remove it like the code did so far. But should we remove it when we never set it? In particular as that might overwrite a change explicitly made by the user (for whatever reason)
When running on ppc64le and the user provided --fadump option In this case _new_fadump and _dump_mode are set accordingly to what the user provided. Thus we need to update both the crashkernel (in case fadump was turned on/off) and the fadump (in case the fadump mode changed) parameters.
When running on ppc64le but the user did not provide --fadump option In this case both _new_fadump='' and _dump_mode=''. In this case we take over the previously set fadump parameter. Which means that we don't need to update the fadump parameter at all. We do need to check whether the _new_dump_mode is fadump or kdump though so we use the correct (new) default crashkernel value.
In the three cases only the second one needs to update the fadump parameter. Reflect this discussion in code.
Signed-off-by: Philipp Rudo prudo@redhat.com
kdumpctl | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/kdumpctl b/kdumpctl index dcd9f60..6d0e180 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1549,10 +1549,10 @@ _get_all_kernels_from_grubby() reset_crashkernel() { local _opt _val _reboot _grubby_kernel_path _kernel _kernels
local _dump_mode _new_dump_mode
local _dump_mode local _has_changed _needs_reboot local _old_ck _new_ck
local _old_fadump _new_fadump
local _old_fadump _new_fadump _opt_fadump for _opt in "$@"; do case "$_opt" in
@@ -1561,12 +1561,11 @@ reset_crashkernel() derror "Option --fadump only valid on PPC" exit 1 fi
_new_fadump=${_opt#*=}
if ! _dump_mode=$(get_dump_mode_by_fadump_val $_new_fadump); then
_opt_fadump=${_opt#*=}
if ! _dump_mode=$(get_dump_mode_by_fadump_val $_opt_fadump); then derror "failed to determine dump mode" exit fi
[[ "$_new_fadump" == off ]] && _new_fadump="" ;; --kernel=*) _val=${_opt#*=}
@@ -1601,8 +1600,6 @@ reset_crashkernel() return fi
[[ $(uname -m) != ppc64le ]] && _dump_mode=kdump
# If kernel-path not specified, either # - use KDUMP_KERNELVER if it's defined # - use current running kernel
@@ -1618,19 +1615,28 @@ reset_crashkernel()
for _kernel in $_kernels; do _has_changed=""
if [[ -z $_dump_mode ]]; then
_new_dump_mode=$(get_dump_mode_by_kernel "$_kernel")
_new_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump)
if [[ $(uname -m) == ppc64le ]]; then
if [[ -n "$_opt_fadump" ]]; then
_new_ck=$(kdump_get_arch_recommend_crashkernel "$_dump_mode")
_old_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump)
_new_fadump="$_opt_fadump"
[[ "$_new_fadump" == off ]] && _new_fadump=""
if _update_kernel_cmdline "$_kernel" fadump "$_old_fadump" "$_new_fadump"; then
if [[ -n "$_new_fadump" ]]; then
_has_changed="Updated fadump=$_new_fadump"
else
_has_changed="Removed fadump"
fi
fi
else
_dump_mode="$(get_dump_mode_by_kernel "$_kernel")"
_new_ck=$(kdump_get_arch_recommend_crashkernel "$_dump_mode")
fi else
_new_dump_mode=$_dump_mode
_new_ck=$(kdump_get_arch_recommend_crashkernel kdump) fi _old_ck=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel)
_new_ck=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode")
_old_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump)
if _update_kernel_cmdline "$_kernel" fadump "$_old_fadump" "$_new_fadump"; then
_has_changed="Updated fadump=$_new_fadump"
fi if _update_kernel_cmdline "$_kernel" crashkernel "$_old_ck" "$_new_ck"; then _has_changed="Updated crashkernel=$_new_ck" fi
-- 2.40.0
Reviewed-by: Pingfan Liu piliu@redhat.com
In preparation to rewrite the CLI switch from a self written option parser to getopt. This not only makes it easier to add options to other subcommands (or globally) but also gives more flexibility to the user. For example there is no more requirement to pass option arguments with a '=', i.e. like --option=argument.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 197 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 157 insertions(+), 40 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 6d0e180..15a1476 100755 --- a/kdumpctl +++ b/kdumpctl @@ -42,6 +42,37 @@ cmds_global[_reset-crashkernel-after-update]=reset_crashkernel_after_update # shellcheck disable=SC2034 cmds_global[_reset-crashkernel-for-installed_kernel]=reset_crashkernel_for_installed_kernel
+# shellcheck disable=SC2034 +opts_short_reset_crashkernel="" +# shellcheck disable=SC2034 +opts_long_reset_crashkernel=( + --long "fadump:" + --long "kernel:" + --long "reboot" +) + +parse_args_reset_crashkernel() +{ + case $1 in + --fadump) + if [[ $(uname -a) != ppc64le ]]; then + derror "Option --fadump only valid on PPC" + exit 1 + fi + OPT[fadump]="$2" + return 2 + ;; + --kernel) + OPT[kernel]="$2" + return 2 + ;; + --reboot) + OPT[reboot]=yes + return 1 + ;; + esac +} + if [[ -f /etc/sysconfig/kdump ]]; then . /etc/sysconfig/kdump fi @@ -73,6 +104,11 @@ trap ' exit $ret; ' EXIT
+has_function() +{ + declare -F "$1" > /dev/null +} + _usage() { [[ -n "$*" ]] && dinfo "$*" @@ -82,6 +118,110 @@ _usage() exit 1 }
+# shellcheck disable=SC2120 +_parse_args() +{ + local _tmp _parser _ret + + _tmp=$( getopt \ + -o "+$__shortopts" \ + "${__longopts[@]}" \ + -- "${__argv[@]}" + ) + + # shellcheck disable=SC2181 + [[ $? -ne 0 ]] && _usage + + eval set -- "$_tmp" + while :; do + if [[ "$1" == -- ]]; then + shift + break + fi + + for _parser in "${__parsers[@]}"; do + $_parser "$@" + _ret=$? + if [[ $_ret -gt 0 ]]; then + shift $_ret + continue 2 + fi + done + + # This point should never be reached, unless there is an option + # defined for getopt that none of the parsers can handle. + echo "Missing parser for option $1" >&2 + exit + done + __argv=("$@") +} + +__switch_cmd() +{ + local -n _shortopts _longopts _cmds + local _cmd _parser k + + _cmd=$1 + + [[ -n "$_cmd" ]] || return + + _shortopts=opts_short_${_cmd} + _longopts=opts_long_${_cmd} + _parser=parse_args_${_cmd} + _cmds=cmds_${_cmd} + + has_function "$_parser" || return + + __shortopts+="$_shortopts" + __longopts+=("${_longopts[@]}") + __parsers+=("$_parser") + + __cmds=() + for k in "${!_cmds[@]}"; do + __cmds[$k]="${_cmds[$k]}" + done +} + +parse_args() +{ + # Caution: These are global variables within the parser + local -a __argv __longopts __parsers + local -A __cmds + local __shortopts + + # Return via name references + local -n __args __func + local _cmd _tmp_func + + __cmd="$1"; shift + __func="$1"; shift + __args="$1"; shift + __argv=("$@") + + while :; do + __cmd=${__cmd//-/_} + __switch_cmd "$__cmd" + _parse_args + + [[ ${#__argv[@]} -eq 0 ]] && break + [[ -n "${__cmds["${__argv[0]}"]}" ]] || break + _tmp_func="${__cmds["${__argv[0]}"]}" + if [[ "$__cmd" == global ]]; then + __cmd="${__argv[0]}" + else + __cmd="${__cmd}_${__argv[0]}" + fi + unset "__argv[0]" + # Fix indices in the array + __argv=("${__argv[@]}") + done + + __func="$_tmp_func" + __args="${__argv[*]}" + + return +} + _get_dracut_arg() { local shortopt longopt n tmp @@ -1548,42 +1688,18 @@ _get_all_kernels_from_grubby()
reset_crashkernel() { - local _opt _val _reboot _grubby_kernel_path _kernel _kernels - local _dump_mode + local _kernel _kernels _dump_mode local _has_changed _needs_reboot local _old_ck _new_ck - local _old_fadump _new_fadump _opt_fadump - - for _opt in "$@"; do - case "$_opt" in - --fadump=*) - if [[ $(uname -m) != ppc64le ]]; then - derror "Option --fadump only valid on PPC" - exit 1 - fi - _opt_fadump=${_opt#*=} - if ! _dump_mode=$(get_dump_mode_by_fadump_val $_opt_fadump); then - derror "failed to determine dump mode" - exit - fi - ;; - --kernel=*) - _val=${_opt#*=} - if ! _valid_grubby_kernel_path $_val; then - derror "Invalid $_opt, please specify a valid kernel path, ALL or DEFAULT" - exit - fi - _grubby_kernel_path=$_val - ;; - --reboot) - _reboot=yes - ;; - *) - derror "$_opt not recognized" - exit 1 - ;; - esac - done + local _old_fadump _new_fadump + local func args + + parse_args reset-crashkernel func args "$@" + eval set -- "$args" + + if [[ -n "$1" ]]; then + _usage "Additional parameter '$1' provided." + fi
# 1. OSTree systems use "rpm-ostree kargs" instead of grubby to manage kernel command # line. --kernel=ALL doesn't make sense for OStree. @@ -1595,7 +1711,7 @@ reset_crashkernel() _old_ck=$(rpm-ostree kargs | sed -n -E 's/.*(^|\s)crashkernel=(\S*).*/\2/p') _new_ck=$(kdump_get_arch_recommend_crashkernel kdump) if _update_kernel_cmdline "" crashkernel "$_old_ck" "$_new_ck"; then - [[ $_reboot == yes ]] && systemctl reboot + [[ ${OPT[reboot]} == yes ]] && systemctl reboot fi return fi @@ -1603,23 +1719,24 @@ reset_crashkernel() # If kernel-path not specified, either # - use KDUMP_KERNELVER if it's defined # - use current running kernel - if [[ -z $_grubby_kernel_path ]]; then + if [[ -z ${OPT[kernel]} ]]; then [[ -n $KDUMP_KERNELVER ]] || KDUMP_KERNELVER=$(uname -r) if ! _kernels=$(_find_kernel_path_by_release "$KDUMP_KERNELVER"); then derror "no kernel for version $KDUMP_KERNELVER found" exit 1 fi else - _kernels=$(_get_all_kernels_from_grubby "$_grubby_kernel_path") + _kernels=$(_get_all_kernels_from_grubby "${OPT[kernel]}") fi
for _kernel in $_kernels; do _has_changed="" if [[ $(uname -m) == ppc64le ]]; then - if [[ -n "$_opt_fadump" ]]; then + if [[ -n "${OPT[fadump]}" ]]; then + _dump_mode=$(get_dump_mode_by_fadump_val "${OPT[fadump]}") _new_ck=$(kdump_get_arch_recommend_crashkernel "$_dump_mode") _old_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump) - _new_fadump="$_opt_fadump" + _new_fadump="${OPT[fadump]}" [[ "$_new_fadump" == off ]] && _new_fadump="" if _update_kernel_cmdline "$_kernel" fadump "$_old_fadump" "$_new_fadump"; then if [[ -n "$_new_fadump" ]]; then @@ -1646,7 +1763,7 @@ reset_crashkernel() fi done
- if [[ $_reboot == yes && $_needs_reboot == 1 ]]; then + if [[ ${OPT[reboot]} == yes && $_needs_reboot == 1 ]]; then systemctl reboot fi }
With the arrays introduced for getopt it's pretty simple to add some bash completion. Let's make our lives not harder than they have to be and add some.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 3 ++ kdumpctl.bash-completion | 107 +++++++++++++++++++++++++++++++++++++++ kexec-tools.spec | 4 ++ 3 files changed, 114 insertions(+) create mode 100755 kdumpctl.bash-completion
diff --git a/kdumpctl b/kdumpctl index 15a1476..b4c26e4 100755 --- a/kdumpctl +++ b/kdumpctl @@ -73,6 +73,9 @@ parse_args_reset_crashkernel() esac }
+# Only do the bare minimum when sourced during bash completion +[[ ${COMP_LINE:+x} ]] && return + if [[ -f /etc/sysconfig/kdump ]]; then . /etc/sysconfig/kdump fi diff --git a/kdumpctl.bash-completion b/kdumpctl.bash-completion new file mode 100755 index 0000000..b0fe92e --- /dev/null +++ b/kdumpctl.bash-completion @@ -0,0 +1,107 @@ +#!/usr/bin/bash +# shellcheck disable=SC1091 + +source /usr/share/bash-completion/bash_completion + +_is_defined() +{ + declare -p "$1" &> /dev/null +} + +_is_subcmd() +{ + local _cmd _subcmd + local -n _cmds + + _cmd="$1" + _subcmd="$2" + + _cmds=cmds_${_cmd} + _is_defined "cmds_${_cmd}" || return + + [[ -n "${_subcmd}" ]] || return + [[ -n "${_cmds["$_subcmd"]}" ]] +} + +_add_cmds() +{ + local -n _cmds + local _cmd + + _is_defined "$1" || return + + _cmds="$1" + for _cmd in "${!_cmds[@]}"; do + [[ "${_cmd:0:1}" == "_" ]] && unset '_cmds[$_cmd]' + done + + # shellcheck disable=SC2207 + COMPREPLY+=($(compgen -W "${!_cmds[*]}" -- "$cur")) +} + +_add_opts() +{ + local _opt + local -a _list + local -n _opts + + _is_defined "$1" || return + + _opts="$1" + for _opt in "${_opts[@]}"; do + [[ "$_opt" == "--long" ]] && continue + _list+=("--${_opt%:}") + done + + # shellcheck disable=SC2207 + COMPREPLY+=($(compgen -W "${_list[*]}" -- "$cur")) +} + +__kdumpctl() { + # shellcheck disable=SC2034 + local cur prev words cword + local _word _cmd _longopts + + _init_completion || return + + source /usr/bin/kdumpctl + + # make the completion work with --opt= style options. Where the '=' gets + # split into its own word. I.e. --opt= becomes ( '--opt' '=' ) and + # --opt=foo becomes ( '--opt' '=' 'foo' ). Hence adjust cur and prev for + # both cases. + [[ $cur == = ]] && cur="" + [[ $prev == = ]] && prev=${words[-3]} + + case "$prev" in + --fadump) + # shellcheck disable=SC2207 + COMPREPLY+=($(compgen -W "on off nocma" -- "$cur")) + return + ;; + --kernel) + _filedir + # shellcheck disable=SC2207 + COMPREPLY+=($(compgen -W "ALL DEFAULT" -- "$cur")) + return + ;; + esac + + _cmd=global + _add_opts opts_long_global + for _word in "${words[@]}"; do + _longopts=opts_long_${_word} + _is_defined "$_longopts" && _add_opts "$_longopts" + + if _is_subcmd "$_cmd" "$_word"; then + if [[ "$_cmd" == global ]]; then + _cmd="$_word" + else + _cmd="${_cmd}_${_word}" + fi + fi + done + + _is_defined "cmds_${_cmd}" && _add_cmds "cmds_${_cmd}" +} && + complete -F __kdumpctl kdumpctl diff --git a/kexec-tools.spec b/kexec-tools.spec index 6b2eac4..2f4e4a6 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -39,6 +39,7 @@ Source34: crashkernel-howto.txt Source35: kdump-migrate-action.sh Source36: kdump-restart.sh Source37: 60-fadump.install +Source38: kdumpctl.bash-completion
####################################### # These are sources for mkdumpramfs @@ -171,6 +172,7 @@ mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/ mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man5/ mkdir -p -m755 $RPM_BUILD_ROOT%{_docdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_datadir}/kdump +mkdir -p -m755 $RPM_BUILD_ROOT%{_datadir}/bash-completion/completions/ mkdir -p -m755 $RPM_BUILD_ROOT%{_udevrulesdir} mkdir -p $RPM_BUILD_ROOT%{_unitdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_bindir} @@ -190,6 +192,7 @@ install -m 644 kdump.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 rst2man %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 rst2man %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 +install -m 755 %{SOURCE38} $RPM_BUILD_ROOT%{_datadir}/bash-completion/completions/kdumpctl install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh install -m 755 %{SOURCE31} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-logger.sh @@ -356,6 +359,7 @@ fi %dir %{_sysconfdir}/kdump/pre.d %dir %{_sysconfdir}/kdump/post.d %dir %{_sharedstatedir}/kdump +%{_datadir}/bash-completion/completions/kdumpctl %{_mandir}/man8/kdumpctl.8.gz %{_mandir}/man8/kexec.8.gz %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
In order to be able to use --kernel with other subcommands create global options and move it there.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 43 +++++++++++++++++++++++++++++-------------- kdumpctl.8.rst | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 59 insertions(+), 22 deletions(-)
diff --git a/kdumpctl b/kdumpctl index b4c26e4..9d6169e 100755 --- a/kdumpctl +++ b/kdumpctl @@ -42,12 +42,28 @@ cmds_global[_reset-crashkernel-after-update]=reset_crashkernel_after_update # shellcheck disable=SC2034 cmds_global[_reset-crashkernel-for-installed_kernel]=reset_crashkernel_for_installed_kernel
+# shellcheck disable=SC2034 +opts_short_global="" +# shellcheck disable=SC2034 +opts_long_global=( + --long "kernel:" +) + +parse_args_global() +{ + case $1 in + --kernel) + OPT[kernel]="$2" + return 2 + ;; + esac +} + # shellcheck disable=SC2034 opts_short_reset_crashkernel="" # shellcheck disable=SC2034 opts_long_reset_crashkernel=( --long "fadump:" - --long "kernel:" --long "reboot" )
@@ -62,10 +78,6 @@ parse_args_reset_crashkernel() OPT[fadump]="$2" return 2 ;; - --kernel) - OPT[kernel]="$2" - return 2 - ;; --reboot) OPT[reboot]=yes return 1 @@ -1697,9 +1709,6 @@ reset_crashkernel() local _old_fadump _new_fadump local func args
- parse_args reset-crashkernel func args "$@" - eval set -- "$args" - if [[ -n "$1" ]]; then _usage "Additional parameter '$1' provided." fi @@ -1865,16 +1874,22 @@ reset_crashkernel_for_installed_kernel()
main() { - local cmd + local func args + + parse_args global func args "$@" + eval set -- "$args"
- [[ -n $1 ]] || _usage "No sub-command provided" - cmd=${cmds_global[$1]} - [[ -n $cmd ]] || _usage "Unknown option or sub-command '$1' provided" - shift + if [[ -z "$func" ]]; then + if [[ -z "$1" ]]; then + _usage "No command provided." + else + _usage "Unknown command '$1' provided." + fi + fi
# Determine if the dump mode is kdump or fadump determine_dump_mode - $cmd "$@" + $func "$@" }
if [[ ${__SOURCED__:+x} ]]; then diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst index c6eeeb8..60b5a84 100644 --- a/kdumpctl.8.rst +++ b/kdumpctl.8.rst @@ -74,14 +74,10 @@ estimate get-default-crashkernel Return the default crashkernel value provided by kexec-tools.
-reset-crashkernel [--kernel=*kernel_path*] [--reboot] - Reset crashkernel to default value recommended by kexec-tools. If no kernel - is specified, will reset **KDUMP_KERNELVER** if it is defined in - */etc/sysconfig/kdump* or the current running kernels crashkernel value if - KDUMP_KERNELVER is empty. You can also specify **--kernel=ALL** and - **--kernel=DEFAULT** which have the same meaning as grubbys kernel-path=ALL - and kernel-path=DEFAULT. ppc64le supports FADump and supports an additional - [**--fadump=on|off|nocma**] parameter to toggle FADump on/off. +reset-crashkernel *[OPTIONS]* + Set the value of the crashkernel parameter on the kernel command line to a + recommended default. The system needs to reboot for the change to take + effect.
.. note:: The memory requirements for kdump varies heavily depending on the used hardware and system configuration and cannot be predicted @@ -90,6 +86,32 @@ reset-crashkernel [--kernel=*kernel_path*] [--reboot] changing the crashkernel parameter on the kernel command line.
+OPTIONS +======= + +Global Options +-------------- + +--kernel *kernel_path* + Specifies the kernel image to use as kdump kernel. There are a number of ways + to specify the kernel used (1) by path to the kernel image, (2) **DEFAULT** + selects the default kernel (requires grubby) and, (3) **ALL** selects all + installed kernels (not applicable with all commands). + + If omitted **kdumpctl** uses the one specified in */etc/sysconfig/kdump*. If + that is missing as well **kdumpctl** falls back to the currently running + kernel. + +Options for reset-crashkernel +----------------------------- + +--fadump [on|off|nocma] + Set the mode for FADump (only valid on PPC). + +--reboot + Automatically reboot if the kernel command line changed. + + SEE ALSO ========
Most users will expect such an option. So add it.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 40 +++++++++++++++++++++++++++++++++++++++- kdumpctl.8.rst | 3 +++ 2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl index 9d6169e..047c635 100755 --- a/kdumpctl +++ b/kdumpctl @@ -43,15 +43,20 @@ cmds_global[_reset-crashkernel-after-update]=reset_crashkernel_after_update cmds_global[_reset-crashkernel-for-installed_kernel]=reset_crashkernel_for_installed_kernel
# shellcheck disable=SC2034 -opts_short_global="" +opts_short_global="h" # shellcheck disable=SC2034 opts_long_global=( + --long "help" --long "kernel:" )
parse_args_global() { case $1 in + -h|--help) + _help + exit 0 + ;; --kernel) OPT[kernel]="$2" return 2 @@ -133,6 +138,39 @@ _usage() exit 1 }
+_help() +{ + cat << EOF +Usage: $PROGNAME [OPTIONS] COMMAND + +Controll interface for the kdump service +Options: + -h, --help Print this help message + --kernel <path> + Specifies the kernel image to use. This option allows the + special keywords DEFAULT to select the default kernel (requires + grubby) and ALL to allow editing all installed kernels (not + applicaple with all commands). + +Options for reset-crashkernel: + --fadump [on|off|nocma] + The mode fadump should run in (only valid for PPC). + --reboot Automatically reboot if the kernel command line changed. + +Common commands: + status Print current status of the service + start Start the service + stop Stop the service + restart Equivalent to stop; start + rebuild Force rebuild the kdump initramfs + propagate Setup key authentication for ssh dump targets + reset-crashkernel + Reset the crashkernel parameter to its default value + +See 'man $PROGNAME' for more details and the full list of commands. +EOF +} + # shellcheck disable=SC2120 _parse_args() { diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst index 60b5a84..4c2a06e 100644 --- a/kdumpctl.8.rst +++ b/kdumpctl.8.rst @@ -92,6 +92,9 @@ OPTIONS Global Options --------------
+-h, --help + Display a short help text and exit. + --kernel *kernel_path* Specifies the kernel image to use as kdump kernel. There are a number of ways to specify the kernel used (1) by path to the kernel image, (2) **DEFAULT**
Add the --kver option. It is identical to setting KDUMP_KERNELVER in /etc/sysconfig/kdump. Providing --kver on the command line takes precedence over KDUMP_KERNELVER if both are used.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 18 ++++++++++++++++++ kdumpctl.8.rst | 6 ++++++ kdumpctl.bash-completion | 18 ++++++++++++++++++ 3 files changed, 42 insertions(+)
diff --git a/kdumpctl b/kdumpctl index 047c635..10e671a 100755 --- a/kdumpctl +++ b/kdumpctl @@ -48,6 +48,7 @@ opts_short_global="h" opts_long_global=( --long "help" --long "kernel:" + --long "kver:" )
parse_args_global() @@ -61,6 +62,10 @@ parse_args_global() OPT[kernel]="$2" return 2 ;; + --kver) + KDUMP_KERNELVER="$2" + return 2 + ;; esac }
@@ -151,6 +156,10 @@ Options: special keywords DEFAULT to select the default kernel (requires grubby) and ALL to allow editing all installed kernels (not applicaple with all commands). + --kver <version> + Specifies the kernel version to use. This option is only + required if the version cannot be determined from the filename + provided by the --kernel option.
Options for reset-crashkernel: --fadump [on|off|nocma] @@ -1910,6 +1919,11 @@ reset_crashkernel_for_installed_kernel() _update_crashkernel "$_installed_kernel" }
+_is_valid_kver() +{ + [[ -f /usr/lib/modules/$1/modules.dep ]] +} + main() { local func args @@ -1925,6 +1939,10 @@ main() fi fi
+ if [[ -n "$KDUMP_KERNELVER" ]] && ! _is_valid_kver "$KDUMP_KERNELVER"; then + _usage "Invalid kernel version $KDUMP_KERNELVER provided" + fi + # Determine if the dump mode is kdump or fadump determine_dump_mode $func "$@" diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst index 4c2a06e..58e7dfa 100644 --- a/kdumpctl.8.rst +++ b/kdumpctl.8.rst @@ -105,6 +105,12 @@ Global Options that is missing as well **kdumpctl** falls back to the currently running kernel.
+--kver *version* + Specifies the kernel version to use. This option is only required if the + version cannot be determined from the filename provided by the --kernel + option. Otherwise the version determined from the filename will take + precedence. + Options for reset-crashkernel -----------------------------
diff --git a/kdumpctl.bash-completion b/kdumpctl.bash-completion index b0fe92e..8e7d099 100755 --- a/kdumpctl.bash-completion +++ b/kdumpctl.bash-completion @@ -57,6 +57,20 @@ _add_opts() COMPREPLY+=($(compgen -W "${_list[*]}" -- "$cur")) }
+_kver() { + local _ver + local -a _ret + + for _ver in /usr/lib/modules/*; do + _ver=${_ver#/usr/lib/modules/} + _ver=${_ver%%/*} + _ret+=("$_ver") + done + + # shellcheck disable=SC2207 + COMPREPLY+=($(compgen -W "${_ret[*]}" -- "$cur")) +} + __kdumpctl() { # shellcheck disable=SC2034 local cur prev words cword @@ -85,6 +99,10 @@ __kdumpctl() { COMPREPLY+=($(compgen -W "ALL DEFAULT" -- "$cur")) return ;; + --kver) + _kver + return + ;; esac
_cmd=global
Currently the --kernel option relies on grubby to resolve the paths to the kernel image. This is somewhat problematic as grubby is not installed all the time. Furthermore it only works with installed kernels. So developer cannot use a self compiled kernel directly but has to install it first. Solve this by emulating the behaviour of grubbys --kernel option in kdumpctl.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 186 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 166 insertions(+), 20 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 10e671a..d77ee56 100755 --- a/kdumpctl +++ b/kdumpctl @@ -3,6 +3,7 @@ KEXEC=/sbin/kexec
KDUMP_KERNELVER="" KDUMP_KERNEL="" +declare -A KDUMP_KERNEL_LIST KDUMP_COMMANDLINE="" KEXEC_ARGS="" KDUMP_LOG_PATH="/var/log" @@ -1727,11 +1728,6 @@ _update_kernel_cmdline() fi }
-_valid_grubby_kernel_path() -{ - [[ -n "$1" ]] && grubby --info="$1" > /dev/null 2>&1 -} - # return all the kernel paths given a grubby kernel-path # # $1: kernel path accepted by grubby, e.g. DEFAULT, ALL, @@ -1750,7 +1746,7 @@ _get_all_kernels_from_grubby()
reset_crashkernel() { - local _kernel _kernels _dump_mode + local _kernel _dump_mode local _has_changed _needs_reboot local _old_ck _new_ck local _old_fadump _new_fadump @@ -1775,20 +1771,7 @@ reset_crashkernel() return fi
- # If kernel-path not specified, either - # - use KDUMP_KERNELVER if it's defined - # - use current running kernel - if [[ -z ${OPT[kernel]} ]]; then - [[ -n $KDUMP_KERNELVER ]] || KDUMP_KERNELVER=$(uname -r) - if ! _kernels=$(_find_kernel_path_by_release "$KDUMP_KERNELVER"); then - derror "no kernel for version $KDUMP_KERNELVER found" - exit 1 - fi - else - _kernels=$(_get_all_kernels_from_grubby "${OPT[kernel]}") - fi - - for _kernel in $_kernels; do + for _kernel in "${KDUMP_KERNEL_LIST[@]}"; do _has_changed="" if [[ $(uname -m) == ppc64le ]]; then if [[ -n "${OPT[fadump]}" ]]; then @@ -1919,11 +1902,167 @@ reset_crashkernel_for_installed_kernel() _update_crashkernel "$_installed_kernel" }
+_init_systeminfo() +{ + local line + + while read -r line; do + case ${line%%:*} in + KERNEL_INSTALL_BOOT_ROOT) + [[ -n $KDUMP_BOOTDIR ]] && continue + KDUMP_BOOTDIR=${line##*: } + ;; + KERNEL_INSTALL_ENTRY_TOKEN) + BLS_ENTRY_TOKEN=${line##*: } + ;; + esac + done < <(kernel-install inspect) + BLS_CONFDIR=$KDUMP_BOOTDIR/loader/entries + BLS_UKIDIR=$KDUMP_BOOTDIR/efi/EFI/Linux +} + _is_valid_kver() { [[ -f /usr/lib/modules/$1/modules.dep ]] }
+_is_rescue_kernel() +{ + [[ "$1" == *rescue* ]] +} + +_parse_kver() +{ + local _img _kver + + [[ -z "$1" ]] && return + + _img=$1 + + # Fedora standard installation, i.e. $BOOT/vmlinuz-<version> + _kver=${_img##*/vmlinuz-} + _kver=${_kver%"$KDUMP_IMG_EXT"} + if _is_valid_kver "$_kver"; then + echo "$_kver" + return + fi + + # BLS recommended image names, i.e. $BOOT/<token>/<version>/linux + _kver=${_img##*/"$BLS_ENTRY_TOKEN"/} + _kver=${_kver%%/*} + if _is_valid_kver "$_kver"; then + echo "$_kver" + return + fi + + # Fedora UKI installation, i.e. $BOOT/efi/EFI/Linux/<token>-<version>.efi + _kver=${_img##*/"$BLS_ENTRY_TOKEN"-} + _kver=${_kver%.efi} + if _is_valid_kver "$_kver"; then + echo "$_kver" + return + fi + + ddebug "Could not parse version from $_img" + echo "UNKNOWN" +} + +# _get_installed_kernel +# Returns a line with <path to kernel img> <kver> for each installed kernel +# The function assumes that every installed kernel has a valid BLS entry +_get_installed_kernel() +{ + local _img + + while read -r _img; do + # On s390 the paths in the bls type 1 configs are absolute, not + # relative to the boot partition + [[ -f "$_img" ]] || _img="$KDUMP_BOOTDIR/${_img#/}" + [[ -f "$_img" ]] || continue + _is_rescue_kernel "$_img" && continue + + echo "$_img $(_parse_kver "$_img") " + done < <(sed -n -e "s/^linux (.*)$/\1/p" \ + "$BLS_CONFDIR"/"$BLS_ENTRY_TOKEN"-*.conf \ + "$BLS_CONFDIR"/ostree-*.conf \ + 2> /dev/null) + + for _img in "$BLS_UKIDIR"/"$BLS_ENTRY_TOKEN"-*.efi; do + [[ -f $_img ]] || continue + _is_rescue_kernel "$_img" && continue + + echo "$_img $(_parse_kver "$_img")" + done +} + +_setup_kernel_list() +{ + local _opt_kernel _opt_kver _img _kver _uname + + _opt_kernel="$1" + _opt_kver="$2" + + KDUMP_KERNEL_LIST=() + + # case: --kernel=<path to image> + if [[ -f "$_opt_kernel" ]]; then + _img="$1" + _kver=$(_parse_kver "$_img") + KDUMP_KERNEL_LIST[$_kver]=$_img + + # case: no --kernel= given. + # Also use this case for CoreOS to prevent the special cases DEFAULT + # and ALL. DEFAULT requires grubby which isn't available on CoreOS. + # ALL doesn't make sense as with CoreOS' A/B update scheme you should + # always only make changes to the current OS image. + elif [[ -z "$_opt_kernel" ]] || is_ostree; then + _uname=${_opt_kver:-"$(uname -r)"} + while read -r _img _kver; do + [[ "$_uname" == "$_kver" ]] || continue + KDUMP_KERNEL_LIST[$_kver]=$_img + break + done < <(_get_installed_kernel) + + # case: --kernel=ALL + elif [[ "$_opt_kernel" == ALL ]]; then + while read -r _img _kver; do + if [[ "$_kver" == UNKNOWN ]]; then + derror "Could not parse kernel version from '$_img'" + continue + fi + KDUMP_KERNEL_LIST[$_kver]=$_img + done < <(_get_installed_kernel) + return + + # case: --kernel=DEFAULT + elif [[ "$_opt_kernel" == DEFAULT ]]; then + if ! has_command grubby; then + derror "Special keyword DEFAULT requires grubby" + exit 1 + fi + _img=$(grubby --info=DEFAULT) + _img=${_img##*kernel="} + _img=${_img%%"*} + _kver=$(_parse_kver "$_img") + KDUMP_KERNEL_LIST[$_kver]=$_img + + else + derror "Invalid kernel image $2 provided" + exit 1 + fi + + if [[ -n "${KDUMP_KERNEL_LIST[UNKNOWN]}" ]]; then + if [[ -z "$_opt_kver" ]]; then + derror "Could not parse kernel version from ${KDUMP_KERNEL_LIST[UNKNOWN]}" + derror "Please provide it using the --kver option" + exit 1 + else + KDUMP_KERNEL_LIST[$_opt_kver]="${KDUMP_KERNEL_LIST[UNKNOWN]}" + unset 'KDUMP_KERNEL_LIST[UNKNOWN]' + fi + fi +} + main() { local func args @@ -1943,6 +2082,13 @@ main() _usage "Invalid kernel version $KDUMP_KERNELVER provided" fi
+ _init_systeminfo + _setup_kernel_list "${OPT[kernel]}" "$KDUMP_KERNELVER" + if [[ ${#KDUMP_KERNEL_LIST[@]} -eq 0 ]]; then + derror "Could not find any installed kernel" + exit 1 + fi + # Determine if the dump mode is kdump or fadump determine_dump_mode $func "$@"
With the new, global --kernel and --kver options both cases can be simplified to a point where they are almost identical. Merge them into a single pkg_upgrade_hook to simplify the CLI and have a more recognizable function naming.
While at it move the special handling for CoreOS from the spec file to the new hook so there is a single place with all exceptions.
Signed-off-by: Philipp Rudo prudo@redhat.com --- 92-crashkernel.install | 2 +- kdumpctl | 86 ++++++++---------------------------------- kexec-tools.spec | 11 +++--- 3 files changed, 22 insertions(+), 77 deletions(-)
diff --git a/92-crashkernel.install b/92-crashkernel.install index 19bd078..bd7c27e 100755 --- a/92-crashkernel.install +++ b/92-crashkernel.install @@ -7,7 +7,7 @@ KERNEL_IMAGE="$4"
case "$COMMAND" in add) - kdumpctl _reset-crashkernel-for-installed_kernel "$KERNEL_VERSION" + kdumpctl _pkg-upgrade-hook kernel --kver "$KERNEL_VERSION" exit 0 ;; esac diff --git a/kdumpctl b/kdumpctl index d77ee56..8090af3 100755 --- a/kdumpctl +++ b/kdumpctl @@ -39,9 +39,8 @@ cmds_global[showmem]=show_reserved_mem cmds_global[estimate]=do_estimate cmds_global[get-default-crashkernel]=get_default_crashkernel cmds_global[reset-crashkernel]=reset_crashkernel -cmds_global[_reset-crashkernel-after-update]=reset_crashkernel_after_update # shellcheck disable=SC2034 -cmds_global[_reset-crashkernel-for-installed_kernel]=reset_crashkernel_for_installed_kernel +cmds_global[_pkg-upgrade-hook]=pkg_upgrade_hook
# shellcheck disable=SC2034 opts_short_global="h" @@ -1670,27 +1669,6 @@ get_dump_mode_by_kernel() fi }
-_filter_grubby_kernel_str() -{ - local _grubby_kernel_str=$1 - echo -n "$_grubby_kernel_str" | sed -n -e 's/^kernel="(.*)"/\1/p' -} - -_find_kernel_path_by_release() -{ - local _release="$1" _grubby_kernel_str _kernel_path - - # Insert '/' before '+' to cope with grep's EREs - _release=${_release//+/\+} - _grubby_kernel_str=$(grubby --info ALL | grep -E "^kernel=.*$_release(/\w+)?"$") - _kernel_path=$(_filter_grubby_kernel_str "$_grubby_kernel_str") - if [[ -z $_kernel_path ]]; then - ddebug "kernel $_release doesn't exist" - return 1 - fi - echo -n "$_kernel_path" -} - _update_kernel_cmdline() { local _kernel _param _old _new @@ -1728,22 +1706,6 @@ _update_kernel_cmdline() fi }
-# return all the kernel paths given a grubby kernel-path -# -# $1: kernel path accepted by grubby, e.g. DEFAULT, ALL, -# /boot/vmlinuz-`uname -r` -# return: kernel paths separated by space -_get_all_kernels_from_grubby() -{ - local _kernels _line _kernel_path _grubby_kernel_path=$1 - - for _line in $(grubby --info "$_grubby_kernel_path" | grep "^kernel="); do - _kernel_path=$(_filter_grubby_kernel_str "$_line") - _kernels="$_kernels $_kernel_path" - done - echo -n "$_kernels" -} - reset_crashkernel() { local _kernel _dump_mode @@ -1838,23 +1800,6 @@ _update_crashkernel() fi }
-reset_crashkernel_after_update() -{ - local _kernel - - if [[ $(kdump_get_conf_val auto_reset_crashkernel) != yes ]]; then - return - fi - - if ! _is_bootloader_installed; then - return - fi - - for _kernel in $(_get_all_kernels_from_grubby ALL); do - _update_crashkernel "$_kernel" - done -} - # read the value of an environ variable from given environ file path # # The environment variable entries in /proc/[pid]/environ are separated @@ -1874,32 +1819,33 @@ _is_osbuild() [[ $(read_proc_environ_var container "$_OSBUILD_ENVIRON_PATH") == bwrap-osbuild ]] }
-reset_crashkernel_for_installed_kernel() +pkg_upgrade_hook() { - local _installed_kernel + local _pkg
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != yes ]]; then return fi
- # During package install, only try to reset crashkernel for osbuild - # thus to avoid calling grubby when installing os via anaconda - if ! _is_bootloader_installed && ! _is_osbuild; then - return - fi - - if ! _installed_kernel=$(_find_kernel_path_by_release "$1"); then - exit 1 - fi + _pkg=$1
- if _is_osbuild; then + if [[ $_pkg == kernel ]] && _is_osbuild; then if ! grep -qs crashkernel= /etc/kernel/cmdline; then - reset_crashkernel "--kernel=$_installed_kernel" + reset_crashkernel "--kernel=${KDUMP_KERNEL_LIST["$KDUMP_KERNELVER"]}" fi return + elif [[ $_pkg == kexec-tools ]]; then + # automatic handling of crashkernel is not supported on CoreOS + is_ostree && exit 0 fi
- _update_crashkernel "$_installed_kernel" + _is_bootloader_installed || return + + for KDUMP_KERNELVER in "${!KDUMP_KERNEL_LIST[@]}"; do + KDUMP_KERNEL="${KDUMP_KERNEL_LIST["$KDUMP_KERNELVER"]}" + _update_crashkernel "$KDUMP_KERNEL" + done + }
_init_systeminfo() diff --git a/kexec-tools.spec b/kexec-tools.spec index 2f4e4a6..f4327a1 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -320,12 +320,11 @@ done # Try to reset kernel crashkernel value to new default value or set up # crasherkernel value for new install # -# Note -# 1. Skip ostree systems as they are not supported. -# 2. For Fedora 36 and RHEL9, "[ $1 == 1 ]" in posttrans scriptlet means both install and upgrade; -# For Fedora > 36, "[ $1 == 1 ]" only means install and "[ $1 == 2 ]" means upgrade -if [ ! -f /run/ostree-booted ] && [ $1 == 1 -o $1 == 2 ]; then - kdumpctl _reset-crashkernel-after-update +# Note: For Fedora < 36 and RHEL9, "[ $1 == 1 ]" in posttrans scriptlet means +# both install and upgrade; For Fedora > 36, "[ $1 == 1 ]" only means +# install and "[ $1 == 2 ]" means upgrade +if [ $1 == 1 -o $1 == 2 ]; then + kdumpctl _pkg-upgrade-hook kexec-tools --kernel=ALL : fi
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdump-lib.sh | 6 ++++++ kdumpctl | 25 ++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index c2c7e26..cf83509 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -497,6 +497,12 @@ prepare_kdump_kernel() { local kdump_kernelver=$1 local dir img boot_dirlist boot_imglist kdump_kernel machine_id + + if [[ -n "$KDUMP_KERNEL" ]]; then + echo "$KDUMP_KERNEL" + return + fi + read -r machine_id < /etc/machine-id
boot_dirlist=${KDUMP_BOOTDIR:-"/boot /boot/efi /efi /"} diff --git a/kdumpctl b/kdumpctl index 8090af3..695142d 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1298,6 +1298,14 @@ __start()
_start() { + if [[ ${#KDUMP_KERNEL_LIST[@]} -ne 1 ]]; then + derror "Cannot use --kernel=ALL with command 'start'." + exit 1 + fi + + KDUMP_KERNELVER=${!KDUMP_KERNEL_LIST[0]} + KDUMP_KERNEL=${KDUMP_KERNEL_LIST[0]} + if ! __start; then derror "Starting kdump: [FAILED]" exit 1 @@ -1428,12 +1436,23 @@ _restart()
_rebuild() { + local _ret + parse_config || return 1 check_and_wait_network_ready || return 1
- setup_initrd || return 1 - - rebuild_initrd + for KDUMP_KERNELVER in "${!KDUMP_KERNEL_LIST[@]}"; do + KDUMP_KERNEL=${KDUMP_KERNEL_LIST[$KDUMP_KERNELVER]} + if ! setup_initrd; then + derror "Failed to setup initrd for $KDUMP_KERNEL" + _ret=1 + continue + fi + rebuild_initrd + _ret=$? + [[ $_ret -eq 0 ]] || break + done + return $_ret }
check_vmlinux()
Handy way to change KDUMP_STDLOGLVL without the need to edit the sysconfig.
While at it redirect the error message printed when dinit fails to stderr.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 35 +++++++++++++++++++++++++---------- kdumpctl.8.rst | 6 ++++++ 2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 695142d..6a15f1e 100755 --- a/kdumpctl +++ b/kdumpctl @@ -20,6 +20,7 @@ DEFAULT_DUMP_MODE="kdump" PROGNAME=${0##*/}
standard_kexec_args="-d -p" +KDUMP_STDLOGLVL=3
# Some default values in case /etc/sysconfig/kdump doesn't include KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug" @@ -43,12 +44,14 @@ cmds_global[reset-crashkernel]=reset_crashkernel cmds_global[_pkg-upgrade-hook]=pkg_upgrade_hook
# shellcheck disable=SC2034 -opts_short_global="h" +opts_short_global="hqv" # shellcheck disable=SC2034 opts_long_global=( --long "help" --long "kernel:" --long "kver:" + --long "quiet" + --long "verbose" )
parse_args_global() @@ -66,6 +69,16 @@ parse_args_global() KDUMP_KERNELVER="$2" return 2 ;; + -q|--quiet) + KDUMP_STDLOGLVL=0 + return 1 + ;; + -v|--verbose) + if [[ $KDUMP_STDLOGLVL -lt 4 ]]; then + (( KDUMP_STDLOGLVL += 1 )) + fi + return 1 + ;; esac }
@@ -116,12 +129,6 @@ fi # shellcheck source=./kdump-logger.sh . $KDUMP_LIB_PATH/kdump-logger.sh
-#initiate the kdump logger -if ! dlog_init; then - echo "failed to initiate the kdump logger." - exit 1 -fi - KDUMP_TMPDIR=$(mktemp --tmpdir -d kdump.XXXX) trap ' ret=$?; @@ -160,6 +167,8 @@ Options: Specifies the kernel version to use. This option is only required if the version cannot be determined from the filename provided by the --kernel option. + -q, --quiet Supress logging to console. Equivalent to KDUMP_STDLOGLVL=0. + -v, --verbose Increase verbosity for logging to console.
Options for reset-crashkernel: --fadump [on|off|nocma] @@ -347,7 +356,7 @@ single_instance_lock() fi
if ! exec 9> $lockfile; then - derror "Create file lock failed" + echo "Create file lock failed" >&2 exit 1 fi
@@ -355,7 +364,7 @@ single_instance_lock() rc=$?
while [[ $rc -ne 0 ]]; do - dinfo "Another app is currently holding the kdump lock; waiting for it to exit..." + echo "Another app is currently holding the kdump lock; waiting for it to exit..." flock -w $timeout 9 rc=$? done @@ -2035,6 +2044,12 @@ main() parse_args global func args "$@" eval set -- "$args"
+ #initiate the kdump logger + if ! dlog_init; then + echo "failed to initiate the kdump logger." >&2 + exit 1 + fi + if [[ -z "$func" ]]; then if [[ -z "$1" ]]; then _usage "No command provided." @@ -2064,7 +2079,7 @@ if [[ ${__SOURCED__:+x} ]]; then fi
if [[ ! -f $KDUMP_CONFIG_FILE ]]; then - derror "Error: No kdump config file found!" + echo "Error: No kdump config file found!" >&2 exit 1 fi
diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst index 58e7dfa..3cf18db 100644 --- a/kdumpctl.8.rst +++ b/kdumpctl.8.rst @@ -111,6 +111,12 @@ Global Options option. Otherwise the version determined from the filename will take precedence.
+-q, --quiet + Suppress logging to console. Equivalent to KDUMP_STDLOGLVL=0. + +-v, --verbose + Increase verbosity for logging to console. + Options for reset-crashkernel -----------------------------
'status' currently only translates the content of /sys/kernel/kexec_crash_loaded (or /sys/kernel/fadump_registered) to a string which is only mildly helpful. Thus extend the information printed with some more status information like the dump mode and size of the reserved crashkernel memory. Furthermore, add warnings for typical problems that occur regularly.
This patch makes 'showmem' obsolete and removes it.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 52 +++++++++++++++++++++++++++++++++----------------- kdumpctl.8.rst | 3 --- 2 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 6a15f1e..2009eb7 100755 --- a/kdumpctl +++ b/kdumpctl @@ -36,7 +36,6 @@ cmds_global[reload]=_reload cmds_global[restart]=_restart cmds_global[rebuild]=_rebuild cmds_global[propagate]=propagate_ssh_key -cmds_global[showmem]=show_reserved_mem cmds_global[estimate]=do_estimate cmds_global[get-default-crashkernel]=get_default_crashkernel cmds_global[reset-crashkernel]=reset_crashkernel @@ -1093,17 +1092,6 @@ propagate_ssh_key() fi }
-show_reserved_mem() -{ - local mem - local mem_mb - - mem=$(< /sys/kernel/kexec_crash_size) - mem_mb=$((mem / 1024 / 1024)) - - dinfo "Reserved ${mem_mb}MB memory for crash kernel" -} - save_raw() { local raw_target @@ -1323,19 +1311,47 @@ _start()
_status() { - EXIT_CODE=0 + local _ret _i + local _ck_loaded _ck_mem + + local -a _units=( "Bytes" "KB" "MB" "GB" ) + + _ret=0 + is_kernel_loaded "$DEFAULT_DUMP_MODE" case "$?" in 0) - dinfo "Kdump is operational" - EXIT_CODE=0 + _ck_loaded=true + _ret=0 ;; 1) - dinfo "Kdump is not operational" - EXIT_CODE=3 + _ck_loaded=false + _ret=3 ;; esac - exit $EXIT_CODE + + _ck_mem=$(< /sys/kernel/kexec_crash_size) + if [[ $_ck_mem -gt 0 ]]; then + while [[ $(( _ck_mem / 1024 )) -gt 0 ]]; do + (( _ck_mem /= 1024 )) + (( _i += 1 )) + done + _ck_mem+=" ${_units[_i]}" + else + _ck_mem="None" + fi + + cat << EOF | dinfo +Dump mode: $DEFAULT_DUMP_MODE +Crashkernel loaded: $_ck_loaded +Memory reserved: $_ck_mem +EOF + + parse_config || exit $_ret + if ! check_and_wait_network_ready &> /dev/null; then + dwarn "Warning: Remote host not reachable. Please verify your network connection and check if you have propagated your SSH key." + fi + exit $_ret }
_reload() diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst index 3cf18db..5700f2b 100644 --- a/kdumpctl.8.rst +++ b/kdumpctl.8.rst @@ -55,9 +55,6 @@ status Prints the current status of kdump. Returns zero if kdump is operational, nonzero otherwise.
-showmem - Prints the size of reserved crash kernel memory in Megabytes. - propagate Helper to setup key authentication for ssh dump targets.
The function is pretty simple and only used in the upgrade hook. So move it in there.
While at it make sure that the message printed is consistent with the one in reset_crashkernel. Furthermore, only ask for reboot once and only when the currently running kernel was updated.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 65 ++++++++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 37 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 2009eb7..e664d10 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1715,7 +1715,7 @@ get_dump_mode_by_kernel()
_update_kernel_cmdline() { - local _kernel _param _old _new + local _kernel _param _old _new _has_changed
_kernel="$1" _param="$2" @@ -1728,22 +1728,29 @@ _update_kernel_cmdline() if is_ostree; then if [[ -z "$_new" ]]; then rpm-ostree kargs --delete="$_param=$_old" + _has_changed="Added $_param=$_new" elif [[ -n "$_old" ]]; then rpm-ostree kargs --replace="$_param=$_new" + _has_changed="Updated $_param=$_new" else rpm-ostree kargs --append="$_param=$_new" + _has_changed="Removed $_param=$_new" fi elif has_command grubby; then if [[ -n "$_new" ]]; then grubby --update-kernel "$_kernel" --args "$_param=$_new" + _has_changed="Updated $_param=$_new" else grubby --update-kernel "$_kernel" --remove-args "$_param" + _has_changed="Removed $_param=$_new" fi else derror "Unable to update kernel command line" exit 1 fi
+ dwarn "$_has_changed for kernel=$_kernel." + # Don't use "[[ CONDITION ]] && COMMAND" which returns 1 under false CONDITION if [[ -f /etc/zipl.conf ]]; then zipl > /dev/null @@ -1752,8 +1759,7 @@ _update_kernel_cmdline()
reset_crashkernel() { - local _kernel _dump_mode - local _has_changed _needs_reboot + local _kernel _needs_reboot _dump_mode local _old_ck _new_ck local _old_fadump _new_fadump local func args @@ -1778,7 +1784,6 @@ reset_crashkernel() fi
for _kernel in "${KDUMP_KERNEL_LIST[@]}"; do - _has_changed="" if [[ $(uname -m) == ppc64le ]]; then if [[ -n "${OPT[fadump]}" ]]; then _dump_mode=$(get_dump_mode_by_fadump_val "${OPT[fadump]}") @@ -1787,11 +1792,7 @@ reset_crashkernel() _new_fadump="${OPT[fadump]}" [[ "$_new_fadump" == off ]] && _new_fadump="" if _update_kernel_cmdline "$_kernel" fadump "$_old_fadump" "$_new_fadump"; then - if [[ -n "$_new_fadump" ]]; then - _has_changed="Updated fadump=$_new_fadump" - else - _has_changed="Removed fadump" - fi + [[ $(uname -r) == "$KDUMP_KERNELVER" ]] && _needs_reboot=1 fi else _dump_mode="$(get_dump_mode_by_kernel "$_kernel")" @@ -1803,16 +1804,16 @@ reset_crashkernel()
_old_ck=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) if _update_kernel_cmdline "$_kernel" crashkernel "$_old_ck" "$_new_ck"; then - _has_changed="Updated crashkernel=$_new_ck" - fi - if [[ -n "$_has_changed" ]]; then - _needs_reboot=1 - dwarn "$_has_changed for kernel=$_kernel. Please reboot the system for the change to take effect." + [[ $(uname -r) == "$KDUMP_KERNELVER" ]] && _needs_reboot=1 fi done
- if [[ ${OPT[reboot]} == yes && $_needs_reboot == 1 ]]; then - systemctl reboot + if [[ $_needs_reboot == 1 ]]; then + if [[ ${OPT[reboot]} == yes ]]; then + systemctl reboot + else + dwarn "Please reboot the system for the change to take effect." + fi fi }
@@ -1826,24 +1827,6 @@ _is_bootloader_installed() fi }
-_update_crashkernel() -{ - local _kernel _kver _dump_mode _msg - local _old_ck _new_ck - - _kernel=$1 - _dump_mode=$(get_dump_mode_by_kernel "$_kernel") - _old_ck=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) - _kver=$(parse_kver_from_path "$_kernel") - # The second argument is for the case of aarch64, where installing a 64k variant on a 4k kernel, or vice versa - _new_ck=$(kdump_get_arch_recommend_crashkernel "$_dump_mode" "$_kver") - if _update_kernel_cmdline "$_kernel" crashkernel "$_old_ck" "$_new_ck"; then - _msg="For kernel=$_kernel, crashkernel=$_new_ck now. Please reboot the system for the change to take effect." - _msg+=" Note if you don't want kexec-tools to manage the crashkernel kernel parameter, please set auto_reset_crashkernel=no in /etc/kdump.conf." - dinfo "$_msg" - fi -} - # read the value of an environ variable from given environ file path # # The environment variable entries in /proc/[pid]/environ are separated @@ -1865,7 +1848,7 @@ _is_osbuild()
pkg_upgrade_hook() { - local _pkg + local _pkg _old_ck _new_ck _mode _needs_reboot
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != yes ]]; then return @@ -1887,9 +1870,17 @@ pkg_upgrade_hook()
for KDUMP_KERNELVER in "${!KDUMP_KERNEL_LIST[@]}"; do KDUMP_KERNEL="${KDUMP_KERNEL_LIST["$KDUMP_KERNELVER"]}" - _update_crashkernel "$KDUMP_KERNEL" + _old_ck=$(get_grub_kernel_boot_parameter "$KDUMP_KERNEL" crashkernel) + _mode=$(get_dump_mode_by_kernel "$KDUMP_KERNEL") + _new_ck=$(kdump_get_arch_recommend_crashkernel "$_mode" "$KDUMP_KERNELVER") + if _update_kernel_cmdline "$KDUMP_KERNEL" crashkernel "$_old_ck" "$_new_ck"; then + [[ $(uname -r) == "$KDUMP_KERNELVER" ]] && _needs_reboot=1 + fi done - + if [[ $_needs_reboot == 1 ]]; then + dwarn "Please reboot the system for the change to take effect." + fi + dinfo "Note if you don't want kexec-tools to manage the crashkernel kernel parameter, please set auto_reset_crashkernel=no in /etc/kdump.conf." }
_init_systeminfo()
The only reason why there is still the need to special handle CoreOS in reset_crashkernel is parsing the crashkernel= parameter from the command line. Thus rename get_grub_kernel_boot_parameter to _get_kernel_cmdline_parameter and make it work for CoreOS as well. With this the special handling can be removed.
With the new _get_kernel_cmdline_parameter there is now a runtime check whether grubby is installed before every call to grubby. So we can also remove the weak dependency on grubby in the spec file.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 69 ++++++++++++++++++++++++++---------------------- kexec-tools.spec | 1 - 2 files changed, 38 insertions(+), 32 deletions(-)
diff --git a/kdumpctl b/kdumpctl index e664d10..31d1d51 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1668,17 +1668,6 @@ get_default_crashkernel() kdump_get_arch_recommend_crashkernel "$_dump_mode" }
-# Read kernel cmdline parameter for a specific kernel -# $1: kernel path, DEFAULT or kernel path, ALL not accepted -# $2: kernel cmldine parameter -get_grub_kernel_boot_parameter() -{ - local _kernel_path=$1 _para=$2 - - [[ $_kernel_path == ALL ]] && derror "kernel_path=ALL invalid for get_grub_kernel_boot_parameter" && return 1 - grubby --info="$_kernel_path" | sed -En -e "/^args=.*$/{s/^.*(\s|")${_para}=(\S*).*"$/\2/p;q}" -} - # get dump mode by fadump value # return # - fadump, if fadump=on or fadump=nocma @@ -1704,7 +1693,7 @@ get_dump_mode_by_kernel() { local _kernel_path=$1 _fadump_val _dump_mode
- _fadump_val=$(get_grub_kernel_boot_parameter "$_kernel_path" fadump) + _fadump_val=$(_get_kernel_cmdline_parameter "$_kernel_path" fadump) if _dump_mode=$(get_dump_mode_by_fadump_val "$_fadump_val"); then echo -n "$_dump_mode" else @@ -1713,6 +1702,36 @@ get_dump_mode_by_kernel() fi }
+_get_kernel_cmdline_parameter() +{ + local _kernel _param _cmdline _ret + + _kernel="$1" + _param="$2" + + if is_ostree; then + _cmdline="$(rpm-ostree kargs)" + elif has_command grubby; then + _cmdline="$(grubby --info="$_kernel")" + _cmdline="${_cmdline##*args="}" + _cmdline="${_cmdline%%"*}" + else + derror "Unable to get kernel command line" + fi + + ddebug "command line for kernel $_kernel is '$_cmdline'" + + # make sure there is a space before/after the parameter + _cmdline=" $_cmdline " + if [[ $_cmdline == *" $_param="* ]]; then + _ret=${_cmdline##*"$_param"=} + _ret=${_ret%% *} + echo "$_ret" + elif [[ $_cmdline == *" $_param "* ]];then + echo "$_param" + fi +} + _update_kernel_cmdline() { local _kernel _param _old _new _has_changed @@ -1768,27 +1787,12 @@ reset_crashkernel() _usage "Additional parameter '$1' provided." fi
- # 1. OSTree systems use "rpm-ostree kargs" instead of grubby to manage kernel command - # line. --kernel=ALL doesn't make sense for OStree. - # 2. We don't have any OSTree POWER systems so the dump mode is always kdump. - # 3. "rpm-ostree kargs" would prompt the user to reboot the system after - # modifying the kernel command line so there is no need for kexec-tools - # to repeat it. - if is_ostree; then - _old_ck=$(rpm-ostree kargs | sed -n -E 's/.*(^|\s)crashkernel=(\S*).*/\2/p') - _new_ck=$(kdump_get_arch_recommend_crashkernel kdump) - if _update_kernel_cmdline "" crashkernel "$_old_ck" "$_new_ck"; then - [[ ${OPT[reboot]} == yes ]] && systemctl reboot - fi - return - fi - for _kernel in "${KDUMP_KERNEL_LIST[@]}"; do if [[ $(uname -m) == ppc64le ]]; then if [[ -n "${OPT[fadump]}" ]]; then _dump_mode=$(get_dump_mode_by_fadump_val "${OPT[fadump]}") _new_ck=$(kdump_get_arch_recommend_crashkernel "$_dump_mode") - _old_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump) + _old_fadump=$(_get_kernel_cmdline_parameter "$_kernel" fadump) _new_fadump="${OPT[fadump]}" [[ "$_new_fadump" == off ]] && _new_fadump="" if _update_kernel_cmdline "$_kernel" fadump "$_old_fadump" "$_new_fadump"; then @@ -1802,7 +1806,7 @@ reset_crashkernel() _new_ck=$(kdump_get_arch_recommend_crashkernel kdump) fi
- _old_ck=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) + _old_ck=$(_get_kernel_cmdline_parameter "$_kernel" crashkernel) if _update_kernel_cmdline "$_kernel" crashkernel "$_old_ck" "$_new_ck"; then [[ $(uname -r) == "$KDUMP_KERNELVER" ]] && _needs_reboot=1 fi @@ -1811,7 +1815,10 @@ reset_crashkernel() if [[ $_needs_reboot == 1 ]]; then if [[ ${OPT[reboot]} == yes ]]; then systemctl reboot - else + + # "rpm-ostree kargs" already asked the user to reboot after + # modifying the kernel command line. No need to repeat it. + elif ! is_ostree; then dwarn "Please reboot the system for the change to take effect." fi fi @@ -1870,7 +1877,7 @@ pkg_upgrade_hook()
for KDUMP_KERNELVER in "${!KDUMP_KERNEL_LIST[@]}"; do KDUMP_KERNEL="${KDUMP_KERNEL_LIST["$KDUMP_KERNELVER"]}" - _old_ck=$(get_grub_kernel_boot_parameter "$KDUMP_KERNEL" crashkernel) + _old_ck=$(_get_kernel_cmdline_parameter "$KDUMP_KERNEL" crashkernel) _mode=$(get_dump_mode_by_kernel "$KDUMP_KERNEL") _new_ck=$(kdump_get_arch_recommend_crashkernel "$_mode" "$KDUMP_KERNELVER") if _update_kernel_cmdline "$KDUMP_KERNEL" crashkernel "$_old_ck" "$_new_ck"; then diff --git a/kexec-tools.spec b/kexec-tools.spec index f4327a1..66dae29 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -69,7 +69,6 @@ Requires: ethtool Requires: util-linux # Needed for UKI support Recommends: binutils -Recommends: grubby Recommends: hostname BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel
All callers of _update_kernel_cmdline determine the "old" value right before the call via _get_kernel_cmdline_parameter. All the information needed to do this call are available in _update_kernel_cmdline. So move the call there to reduce some redundant code.
While at it drop the "new" from the variable names in the callers. Just to make the name a tad shorter.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 31d1d51..d8d0992 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1738,8 +1738,9 @@ _update_kernel_cmdline()
_kernel="$1" _param="$2" - _old="$3" - _new="$4" + _new="$3" + + _old="$(_get_kernel_cmdline_parameter "$_kernel" "$_param")"
# _new = "" removes a _param, so _new = _old = "" is fine [[ -n "$_new" ]] && [[ "$_old" == "$_new" ]] && return 1 @@ -1778,10 +1779,8 @@ _update_kernel_cmdline()
reset_crashkernel() { - local _kernel _needs_reboot _dump_mode - local _old_ck _new_ck - local _old_fadump _new_fadump - local func args + local _opts _kernel _needs_reboot + local _mode _ck _fadump
if [[ -n "$1" ]]; then _usage "Additional parameter '$1' provided." @@ -1790,24 +1789,21 @@ reset_crashkernel() for _kernel in "${KDUMP_KERNEL_LIST[@]}"; do if [[ $(uname -m) == ppc64le ]]; then if [[ -n "${OPT[fadump]}" ]]; then - _dump_mode=$(get_dump_mode_by_fadump_val "${OPT[fadump]}") - _new_ck=$(kdump_get_arch_recommend_crashkernel "$_dump_mode") - _old_fadump=$(_get_kernel_cmdline_parameter "$_kernel" fadump) - _new_fadump="${OPT[fadump]}" - [[ "$_new_fadump" == off ]] && _new_fadump="" - if _update_kernel_cmdline "$_kernel" fadump "$_old_fadump" "$_new_fadump"; then + _mode=$(get_dump_mode_by_fadump_val "${OPT[fadump]}") + _fadump="${OPT[fadump]}" + [[ "$_fadump" == off ]] && _fadump="" + if _update_kernel_cmdline "$_kernel" fadump "$_fadump"; then [[ $(uname -r) == "$KDUMP_KERNELVER" ]] && _needs_reboot=1 fi else - _dump_mode="$(get_dump_mode_by_kernel "$_kernel")" - _new_ck=$(kdump_get_arch_recommend_crashkernel "$_dump_mode") + _mode="$(get_dump_mode_by_kernel "$_kernel")" fi else - _new_ck=$(kdump_get_arch_recommend_crashkernel kdump) + _mode=kdump fi
- _old_ck=$(_get_kernel_cmdline_parameter "$_kernel" crashkernel) - if _update_kernel_cmdline "$_kernel" crashkernel "$_old_ck" "$_new_ck"; then + _ck=$(kdump_get_arch_recommend_crashkernel "$_mode") + if _update_kernel_cmdline "$_kernel" crashkernel "$_ck"; then [[ $(uname -r) == "$KDUMP_KERNELVER" ]] && _needs_reboot=1 fi done @@ -1855,7 +1851,7 @@ _is_osbuild()
pkg_upgrade_hook() { - local _pkg _old_ck _new_ck _mode _needs_reboot + local _pkg _ck _mode _needs_reboot
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != yes ]]; then return @@ -1877,10 +1873,9 @@ pkg_upgrade_hook()
for KDUMP_KERNELVER in "${!KDUMP_KERNEL_LIST[@]}"; do KDUMP_KERNEL="${KDUMP_KERNEL_LIST["$KDUMP_KERNELVER"]}" - _old_ck=$(_get_kernel_cmdline_parameter "$KDUMP_KERNEL" crashkernel) _mode=$(get_dump_mode_by_kernel "$KDUMP_KERNEL") - _new_ck=$(kdump_get_arch_recommend_crashkernel "$_mode" "$KDUMP_KERNELVER") - if _update_kernel_cmdline "$KDUMP_KERNEL" crashkernel "$_old_ck" "$_new_ck"; then + _ck=$(kdump_get_arch_recommend_crashkernel "$_mode" "$KDUMP_KERNELVER") + if _update_kernel_cmdline "$KDUMP_KERNEL" crashkernel "$_ck"; then [[ $(uname -r) == "$KDUMP_KERNELVER" ]] && _needs_reboot=1 fi done
Introduce the new command 'crashkernel' and its subcommand 'show'. The 'crashkernel' command is will be used for all subcommands to manage the crashkernel= value on the kernel command line. The default subcommand is 'show', which simply prints the currently set crashkernel= value to stdout.
'crashkernel' accepts two options, (1) --default to print the recommended default value instead and (2) --fadump to use a specific fadump mode when determining the recommended default value.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 60 ++++++++++++++++++++++++++++++++++++++++++++++---- kdumpctl.8.rst | 23 +++++++++++++++++-- 2 files changed, 77 insertions(+), 6 deletions(-)
diff --git a/kdumpctl b/kdumpctl index d8d0992..07f42e2 100755 --- a/kdumpctl +++ b/kdumpctl @@ -37,7 +37,7 @@ cmds_global[restart]=_restart cmds_global[rebuild]=_rebuild cmds_global[propagate]=propagate_ssh_key cmds_global[estimate]=do_estimate -cmds_global[get-default-crashkernel]=get_default_crashkernel +cmds_global[crashkernel]=_crashkernel_show cmds_global[reset-crashkernel]=reset_crashkernel # shellcheck disable=SC2034 cmds_global[_pkg-upgrade-hook]=pkg_upgrade_hook @@ -107,6 +107,37 @@ parse_args_reset_crashkernel() esac }
+declare -A cmds_crashkernel +cmds_crashkernel=() +# shellcheck disable=SC2034 +cmds_crashkernel[show]=_crashkernel_show + +# shellcheck disable=SC2034 +opts_short_crashkernel="" +# shellcheck disable=SC2034 +opts_long_crashkernel=( + --long "default" + --long "fadump:" +) + +parse_args_crashkernel() +{ + case $1 in + --default) + OPT[default]=yes + return 1 + ;; + --fadump) + if [[ $(uname -a) != ppc64le ]]; then + derror "Option --fadump only valid on PPC" + exit 1 + fi + OPT[fadump]="$2" + return 2 + ;; + esac +} + # Only do the bare minimum when sourced during bash completion [[ ${COMP_LINE:+x} ]] && return
@@ -169,6 +200,11 @@ Options: -q, --quiet Supress logging to console. Equivalent to KDUMP_STDLOGLVL=0. -v, --verbose Increase verbosity for logging to console.
+Options for crashkernel: + --default Use the recommended default value instead. + --fadump on|off|nocma + Set the mode FADump (only valid for PPC). + Options for reset-crashkernel: --fadump [on|off|nocma] The mode fadump should run in (only valid for PPC). @@ -181,6 +217,7 @@ Common commands: restart Equivalent to stop; start rebuild Force rebuild the kdump initramfs propagate Setup key authentication for ssh dump targets + crashkernel Manage the crashkernel parameter on the kernel command line. reset-crashkernel Reset the crashkernel parameter to its default value
@@ -1661,11 +1698,26 @@ do_estimate() fi }
-get_default_crashkernel() +_crashkernel_show() { - local _dump_mode=$1 + local _kernel _kver _mode _ck + + for _kver in "${!KDUMP_KERNEL_LIST[@]}"; do + _kernel="${KDUMP_KERNEL_LIST[$_kver]}"
- kdump_get_arch_recommend_crashkernel "$_dump_mode" + if [[ ${OPT[default]} == yes ]]; then + if [[ -n "${OPT[fadump]}" ]]; then + _mode="$(get_dump_mode_by_fadump_val "${OPT[fadump]}")" + else + _mode="$(get_dump_mode_by_kernel "$_kernel")" + fi + _ck="$(kdump_get_arch_recommend_crashkernel "$_mode" "$_kver")" + else + _ck="$(_get_kernel_cmdline_parameter "$_kernel" crashkernel)" + fi + + echo "$_kernel $_ck" + done }
# get dump mode by fadump value diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst index 5700f2b..cbe9c44 100644 --- a/kdumpctl.8.rst +++ b/kdumpctl.8.rst @@ -68,8 +68,9 @@ estimate work for your specific setup. Always test if kdump works after changing the crashkernel parameter on the kernel command line.
-get-default-crashkernel - Return the default crashkernel value provided by kexec-tools. +crashkernel *[COMMAND]* + Manage the crashkernel parameter on the kernel command line. Default command + is **show**.
reset-crashkernel *[OPTIONS]* Set the value of the crashkernel parameter on the kernel command line to a @@ -82,6 +83,15 @@ reset-crashkernel *[OPTIONS]* work for your specific setup. Always test if kdump works after changing the crashkernel parameter on the kernel command line.
+Commands to crashkernel +----------------------- + +show [--default [--fadump=[on|off|nocma]]] + Print the current value the crashkernel parameter on the kernel command line + is set to. If option **--default** is given print the recommended default + value instead. Use option **--fadump** to print the recommended default value + for the given FADump mode (only valid for PPC). +
OPTIONS ======= @@ -114,6 +124,15 @@ Global Options -v, --verbose Increase verbosity for logging to console.
+Options for crashkernel +----------------------- + +--default + Use the recommended default value instead. + +--fadump [on|off|nocma] + Set the mode for FADump (only valid on PPC). + Options for reset-crashkernel -----------------------------
Introduce a new subcommand 'set' to the 'crashkernel' command. Syntax for the new subcommand is
kdumpctl crashkernel set (--default|<size>)
As the name suggests the new subcommand then updates the crashkernel= parameter to the provided <size> or our recommended default value. With this the 'reset-crashkernel' command is no longer needed and can be removed.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 147 +++++++++++++++++++++++-------------------------- kdumpctl.8.rst | 27 ++++----- 2 files changed, 81 insertions(+), 93 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 07f42e2..6e8d5f8 100755 --- a/kdumpctl +++ b/kdumpctl @@ -38,7 +38,6 @@ cmds_global[rebuild]=_rebuild cmds_global[propagate]=propagate_ssh_key cmds_global[estimate]=do_estimate cmds_global[crashkernel]=_crashkernel_show -cmds_global[reset-crashkernel]=reset_crashkernel # shellcheck disable=SC2034 cmds_global[_pkg-upgrade-hook]=pkg_upgrade_hook
@@ -81,34 +80,9 @@ parse_args_global() esac }
-# shellcheck disable=SC2034 -opts_short_reset_crashkernel="" -# shellcheck disable=SC2034 -opts_long_reset_crashkernel=( - --long "fadump:" - --long "reboot" -) - -parse_args_reset_crashkernel() -{ - case $1 in - --fadump) - if [[ $(uname -a) != ppc64le ]]; then - derror "Option --fadump only valid on PPC" - exit 1 - fi - OPT[fadump]="$2" - return 2 - ;; - --reboot) - OPT[reboot]=yes - return 1 - ;; - esac -} - declare -A cmds_crashkernel cmds_crashkernel=() +cmds_crashkernel[set]=_crashkernel_set # shellcheck disable=SC2034 cmds_crashkernel[show]=_crashkernel_show
@@ -138,6 +112,23 @@ parse_args_crashkernel() esac }
+# shellcheck disable=SC2034 +opts_short_crashkernel_set="" +# shellcheck disable=SC2034 +opts_long_crashkernel_set=( + --long "reboot" +) + +parse_args_crashkernel_set() +{ + case $1 in + --reboot) + OPT[reboot]=yes + return 1 + ;; + esac +} + # Only do the bare minimum when sourced during bash completion [[ ${COMP_LINE:+x} ]] && return
@@ -202,12 +193,8 @@ Options:
Options for crashkernel: --default Use the recommended default value instead. - --fadump on|off|nocma - Set the mode FADump (only valid for PPC). - -Options for reset-crashkernel: --fadump [on|off|nocma] - The mode fadump should run in (only valid for PPC). + Set the mode FADump (only valid for PPC). --reboot Automatically reboot if the kernel command line changed.
Common commands: @@ -218,8 +205,6 @@ Common commands: rebuild Force rebuild the kdump initramfs propagate Setup key authentication for ssh dump targets crashkernel Manage the crashkernel parameter on the kernel command line. - reset-crashkernel - Reset the crashkernel parameter to its default value
See 'man $PROGNAME' for more details and the full list of commands. EOF @@ -1698,6 +1683,57 @@ do_estimate() fi }
+_crashkernel_set() +{ + local _kernel _kver _ck_arg _ck _fadump _needs_reboot + + _ck_arg=$1 + + if [[ -z "$_ck_arg" ]] && [[ -z "${OPT[default]}" ]]; then + derror "You need to provide either a value or --default" + exit 1 + # Verify that _ck_arg has the correct syntax by adding 0 + elif [[ -n "$_ck_arg" ]] && ! _crashkernel_add "$_ck_arg" 0 > /dev/null; then + derror "Invalid syntax in '$_ck_arg'" + exit 1 + fi + + + for _kver in "${!KDUMP_KERNEL_LIST[@]}"; do + _kernel="${KDUMP_KERNEL_LIST[$_kver]}" + + if [[ -n "${OPT[fadump]}" ]]; then + _mode="$(get_dump_mode_by_fadump_val "${OPT[fadump]}")" + else + _mode="$(get_dump_mode_by_kernel "$_kernel")" + fi + + _ck="${_ck_arg:-$(kdump_get_arch_recommend_crashkernel "$_mode" "$_kver")}" + if _update_kernel_cmdline "$_kernel" crashkernel "$_ck"; then + [[ $(uname -r) == "$_kver" ]] && _needs_reboot=1 + fi + + if [[ -n "${OPT[fadump]}" ]]; then + _fadump="${OPT[fadump]}" + [[ $_fadump == off ]] && _fadump="" + if _update_kernel_cmdline "$_kernel" fadump "$_fadump"; then + [[ $(uname -r) == "$_kver" ]] && _needs_reboot=1 + fi + fi + done + + if [[ $_needs_reboot == 1 ]]; then + if [[ ${OPT[reboot]} == yes ]]; then + derror "systemctl reboot" + + # "rpm-ostree kargs" already asked the user to reboot after + # modifying the kernel command line. No need to repeat it. + elif ! is_ostree; then + dwarn "Please reboot the system for the change to take effect." + fi + fi +} + _crashkernel_show() { local _kernel _kver _mode _ck @@ -1829,49 +1865,6 @@ _update_kernel_cmdline() fi }
-reset_crashkernel() -{ - local _opts _kernel _needs_reboot - local _mode _ck _fadump - - if [[ -n "$1" ]]; then - _usage "Additional parameter '$1' provided." - fi - - for _kernel in "${KDUMP_KERNEL_LIST[@]}"; do - if [[ $(uname -m) == ppc64le ]]; then - if [[ -n "${OPT[fadump]}" ]]; then - _mode=$(get_dump_mode_by_fadump_val "${OPT[fadump]}") - _fadump="${OPT[fadump]}" - [[ "$_fadump" == off ]] && _fadump="" - if _update_kernel_cmdline "$_kernel" fadump "$_fadump"; then - [[ $(uname -r) == "$KDUMP_KERNELVER" ]] && _needs_reboot=1 - fi - else - _mode="$(get_dump_mode_by_kernel "$_kernel")" - fi - else - _mode=kdump - fi - - _ck=$(kdump_get_arch_recommend_crashkernel "$_mode") - if _update_kernel_cmdline "$_kernel" crashkernel "$_ck"; then - [[ $(uname -r) == "$KDUMP_KERNELVER" ]] && _needs_reboot=1 - fi - done - - if [[ $_needs_reboot == 1 ]]; then - if [[ ${OPT[reboot]} == yes ]]; then - systemctl reboot - - # "rpm-ostree kargs" already asked the user to reboot after - # modifying the kernel command line. No need to repeat it. - elif ! is_ostree; then - dwarn "Please reboot the system for the change to take effect." - fi - fi -} - GRUB_CFG=/boot/grub2/grub.cfg _is_bootloader_installed() { diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst index cbe9c44..c83e9d0 100644 --- a/kdumpctl.8.rst +++ b/kdumpctl.8.rst @@ -72,20 +72,15 @@ crashkernel *[COMMAND]* Manage the crashkernel parameter on the kernel command line. Default command is **show**.
-reset-crashkernel *[OPTIONS]* - Set the value of the crashkernel parameter on the kernel command line to a - recommended default. The system needs to reboot for the change to take - effect. - - .. note:: The memory requirements for kdump varies heavily depending on the - used hardware and system configuration and cannot be predicted - acurately. Thus the recommanded crash kernel memory size might not - work for your specific setup. Always test if kdump works after - changing the crashkernel parameter on the kernel command line. - Commands to crashkernel -----------------------
+set [--reboot] [--default|\ *size*] + Set the crashkernel parameter on the kernel command line to *size*. If option + **--default** is provided set it to the recommended default value instead. + Please see *Documentation/admin-guide/kernel-parameters.txt* in the kernel + tree for details on the syntax used for the crashkernel parameter. + show [--default [--fadump=[on|off|nocma]]] Print the current value the crashkernel parameter on the kernel command line is set to. If option **--default** is given print the recommended default @@ -130,11 +125,11 @@ Options for crashkernel --default Use the recommended default value instead.
---fadump [on|off|nocma] - Set the mode for FADump (only valid on PPC). - -Options for reset-crashkernel ------------------------------ + .. note:: The memory requirements for kdump varies heavily depending on the + used hardware and system configuration and cannot be predicted + acurately. Thus the recommanded crash kernel memory size might not + work for your specific setup. Always test if kdump works after + changing the crashkernel parameter on the kernel command line.
--fadump [on|off|nocma] Set the mode for FADump (only valid on PPC).
In order to make the interface more consistent move all commands that help managing the crashkernel parameter on the command line to the 'crashkernel' command. For that make the 'estimate' command a subcommand of 'crashkernel'.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 4 ++-- kdumpctl.8.rst | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 6e8d5f8..77737c8 100755 --- a/kdumpctl +++ b/kdumpctl @@ -36,7 +36,6 @@ cmds_global[reload]=_reload cmds_global[restart]=_restart cmds_global[rebuild]=_rebuild cmds_global[propagate]=propagate_ssh_key -cmds_global[estimate]=do_estimate cmds_global[crashkernel]=_crashkernel_show # shellcheck disable=SC2034 cmds_global[_pkg-upgrade-hook]=pkg_upgrade_hook @@ -82,6 +81,7 @@ parse_args_global()
declare -A cmds_crashkernel cmds_crashkernel=() +cmds_crashkernel[estimate]=crashkernel_estimate cmds_crashkernel[set]=_crashkernel_set # shellcheck disable=SC2034 cmds_crashkernel[show]=_crashkernel_show @@ -1573,7 +1573,7 @@ get_kernel_size() echo $_size }
-do_estimate() +crashkernel_estimate() { local kdump_mods local -A large_mods diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst index c83e9d0..b62d99a 100644 --- a/kdumpctl.8.rst +++ b/kdumpctl.8.rst @@ -58,9 +58,16 @@ status propagate Helper to setup key authentication for ssh dump targets.
+crashkernel *[COMMAND]* + Manage the crashkernel parameter on the kernel command line. Default command + is **show**. + +Commands to crashkernel +----------------------- + estimate - Estimate the required size of the crash kernel memory for the current - configuration and system. + Estimate the required size of the crash kernel memory on the current hardware + and system configuration.
.. note:: The memory requirements for kdump varies heavily depending on the used hardware and system configuration and cannot be predicted @@ -68,13 +75,6 @@ estimate work for your specific setup. Always test if kdump works after changing the crashkernel parameter on the kernel command line.
-crashkernel *[COMMAND]* - Manage the crashkernel parameter on the kernel command line. Default command - is **show**. - -Commands to crashkernel ------------------------ - set [--reboot] [--default|\ *size*] Set the crashkernel parameter on the kernel command line to *size*. If option **--default** is provided set it to the recommended default value instead.
Just a small, handy way to increase the crashkernel value on the command line. In case there is no crashkernel parameter on the command line do nothing.
Signed-off-by: Philipp Rudo prudo@redhat.com --- kdumpctl | 35 +++++++++++++++++++++++++++++++++++ kdumpctl.8.rst | 14 ++++++++++++++ 2 files changed, 49 insertions(+)
diff --git a/kdumpctl b/kdumpctl index 77737c8..a1b9612 100755 --- a/kdumpctl +++ b/kdumpctl @@ -81,6 +81,7 @@ parse_args_global()
declare -A cmds_crashkernel cmds_crashkernel=() +cmds_crashkernel[add]=crashkernel_add cmds_crashkernel[estimate]=crashkernel_estimate cmds_crashkernel[set]=_crashkernel_set # shellcheck disable=SC2034 @@ -1573,6 +1574,40 @@ get_kernel_size() echo $_size }
+crashkernel_add() +{ + local _kernel _kver _size _ck _needs_reboot + + _size=$1 + + if [[ -z "$_size" ]] || ! is_memsize "$_size"; then + derror "Need to provide a valid size" + exit 1 + fi + + + for _kver in "${!KDUMP_KERNEL_LIST[@]}"; do + _kernel="${KDUMP_KERNEL_LIST[$_kver]}" + + _ck="$(_get_kernel_cmdline_parameter "$_kernel" crashkernel)" + _ck="$(_crashkernel_add "$_ck" "$_size")" + if _update_kernel_cmdline "$_kernel" crashkernel "$_ck"; then + [[ $(uname -r) == "$_kver" ]] && _needs_reboot=1 + fi + done + + if [[ $_needs_reboot == 1 ]]; then + if [[ ${OPT[reboot]} == yes ]]; then + derror "systemctl reboot" + + # "rpm-ostree kargs" already asked the user to reboot after + # modifying the kernel command line. No need to repeat it. + elif ! is_ostree; then + dwarn "Please reboot the system for the change to take effect." + fi + fi +} + crashkernel_estimate() { local kdump_mods diff --git a/kdumpctl.8.rst b/kdumpctl.8.rst index b62d99a..4ed0fbb 100644 --- a/kdumpctl.8.rst +++ b/kdumpctl.8.rst @@ -65,6 +65,20 @@ crashkernel *[COMMAND]* Commands to crashkernel -----------------------
+add [--reboot] *size*\ [KMG] + Increase the size of the crashkernel parameter on the kernel command line by + *size*. If the crashkernel value consists of a list of ranges, increase the + size for every range. If *size* is negative decrease the size of the + parameter instead. + + .. note:: If you want to decrease the size of the crashkernel parameter + *size* needs to follow the end of option parameter '**--**'. + Otherwise *size* will be interpreted as option as it starts with a + minus '**-**'. For example, if you want to decrease the size by 100 + megabytes use + + ``kdumpctl crashkernel add -- -100M`` + estimate Estimate the required size of the crash kernel memory on the current hardware and system configuration.