3cc034
#!/bin/bash
3cc034
# $1: target arch
3cc034
3cc034
3cc034
SED_EXP=""
3cc034
3cc034
generate()
3cc034
{
3cc034
	sed "$SED_EXP" << EOF
b9e861
# This file contains a series of commands to perform (in order) in the kdump
b9e861
# kernel after a kernel crash in the crash kernel(1st kernel) has happened.
b9e861
#
b9e861
# Directives in this file are only applicable to the kdump initramfs, and have
b9e861
# no effect once the root filesystem is mounted and the normal init scripts are
b9e861
# processed.
b9e861
#
b9e861
# Currently, only one dump target and path can be specified.  If the dumping to
b9e861
# the configured target fails, the failure action which can be configured via
b9e861
# the "failure_action" directive will be performed.
b9e861
#
b9e861
# Supported options:
b9e861
#
b9e861
# raw <partition>
b9e861
#           - Will dd /proc/vmcore into <partition>.
b9e861
#             Use persistent device names for partition devices,
b9e861
#             such as /dev/vg/<devname>.
b9e861
#
b9e861
# nfs <nfs mount>
b9e861
#           - Will mount nfs to <mnt>, and copy /proc/vmcore to
b9e861
#             <mnt>/<path>/%HOST-%DATE/, supports DNS.
b9e861
#
b9e861
# ssh <user@server>
fe2ad6
#           - Will save /proc/vmcore to <user@server>:<path>/%HOST-%DATE/,
b9e861
#             supports DNS.
b9e861
#             NOTE: make sure the user has write permissions on the server.
b9e861
#
b9e861
# sshkey <path>
b9e861
#           - Will use the sshkey to do ssh dump.
b9e861
#             Specify the path of the ssh key to use when dumping
b9e861
#             via ssh. The default value is /root/.ssh/kdump_id_rsa.
b9e861
#
b9e861
# <fs type> <partition>
b9e861
#           - Will mount -t <fs type> <partition> <mnt>, and copy
b9e861
#             /proc/vmcore to <mnt>/<path>/%DATE/.
b9e861
#             NOTE: <partition> can be a device node, label or uuid.
b9e861
#             It's recommended to use persistent device names
b9e861
#             such as /dev/vg/<devname>.
b9e861
#             Otherwise it's suggested to use label or uuid.
b9e861
#
b9e861
# path <path>
b9e861
#           - "path" represents the file system path in which vmcore
b9e861
#             will be saved.  If a dump target is specified in
b9e861
#             kdump.conf, then "path" is relative to the specified
b9e861
#             dump target.
b9e861
#
b9e861
#             Interpretation of "path" changes a bit if the user didn't
b9e861
#             specify any dump target explicitly in kdump.conf.  In this
b9e861
#             case, "path" represents the absolute path from root. The
b9e861
#             dump target and adjusted path are arrived at automatically
b9e861
#             depending on what's mounted in the current system.
b9e861
#
b9e861
#             Ignored for raw device dumps.  If unset, will use the default
b9e861
#             "/var/crash".
b9e861
#
b9e861
# core_collector <command> <options>
b9e861
#           - This allows you to specify the command to copy
b9e861
#             the vmcore.  The default is makedumpfile, which on
b9e861
#             some architectures can drastically reduce vmcore size.
b9e861
#             See /sbin/makedumpfile --help for a list of options.
b9e861
#             Note that the -i and -g options are not needed here,
b9e861
#             as the initrd will automatically be populated with a
b9e861
#             config file appropriate for the running kernel.
b9e861
#             The default core_collector for raw/ssh dump is:
fe2ad6
#             "makedumpfile -F -l --message-level 7 -d 31".
b9e861
#             The default core_collector for other targets is:
fe2ad6
#             "makedumpfile -l --message-level 7 -d 31".
b9e861
#
b9e861
#             "makedumpfile -F" will create a flattened vmcore.
b9e861
#             You need to use "makedumpfile -R" to rearrange the dump data to
b9e861
#             a normal dumpfile readable with analysis tools.  For example:
b9e861
#             "makedumpfile -R vmcore < vmcore.flat".
b9e861
#
b9e861
#             For core_collector format details, you can refer to
b9e861
#             kexec-kdump-howto.txt or kdump.conf manpage.
b9e861
#
b9e861
# kdump_post <binary | script>
b9e861
#           - This directive allows you to run a executable binary
b9e861
#             or script after the vmcore dump process terminates.
b9e861
#             The exit status of the current dump process is fed to
b9e861
#             the executable binary or script as its first argument.
fe2ad6
#             All files under /etc/kdump/post.d are collectively sorted
fe2ad6
#             and executed in lexical order, before binary or script
fe2ad6
#             specified kdump_post parameter is executed.
b9e861
#
b9e861
# kdump_pre <binary | script>
b9e861
#           - Works like the "kdump_post" directive, but instead of running
b9e861
#             after the dump process, runs immediately before it.
b9e861
#             Exit status of this binary is interpreted as follows:
73ea9d
#               0 - continue with dump process as usual
fe2ad6
#               non 0 - run the final action (reboot/poweroff/halt)
fe2ad6
#             All files under /etc/kdump/pre.d are collectively sorted and
fe2ad6
#             executed in lexical order, after binary or script specified
73ea9d
#             kdump_pre parameter is executed.
73ea9d
#             Even if the binary or script in /etc/kdump/pre.d directory
73ea9d
#             returns non 0 exit status, the processing is continued.
b9e861
#
b9e861
# extra_bins <binaries | shell scripts>
b9e861
#           - This directive allows you to specify additional binaries or
b9e861
#             shell scripts to be included in the kdump initrd.
b9e861
#             Generally they are useful in conjunction with a kdump_post
b9e861
#             or kdump_pre binary or script which depends on these extra_bins.
b9e861
#
b9e861
# extra_modules <module(s)>
b9e861
#           - This directive allows you to specify extra kernel modules
b9e861
#             that you want to be loaded in the kdump initrd.
b9e861
#             Multiple modules can be listed, separated by spaces, and any
b9e861
#             dependent modules will automatically be included.
b9e861
#
b9e861
# failure_action <reboot | halt | poweroff | shell | dump_to_rootfs>
b9e861
#           - Action to perform in case dumping fails.
b9e861
#             reboot:   Reboot the system.
b9e861
#             halt:     Halt the system.
b9e861
#             poweroff: Power down the system.
b9e861
#             shell:    Drop to a bash shell.
b9e861
#                       Exiting the shell reboots the system by default,
b9e861
#                       or perform "final_action".
b9e861
#             dump_to_rootfs:  Dump vmcore to rootfs from initramfs context and
b9e861
#                       reboot by default or perform "final_action".
b9e861
#                       Useful when non-root dump target is specified.
b9e861
#             The default option is "reboot".
b9e861
#
b9e861
# default <reboot | halt | poweroff | shell | dump_to_rootfs>
b9e861
#           - Same as the "failure_action" directive above, but this directive
b9e861
#             is obsolete and will be removed in the future.
b9e861
#
b9e861
# final_action <reboot | halt | poweroff>
b9e861
#           - Action to perform in case dumping succeeds. Also performed
b9e861
#             when "shell" or "dump_to_rootfs" failure action finishes.
b9e861
#             Each action is same as the "failure_action" directive above.
b9e861
#             The default is "reboot".
b9e861
#
b9e861
# force_rebuild <0 | 1>
b9e861
#           - By default, kdump initrd will only be rebuilt when necessary.
b9e861
#             Specify 1 to force rebuilding kdump initrd every time when kdump
b9e861
#             service starts.
b9e861
#
b9e861
# force_no_rebuild <0 | 1>
b9e861
#           - By default, kdump initrd will be rebuilt when necessary.
b9e861
#             Specify 1 to bypass rebuilding of kdump initrd.
b9e861
#
b9e861
#             force_no_rebuild and force_rebuild options are mutually
b9e861
#             exclusive and they should not be set to 1 simultaneously.
b9e861
#
b9e861
# override_resettable <0 | 1>
b9e861
#           - Usually an unresettable block device can't be a dump target.
b9e861
#             Specifying 1 when you want to dump even though the block
b9e861
#             target is unresettable
b9e861
#             By default, it is 0, which will not try dumping destined to fail.
b9e861
#
b9e861
# dracut_args <arg(s)>
b9e861
#           - Pass extra dracut options when rebuilding kdump initrd.
b9e861
#
b9e861
# fence_kdump_args <arg(s)>
b9e861
#           - Command line arguments for fence_kdump_send (it can contain
b9e861
#             all valid arguments except hosts to send notification to).
b9e861
#
b9e861
# fence_kdump_nodes <node(s)>
b9e861
#           - List of cluster node(s) except localhost, separated by spaces,
b9e861
#             to send fence_kdump notifications to.
b9e861
#             (this option is mandatory to enable fence_kdump).
b9e861
#
b9e861
b9e861
#raw /dev/vg/lv_kdump
b9e861
#ext4 /dev/vg/lv_kdump
b9e861
#ext4 LABEL=/boot
b9e861
#ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937
b9e861
#nfs my.server.com:/export/tmp
fe2ad6
#nfs [2001:db8::1:2:3:4]:/export/tmp
b9e861
#ssh user@my.server.com
fe2ad6
#ssh user@2001:db8::1:2:3:4
b9e861
#sshkey /root/.ssh/kdump_id_rsa
b9e861
path /var/crash
fe2ad6
core_collector makedumpfile -l --message-level 7 -d 31
b9e861
#core_collector scp
b9e861
#kdump_post /var/crash/scripts/kdump-post.sh
b9e861
#kdump_pre /var/crash/scripts/kdump-pre.sh
b9e861
#extra_bins /usr/bin/lftp
b9e861
#extra_modules gfs2
b9e861
#failure_action shell
b9e861
#force_rebuild 1
b9e861
#force_no_rebuild 1
b9e861
#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"
b9e861
#fence_kdump_args -p 7410 -f auto -c 0 -i 10
b9e861
#fence_kdump_nodes node1 node2
3cc034
EOF
3cc034
}
3cc034
3cc034
update_param()
3cc034
{
3cc034
	SED_EXP="${SED_EXP}s/^$1.*$/$1 $2/;"
3cc034
}
3cc034
3cc034
case "$1" in
3cc034
aarch64)
3cc034
	;;
3cc034
i386)
3cc034
	;;
3cc034
ppc64)
3cc034
	;;
3cc034
ppc64le)
3cc034
	;;
3cc034
s390x)
3cc034
	update_param core_collector \
3cc034
		"makedumpfile -c --message-level 7 -d 31"
3cc034
	;;
3cc034
x86_64)
3cc034
	;;
3cc034
*)
3cc034
	echo "Warning: Unknown architecture '$1', using default kdump.conf template."
3cc034
	;;
3cc034
esac
3cc034
3cc034
generate