Probe for NFS and NBD capability before trying to load their modules
in case they are built into the kernel. Ugly use of flag files, but
avoids the need for grep to be on the image.
getarg rw && nbdrw=rw
fsopts=${fsopts+$fsopts,}${nbdrw}
-modprobe nbd || exit 1
+if [ ! -e /tmp/nbd.present ]; then
+ cat /proc/devices | while read t1 devt; do
+ if [ "$devt" = "nbd" ]; then
+ >/tmp/nfs.present
+ break
+ fi
+ done
+fi
+if [ ! -e /tmp/nbd.present ]; then
+ modprobe nbd || exit 1
+fi
# XXX better way to wait for the device to be made?
i=0
nfsflags=${nfsflags+$nfsflags,}${nfsrw}
# Load the modules so the filesystem type is there
-modprobe nfs || exit 1
+if [ ! -e /tmp/nfs.present ]; then
+ cat /proc/filesystems | while read t1 fst; do
+ case "$fst" in
+ nfs|nfs4) >/tmp/nfs.present; break ;;
+ esac
+ done
+fi
+if [ ! -e /tmp/nfs.present ]; then
+ modprobe nfs || exit 1
+fi
# XXX don't forget to move /var/lib/nfs/rpc_pipefs to new /