Linux NFS Root and PXE-Boot

November 6, 2006
Home· Linux
Linux kernel hacking and test running on the same machine becomes a major pain. This tutorial explains how to separate the two easily for a quick code-and-test loop. This tutorial explains how to setup a Linux thin client that boots using PXE by pulling a remote Linux kernel image and mounting a remote root file system over NFS. This is only possible if your client machine has a network card that supports this (do you remember seeing some type of option like press N to boot from network just after posting?). I am using Fedora Core 5 as my server, so some of the details may be specific to FC.

Most of the details of setting up the PXE boot server were found at Setting up a PXE-Boot Server.

1) yum install tftp-server dhcp
Make sure you have an NFS server.

2) create /etc/dhcpd.conf
allow bootp;
allow booting;
ddns-update-style interim;
subnet netmask {
default-lease-time 3600;
max-lease-time 4800;
option routers;
option domain-name-servers;
option subnet-mask;
option domain-name "";
option time-offset -8;
host llama0 {
hardware ethernet 04:4B:80:80:80:03;
option host-name "llama0";
filename "pxelinux.0";

Change MAC address to match that of the client machine.

3) Create the directory and add the following line to /etc/exports for the nfs share.
/nfsroot *(rw,no_all_squash,no_root_squash)

4) cp -a /bin /dev /etc /home /lib /mnt /sbin /tmp /usr /var /nfsroot
from a good Fedora Core install. You'll have to cleanup and change some of these files for your client at some point.

5) Activate tftp within xinetd by changing disable=yes to disable=no in /etc/xinetd.d/tftp. Restart xinetd. The tftp root is at /tftpboot.

6) Compile your kernel with the following options and move bzImage to /tftpboot/:
- NFS filesystem support (CONFIG_NFS_FS).
- Root file system on NFS (CONFIG_ROOT_NFS).
- Ethernet (10 or 100Mbit) (CONFIG_NET_ETHERNET).
- The ethernet driver for the clent's network card.
- IP: kernel level autoconfiguration (CONFIG_IP_PNP)

7) Configure pxelinux. First create the directory /tftpboot/pxelinux.cfg (and make it world readable). Inside that directory you need to create a number of zero size files (use touch):


The first 8 are the hex representation of the IP address that your PXE boot client will be assigned. The permutations allow a broader IP subnet to be searched first for matches. The last entry is the MAC address of your PXE boot client's NIC (with dashes substituted for the colons), with '01' pre-pended. The "01" at the front represents a hardware type of Ethernet, so pxelinux.0 see's the configuration string as an IP address.

Copy /usr/lib/syslinux/pxelinux.0 from your Fedora install to /tftpboot/

8) Now create the default pxelinux configuration inside the new file
prompt 1
default linux
timeout 100
label linux
kernel bzImage
append init=/sbin/init root=/dev/nfs rw nfsroot= ip= noapic acpi=off

The last line is where you can stick any kernel parameters needed. You'll notice this menu is somewhat similar to a grub config file.

Check out the following articles for more information:
PXELINUX - SYSLINUX for network boot
NFS-Root-Client Mini-HOWTO
NFS-Root mini-HOWTO

Related Posts

1 Comment

Comment 9:17pm on Friday 26th February 2010 by manoj jasawat
this is very use full but please fully describe it..............

Add Comment

No login required and anonymous if you prefer.
No html tags. URLs will be automatically linked. Spam protection is in place for email address. Click CAPTCHA image for new one.