|
|
db7d74 |
#!/bin/bash --norc
|
|
|
db7d74 |
# Generate an initramfs image that isolates dump capture capability within
|
|
|
db7d74 |
# the default initramfs using zz-fadumpinit dracut module.
|
|
|
db7d74 |
|
|
|
4a6108 |
if [[ -f /etc/sysconfig/kdump ]]; then
|
|
|
db7d74 |
. /etc/sysconfig/kdump
|
|
|
db7d74 |
fi
|
|
|
db7d74 |
|
|
|
db7d74 |
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
|
|
db7d74 |
. $dracutbasedir/dracut-functions.sh
|
|
|
db7d74 |
. /lib/kdump/kdump-lib.sh
|
|
|
db7d74 |
. /lib/kdump/kdump-logger.sh
|
|
|
db7d74 |
|
|
|
db7d74 |
#initiate the kdump logger
|
|
|
db7d74 |
if ! dlog_init; then
|
|
|
db7d74 |
echo "mkfadumprd: failed to initiate the kdump logger."
|
|
|
db7d74 |
exit 1
|
|
|
db7d74 |
fi
|
|
|
db7d74 |
|
|
|
4a6108 |
MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)"
|
|
|
db7d74 |
[ -d "$MKFADUMPRD_TMPDIR" ] || perror_exit "mkfadumprd: mktemp -d -t mkfadumprd.XXXXXX failed."
|
|
|
db7d74 |
trap '
|
|
|
db7d74 |
ret=$?;
|
|
|
db7d74 |
[[ -d $MKFADUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKFADUMPRD_TMPDIR";
|
|
|
db7d74 |
exit $ret;
|
|
|
db7d74 |
' EXIT
|
|
|
db7d74 |
|
|
|
db7d74 |
# clean up after ourselves no matter how we die.
|
|
|
db7d74 |
trap 'exit 1;' SIGINT
|
|
|
db7d74 |
|
|
|
db7d74 |
MKDUMPRD="/sbin/mkdumprd -f"
|
|
|
db7d74 |
# Default boot initramfs to be rebuilt
|
|
|
db7d74 |
REBUILD_INITRD="$1" && shift
|
|
|
db7d74 |
TARGET_INITRD="$1" && shift
|
|
|
db7d74 |
FADUMP_INITRD="$MKFADUMPRD_TMPDIR/fadump.img"
|
|
|
db7d74 |
|
|
|
db7d74 |
### First build an initramfs with dump capture capability
|
|
|
db7d74 |
# this file tells the initrd is fadump enabled
|
|
|
db7d74 |
touch "$MKFADUMPRD_TMPDIR/fadump.initramfs"
|
|
|
db7d74 |
ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER"
|
|
|
db7d74 |
if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs; then
|
|
|
db7d74 |
perror_exit "mkfadumprd: failed to build image with dump capture support"
|
|
|
db7d74 |
fi
|
|
|
db7d74 |
|
|
|
db7d74 |
### Unpack the initramfs having dump capture capability
|
|
|
db7d74 |
mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot"
|
|
|
4a6108 |
if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$FADUMP_INITRD" &&
|
|
|
db7d74 |
popd > /dev/null); then
|
|
|
db7d74 |
derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'"
|
|
|
db7d74 |
exit 1
|
|
|
db7d74 |
fi
|
|
|
db7d74 |
|
|
|
db7d74 |
### Pack it into the normal boot initramfs with zz-fadumpinit module
|
|
|
4a6108 |
_dracut_isolate_args=(
|
|
|
4a6108 |
--rebuild "$REBUILD_INITRD" --add zz-fadumpinit
|
|
|
4a6108 |
-i "$MKFADUMPRD_TMPDIR/fadumproot" /fadumproot
|
|
|
4a6108 |
-i "$MKFADUMPRD_TMPDIR/fadumproot/usr/lib/dracut/hostonly-kernel-modules.txt"
|
|
|
4a6108 |
/usr/lib/dracut/fadump-kernel-modules.txt
|
|
|
4a6108 |
)
|
|
|
db7d74 |
|
|
|
db7d74 |
if is_squash_available; then
|
|
|
4a6108 |
_dracut_isolate_args+=(--add squash)
|
|
|
db7d74 |
fi
|
|
|
4a6108 |
|
|
|
4a6108 |
if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@" "$TARGET_INITRD"; then
|
|
|
db7d74 |
perror_exit "mkfadumprd: failed to setup '$TARGET_INITRD' with dump capture capability"
|
|
|
db7d74 |
fi
|