NFSRoot is the term used to describe running an operating system with its root filesystem (/) mounted via NFS. Why would anyone do this? Thin-clients, kiosks, industrial uses, and so on. If you dont need to touch a local harddisk, you can save a lot in the way of moving parts.
Other places to look for similar information include the DisklessWorkstationNotes page, and the notes on PXE and so forth.
This set up uses PXE booting network cards, via PXEBoot?, to load a kernel and then mount / via NFS. Its very debian oriented, although the principles could be adapted to any situation.
Things you'll need:
This also makes use of the debian package 'diskless' to create the NFS root filesystem. If you dont run debian you'll need to find another way to make a nfsroot fs suitable for your distribution.
Compile a kernel that is suitable for booting via NFS. In particular, you'll need to make sure that the kernel supports IP level autoconfiguration and mounting NFS root. Also, its probably a good idea to compile in the drivers for your network cards, as opposed to leaving them as modules.
CONFIG_NET=y CONFIG_UNIX=y CONFIG_INET=y CONFIG_IP_PNP_BOOTP=y CONFIG_IP_PNP_RARP=y CONFIG_NFS_FS=y
- CONFIG_NFS_V3 is not set
CONFIG_ROOT_NFS=y
- CONFIG_NFSD is not set
CONFIG_SUNRPC=y CONFIG_LOCKD=y
You can either compile this by hand or use make-kpkg under debian to install it, but however you do it you'll need to be able to install it into the nfs root we'll create in a second.
Because I'm using the 'diskless' package under debian, this bit is fairly easy. diskless comes with a program called 'diskless-createbasetgz' which creates a base.tgz (potato-install style) from a basic system root. It uses debootstrap or similar to download the required packages
diskless-createbasetgz /tmp/nfsroot/ woody
http://ftp.nz.debian.org/debian /tmp/base.tgz
This creates a new system under /tmp/nfsroot, from the specified mirror. It then tars this up into /tmp/base.tgz
If you are using diskless, you'll also need to download a copy of diskless-image-simple. NOTE: do NOT install this on your server. Just download it, and stop any debconf from installing it too. Copy the deb to /tmp (or to the same dir your base.tgz is in)
Now, if you run diskless-newimage it will create a new diskless group image in the directory you specify. You must run this program from a directory containing base.tgz and diskless-image-simple
total 56192
- rw-r--r-- 1 root root 55278350 May 11 12:49 base.tgz
- rw-r--r-- 1 root root 13742 May 11 12:32 diskless-image-simple_0.3.17_all.deb
drwxr-xr-x 19 root root 4096 May 11 12:48 nfsroot
Now, run diskless-newimage
Follow the instructions - the defaults are probably good enough
This has created the basic nfsroot filesystem for you. Now you must create a newhost using this image (this allows you ot have per-host settings for hostname etc)
If you made a debian kernel-package, copy it to /var/lib/diskless/default/root/root (or wherever you put your default image), then chroot to /var/lib/diskless/default/root, and run dpkg -i root/kernel-image.....
You'll also need to copy the kernel image to /tftpboot/. Name it something useful. I called it 'nfsroot-kernel'
As we are going to boot via nfsroot, we need to set up a special device to use for this.
mknod /dev/boot255 c 0 255
Make a directory for the tftp root dir. I usually use /tftpboot
This tells tftp to use /tftproot as its root - all paths are now relative to this.
allow bootp; allow booting;
authoritative; ... host nfsroot {
hardware ethernet 00:01:02:03:04:05; fixed-address nfsroot.mydomain.tla; filename "pxelinux.0";
}
This tells the client with the mac address 00:01:02:03:04:05 to use the IP address associated with the name nfsroot.mydomain.tla (this only works if you have your DNS set up correctly. You can specify an IP address here instead of a name if you dont have DNS working). It then loads the file pxelinux.0, which is its bootloader.
Copy pxelinux.0 from the pxelinux distribution under /tftpboot
Make the directory /tftproot/pxelinux.cfg - this is where you'll store all your configurations.
In /tftproot/pxelinux.cfg create a file called 'default', and add something like the following to it:
default nfs
label nfs
kernel netboot-kernel append root=/dev/boot255 \
nfsroot=10.66.1.1:/var/lib/diskless/default/root/ \ ip=:10.66.1.1:10.66.1.1:255.255.255.0::: devfs=nomount
Note, that the default file is the the default configuration file for the client. PXE actually searches first of all for its IP address printed in hexadecimal, then drops a byte off, and continues looking for this until it has to give up and use the default file. This lets you add a config file for each host you boot via PXE.
This pxe config file sets the default boot option to nfs. It tells it to boot the kernel 'netboot-kernel' which it gets via tftp. It appends the specified kernel options to the kernel. These options are all, as far as I can tell, ABSOLUTELY required.
You'll need to add something like the following lines to /etc/exports
/var/lib/diskless/default/10.66.1.104 10.66.1.104(rw,no_root_squash) /home 10.66.1.0/255.255.255.0(rw,no_root_squash)
/var/lib/diskless/default/root 10.66.1.0/255.255.255.0(rw,no_root_squash) /usr 10.66.1.0/255.255.255.0(ro,no_root_squash)
Note that these are different from the suggested options in the diskless package. I found mounting NFS root ro caused a lot problems.
Restart your nfs server (/etc/init.d/nfs-kernel-server restart in debian) and you are away
Set up your client to boot via PXE, either by using a PXE enabled boot card or using the pxe-on-disk image you can find under PXE. This only works with certain cards tho - intel eepro, 3com, realtek 8139, netgear (natsemi chipset), and some others.
This should all go!
No page links to NFSRoot.