From: Laszlo Gombos Date: Sat, 13 Aug 2022 02:00:09 +0000 (+0000) Subject: fix(dmsquash-live): check kernel for built-in squashfs drivers X-Git-Tag: 058~188 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=922c9e28ed87815cf6ae0b5ee911ff0ef616d1b0;p=thirdparty%2Fdracut.git fix(dmsquash-live): check kernel for built-in squashfs drivers Check first for squashfs in `/proc/filesystems`. This is needed in the --no-kernel use case to avoid the error: modprobe: FATAL: Module overlay not found in directory /lib/modules/ Introduce load_fstype function to make it easier to check `/proc/filesystems` before calling modprobe. --- diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh index 9f9eefc01..6d9ce42c8 100755 --- a/modules.d/90dmsquash-live/dmsquash-live-root.sh +++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh @@ -89,7 +89,7 @@ det_img_fs() { blkid -s TYPE -u noraid -o value "$1" } -modprobe squashfs +load_fstype squashfs CMDLINE=$(getcmdline) for arg in $CMDLINE; do case $arg in @@ -204,7 +204,7 @@ do_live_overlay() { fi fi if [ -n "$overlayfs" ]; then - if ! { strstr "$(< /proc/filesystems)" overlay || modprobe overlay; }; then + if ! load_fstype overlay; then if [ "$overlayfs" = required ]; then die "OverlayFS is required but not available." exit 1 diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 43b023e14..913d0a8c0 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -1152,3 +1152,10 @@ remove_hostonly_files() { done < /lib/dracut/hostonly-files fi } + +# parameter: kernel_module filesystem_name +# returns OK if kernel_module is loaded +# modprobe fails if /lib/modules is not available (--no-kernel use case) +load_fstype() { + strstr "$(cat /proc/filesystems)" "$1" || modprobe "$1" +}