dracut-module-setup: Don't build squashed image if required modules are missing

When someone is using a minimal kernel without squash module installed,
including squash dracut module will either either fail to build or fail to
boot the initramfs.

As kdump always build the image for one single kernel, we can safely just
use modprobe to check if a modules is already built in, or it exists and
loadable for the kernel we are using for kdump image, and don't include
the squash module if they are missing. Everything will still work just
fine without squash module.

We do the check in kdump dracut modules not in squash dracut module
because kdump dracut module could leverage of the KDUMP_KERNELVER variable
to know which kernel it should check against, squash dracut module may be
used to build for a generic image.

And we only check for the kernel module dependency, other binary
dependencies are either well checked or well declared in dracut.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
Kairui Song 2018-12-25 22:51:35 +08:00
parent 89565289c6
commit 4a44eee472
1 changed files with 17 additions and 1 deletions

View File

@ -18,7 +18,23 @@ check() {
}
depends() {
local _dep="base shutdown squash"
local _dep="base shutdown"
is_squash_available() {
for kmodule in squashfs overlay loop; do
if [ -z "$KDUMP_KERNELVER" ]; then
modprobe --dry-run $kmodule &>/dev/null || return 1
else
modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1
fi
done
}
if is_squash_available; then
_dep="$_dep squash"
else
dwarning "Required modules to build a squashed kdump image is missing!"
fi
if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then
_dep="$_dep drm"