From 38bc39c299da94ffccccfc77baa8d4580795466e Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sat, 15 Oct 2011 21:01:30 +0000 Subject: [PATCH] Add support for NFS root file system. Patch by Rickard Nilsson. svn path=/nixos/trunk/; revision=29855 --- modules/system/boot/stage-1-init.sh | 6 ++++-- modules/system/boot/stage-1.nix | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) 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.