Index: etc/rc.initdiskless =================================================================== --- etc/rc.initdiskless +++ etc/rc.initdiskless @@ -195,10 +195,27 @@ to_umount="$b ${to_umount}" } -# Create a generic memory disk (using tmpfs) +# Attempt to load tmpfs, if it is not already available +# tmpfs_status is empty if load_tmpfs has not been called, +# 0 if tmpfs is available, and some other status code otherwise +# +tmpfs_status="" +load_tmpfs() { + kldstat -q -m tmpfs || kldload -q tmpfs >/dev/null 2>&1 + tmpfs_status=$? +} + +# Create a generic memory disk +# Use tmpfs, if available, otherwise fall back to using mfs # mount_md() { - mount -t tmpfs -o size=$(($1 * 512)) tmpfs $2 + # Only try to load tmpfs once + ${tmpfs_status:+:} load_tmpfs + if [ $tmpfs_status -eq 0 ]; then + mount -t tmpfs -o size=$(($1 * 512)) tmpfs $2 + else + /sbin/mdmfs -S -i 4096 -s $1 -M md $2 + fi } # Create the memory filesystem if it has not already been created