Network boot from read-only server

This will guide will explain to you how to do a network boot from a read-only server. This can be interesting for you if you want to have several boxes boot the same installation, or to have maintenance Linux installations ready for you to use when you need them. Some people also call this diskless Linux.

Disk preparation
First you need to make a directory for your new network bootable Gentoo installation (this will be /var/gentoo-netboot/ in this example). Unpack your stage-* tarball into this directory like normal and go on as outlined in the official Gentoo Documentation. When you have chrooted into your new installation, synced your portage-tree and adapted your make.conf, checkback here to see what comes next.

Kernel
In the kernel you will need:

Also include a lot of network card supports. You'll also need DHCP support in the kernel:

You can statically compile all needed modules for startup in your kernel to circumvent the need for an inital ramdisk.

Now compile the Kernel and install the modules (if needed):

Init
Next you need to add an additional startup script to mount some ramdisks to different locations that need write access. Here is an example script:

Don't forget to make the file executable with chmod +x /linuxrc

fstab
Your should look like this:

The important part here is, of course, the first line.

ssh
If you want to use sshd in your diskless system you need to create the sshd keys. Normally sshd creates them at the first start, but since the root is read-only, you'll need to create them beforehand:

/etc/init.d
Usually, it is desired that the init-scripts starts up your network interface(s). In your diskless installation this will be done by the kernel at boot-time. Since the network-init scripts are always started (to resolve dependencies), in addition to running: to prevent the execution of net.eth0, you also need to remove the symlink:

Without doing this, the network init-script tries to reconfigure your network connection and will bite the hand that feeds it.

As an alternative you can modify :

Another less destructive way is to leave everything as is and just modify :

The client environment is now configured. You can leave your chrooted environment. We will now continue with the server configuration.

Installation
You will need the following packages:

DHCP
The DHCP server is necessary for telling the client what to boot and where.

Don't forget to modify the IP addresses to fit your network setup.

TFTP
TFTP will be used by PXEBOOT to get the pxelinux binary.

NFS exports
To make the root filesystem available to the client you need to add it to :

PXE
The DHCP-server tells the client to fetch the PXE-bootloader from "pxelinux.0". This file is part of the syslinux package and has to be placed in the TFTP-servers root directory:

In newer versions this may be /usr/share/syslinux/pxelinux.0

This PXE-bootloader expects the default configuration file in. Create this file now:

In the default config file you told the bootloader to boot the kernel named "diskless". Copy this file from your client environment to the appropriate location:

NFS: server not respodning
If you get something like nfs warning: server not responding when the kernel tries to mount the NFS-filesystem you probably want to read this page on ltsp.org.

Using TCP as transport-protocol for NFS may help to work around this problem. To use TCP you should simply add one argument to the root option: