Skip to content

Commit

Permalink
fix(nfs,virtiofs): check kernel for builtin fs drivers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
LaszloGombos authored and johannbg committed Aug 18, 2022
1 parent 4f20ae2 commit 78cafe4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules.d/95nfs/nfs-start-rpc.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/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

Expand Down
2 changes: 1 addition & 1 deletion modules.d/95virtiofs/mount-virtiofs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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

Expand Down
7 changes: 5 additions & 2 deletions modules.d/99base/dracut-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1153,9 +1153,12 @@ remove_hostonly_files() {
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"
}

1 comment on commit 78cafe4

@FGrose
Copy link
Contributor

@FGrose FGrose commented on 78cafe4 Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LaszloGombos @johannbg How about?
strstr "$(cat /proc/filesystems)" "${2:-"$1"}" || modprobe "$1"

Please sign in to comment.