diff --git a/modules/system/boot/stage-1-init.sh b/modules/system/boot/stage-1-init.sh index a1fcfc164b6..68cbc36de86 100644 --- a/modules/system/boot/stage-1-init.sh +++ b/modules/system/boot/stage-1-init.sh @@ -221,8 +221,10 @@ mountFS() { # For CIFS mounts, retry a few times before giving up. local n=0 while true; do - if mount -t "$fsType" -o "$options" "$device" /mnt-root$mountPoint; then - break + if [ "$fsType" = "nfs" ]; then + nfsmount "$device" "/mnt-root$mountPoint" && break + else + mount -t "$fsType" -o "$options" "$device" "/mnt-root$mountPoint" && break fi if [ "$fsType" != cifs -o "$n" -ge 10 ]; then fail; break; fi echo "retrying..." diff --git a/modules/system/boot/stage-1.nix b/modules/system/boot/stage-1.nix index 8936a1108d0..08cf948fea4 100644 --- a/modules/system/boot/stage-1.nix +++ b/modules/system/boot/stage-1.nix @@ -169,6 +169,11 @@ let cp ${kernelPackages.splashutils}/${kernelPackages.splashutils.helperName} $out/bin/splash_helper ''} + # Copy nfsmount if there is any NFS mounts required for boot. + ${optionalString (filter (fs: fs.fsType == "nfs" && (fs.mountPoint == "/" || fs.neededForBoot)) fileSystems != []) '' + cp -v ${pkgs.klibc}/lib/klibc/bin.static/nfsmount $out/bin + ''} + ${config.boot.initrd.extraUtilsCommands} # Run patchelf to make the programs refer to the copied libraries.