Diskless booting implies that a client computer does not have any disk storage when booting an operating system. In that case, the computer can load the kernel as well as the root filesystem from a remote NFS server over network. It may use several different methods to load the kernel and the root filesystem from an NFS server: RARP, BOOTP or DHCP protocols. In this tutorial, I will use BOOTP/DHCP protocol because they are supported by many network cards.

Advantage of Diskless Computers

Imagine you have 30 computers in your office, all of which need to access the same application. If you are managing the computers as an administrator, what would you do? It will be a waste of your time if you install the application on every computer. On the other hand, a diskless system can eliminate the problem. With a diskless system, you just need to install the application on a central NFS server, and then boot all 30 clients over network.

Requirements

Two or more Linux computers equipped with network cards that support DHCP protocol. The computer that will act as an NFS server should have a hard drive, and the other client computer(s) do not need any hard drive. The server and client computer(s) need to be connected to the same local network.

There are five steps to setting up the diskless system.

Install required packages

Configure a TFTP server

Configure a DHCP server

Configure an NFS server

Booting diskless clients

In this tutorial, I assume that the computer which will run as a booting server is running Ubuntu. If you are using other Linux distribution, the principle is the same.

Step Four: Configure an NFS server

Next, configure the NFS server to export the client root filesystem. For that, add the following line to /etc/exports.

/nfsroot *(rw,no_root_squash,async,insecure,no_subtree_check)

Run the following command to reload modified /etc/exports.

$ sudo exportfs -rv

By default, Ubuntu does not add network boot support to the initrd image. Thus you need to create a new initrd.img file. For that, first add the following line to /etc/initramfs-tools/initramfs.conf

BOOT=nfs
MODULES=netboot

Then run the following command to create a new initrd.img.

$ sudo mkinitramfs -o /var/lib/tftpboot/initrd.img

Copy the new kernel image to /var/lib/tftpboot.

$ sudo cp /boot/vmlinuz-`uname -r` /var/lib/tfftpboot/vmlinuz

Now it is time to copy the entire root filesystem to /nfsroot.

Assuming tgat you are using a fresh Ubuntu server installation, you just need to clone the server filesystem to the NFS root.

$ sudo cp -ax / /nfsroot

Then open /nfsroot/etc/fstab with a text editor to add the following line.

/dev/nfs / nfs defaults 1 1

The directory /var/lib/tftpboot should have world read/write permissions. Otherwise the client would not be able to boot from network.

$ sudo chmod -R 777 /var/lib/tfftpboot

Lastly, to avoid any misconfiguration on the server, I recommend using a static IP address for the interface which DHCP service is running on. For example, if its network interface is named eth0, your configuration in /etc/network/interfaces should look like this:

i like the way you have explained the steps, but there is one problem in this article which i faced. When you create an initrd.img from your own server, after rebooting the server, the server is not able to load the image of kernel. It does not boot the kernel and we have to run the old version of kernel if it's present. so please verify the steps.