Check first for fs support in `/proc/filesystems` before attempting
to load the kernel module.
This is needed in the --no-kernel use case to avoid the error:
modprobe: FATAL: Module overlay not found in directory /lib/modules/<kver>
#!/bin/sh
-if modprobe sunrpc || strstr "$(cat /proc/filesystems)" rpc_pipefs; then
+if load_fstype sunrpc rpc_pipefs; then
[ ! -d /var/lib/nfs/rpc_pipefs/nfs ] \
&& mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
type ismounted > /dev/null 2>&1 || . /lib/dracut-lib.sh
if [ "${fstype}" = "virtiofs" -o "${root%%:*}" = "virtiofs" ]; then
- if ! { modprobe virtiofs || strstr "$(cat /proc/filesystems)" virtiofs; }; then
+ if ! load_fstype virtiofs; then
die "virtiofs is required but not available."
fi
fi
}
-# parameter: kernel_module filesystem_name
+# 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"
+ if [ -z "$2" ]; then
+ set -- "$1" "$2"
+ fi
+ strstr "$(cat /proc/filesystems)" "$2" || modprobe "$1"
}