[Nix-dev] [PATCH] Root filesystem on NFS
Nicolas Pierron
nicolas.b.pierron at gmail.com
Sun Aug 28 01:13:30 CEST 2011
Hi Rickard,
On Sat, Aug 27, 2011 at 13:05, Rickard Nilsson
<rickard.nilsson at telia.com> wrote:
> The only way I have managed to get root fs on NFS to work in NixOS is by
> using the "nfsmount" program from klibc. The following patch works fine for
> me, but since I'm new to NixOS I'm open for any changes:
I am happy to see new users willing to share their configuration.
>
> Index: modules/system/boot/stage-1.nix
> ===================================================================
> --- modules/system/boot/stage-1.nix (revision 28845)
> +++ modules/system/boot/stage-1.nix (working copy)
> @@ -169,6 +169,10 @@
> cp
> ${kernelPackages.splashutils}/${kernelPackages.splashutils.helperName}
> $out/bin/splash_helper
> ''}
>
> + # Copy nfsmount
> + # TODO: Maybe only do this if there is a nfs mount point defined?
Sure, we don't want to pollute other user environment:
${if fileSystems != [] && filter (fs.fsType == "nfs") fileSystems then ''
> + cp -v ${pkgs.klibc}/lib/klibc/bin.static/nfsmount $out/bin
'' else ""}
> +
> ${config.boot.initrd.extraUtilsCommands}
>
> # Run patchelf to make the programs refer to the copied libraries.
>
>
> By applying this patch, the following root device specification in
> configuration.nix works perfectly for me:
>
> fileSystems = [
> { mountPoint = "/";
> fsType = "nfs";
> device = "192.168.42.1:/export/nixos_root";
> }
> ];
>
>
> However, you of course also need to get the network up before mounting the
> root fs. I have solved this in the following way directly in
> configuration.nix, but I would really appreciate any suggestions on how to
> solve it more generally in the NixOS repository, so I could write a proper
> patch for it:
>
> boot.initrd.extraUtilsCommands =
> ''
> cp ${pkgs.iproute}/sbin/ip $out/bin
> cp ${pkgs.glibc}/lib/libresolv.so.* $out/lib
> '';
This is ok.
> boot.initrd.postDeviceCommands =
> ''
> ip link set eth0 up
> ip addr add 192.168.42.200/24 dev eth0
> '';
But we probably don't want to hard write this one, best would be to
take into account the networking user configuration. Such things
could be done by extracting the jobs.dhclient script and giving it as
argument of boot.initrd.postDeviceCommands, but this has never been
experimented before.
> # This is necessary, otherwise upstart will tear
> # down the network connection and the root fs will stop working.
> networking.useDHCP = false;
This should not be necessary if you reused the upstart jobs content to
write the init script. Otherwise, if another definition gives you
trouble you can still use mkOverride to force it to another value.
If you are searching option declarations / definitions, use
"nixos-option -l option.name" to locate it.
Thanks for your interest in NixOS.
Feel free to contribute, I'll take pleasure to review your patches.
--
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/
More information about the nix-dev
mailing list