Networking

Hardware

Software

Consultation

 

Linux Diskless Client Server

 
 

⇔ UNDER CONSTRUCTION ⇔

The following will describe how to set up a server for diskless clients, or Diskless Booting.  This means storing the kernel and filesystem  remotely, and using it on other systems.  This allows the simple upgrading of multiple systems by changing only one.




Client

We will be creating a client OS to get the donor installation, install whatever OS you hope to have when finished, in this case Ubuntu 9.10 Desktop i386.  The i386 is used because it has the most compatibility, but it is simple to include multiple donors and choose the most appropriate for a given host.

Server

You can start with any installation, but I would recommend one with at least one static interface, in this case Ubuntu 9.10 Server AMD64.  If you want a good starting place, install as per the "Linux Gateway Setup" tutorial.


Server Configuration

First, log into your server installation as root.

Install the required packages, some may already be installed:

aptitude -y install dhcp3-server tftpd-hpa syslinux nfs-kernel-server initramfs-tools


DHCP

Configure your DHCP Server:

vim /etc/dhcp3/dhcpd.conf

Add the following to the bottom of the file:

option root-path "/nfsroot";
if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {filename "pxelinux.0";}

The "/nfsroot" is the path to the root file system of the client systems on the server, we'll cover this in more detail later.


TFTP

Configure your TFTP server.  We need to set tftp-hpa to run in daemon mode and to use /var/lib/tftpboot as its root directory.

vim /etc/default/tftpd-hpa

The file should look like:

#Defaults for tftpd-hpa
RUN_DAEMON="yes"
OPTIONS="-l -s /tftpboot"


Now setup the directory /var/lib/tftpboot/:

First we need to create the directory /var/lib/tftpboot/pxelinux.cfg:

mkdir -p /var/lib/tftpboot/pxelinux.cfg

Next we place the boot file into the directory /var/lib/tftpboot/:

cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot

The pxelinux.0 file is installed with the syslinux package


Create a configuration file, default, to tell the client and server about the installation used.  It's placed into the /var/lib/tftpboot/pxelinux.cfg directory:

vim /var/lib/tftpboot/pxelinux.cfg/default

The file should contain the following:

LABEL linux
	KERNEL [Linux Kernel Name]
	APPEND root=/dev/nfs initrd=[Created Linux Image File] nfsroot=[Server IP Address]:/nfsroot ip=dhcp rw

There will be some parameters that will need to be changed and some will be determined by the donor installation.  It's ok to fill in the server ip address parameter now, it should be the internal static address of the machine/server you configured the DHCP server on.


The permissions for this file need to be set, if you receive a "File Not Found" or "Permission Denied" error this is a likely cause:

chmod -R ugo+wrx /var/lib/tftpboot/

Start the tftp-hpa service:

/etc/init.d/tftp-hpa start


Exports

Now we create a place on the server to put the client OS.

mkdir /nfsroot

This will work fine if there is only one client OS, if there is more than one this could be the root of the the roots. ie: /nfsroot/AMD64root and /nfsroot/i386root. This will require changing the /etc/dhcp3/dhcpd.conf and the /var/lib/tftpboot/pxelinux.cfg/default files to include the full path.


Now add the directory to the exports to make it available to the client:


vim /etc/exports

Add the following to the end of the file:

/nfsroot	[Subnet Address or Client Address](rw,no_root_squash,async,no_subtree_check)

The Subnet Address will allow multiple clients to use the client OS and should be in CIDR notation. ie: 192.168.2.0/24

Sync your exports

exportfs -rv


Creating your Client OS

Install your donor OS; VirtualBox works well for this, and allows all of the configuration to be done very easily from a single machine.  The commands in this section should be carried out on the client machine unless it is explicitly noted otherwise.


Log into your donor installation as root.

After the installation is finnished, update the installation and install nfs-common. Command line is one option for this, package management also would work:

aptitude -y install nfs-common
aptitude update
aptitude -y full-upgrade
reboot


Copy Kernel

Copy current kernel version to the /root directory. uname -r will print your kernel version, and ~ is shorthand for the current users home directory, in this case root.

cp /boot/vmlinuz-`uname -r` ~


Create Image

We need to create an initrd.img file.  Start by change the BOOT flag to nfs in /etc/initramfs-tools/initramfs.conf

#
# BOOT: [ local | nfs ]
#
# local - Boot off of local media (harddrive, USB stick).
#
# nfs - Boot using an NFS drive as the root of the drive.
#

BOOT=local

To:

#
# BOOT: [ local | nfs ]
#
# local - Boot off of local media (harddrive, USB stick).
#
# nfs - Boot using an NFS drive as the root of the drive.
#

BOOT=nfs


Next change the MODULES flag to netboot in /etc/initramfs-tools/initramfs.conf

#
# MODULES: [ most | netboot | dep | list ]
#
# most - Add all framebuffer, acpi, filesystem, and harddrive drivers.
#
# dep - Try and guess which modules to load.
#
# netboot - Add the base modules, network modules, but skip block devices.
#
# list - Only include modules from the 'additional modules' list
#

MODULES=most

To:

#
# MODULES: [ most | netboot | dep | list ]
#
# most - Add all framebuffer, acpi, filesystem, and harddrive drivers.
#
# dep - Try and guess which modules to load.
#
# netboot - Add the base modules, network modules, but skip block devices.
#
# list - Only include modules from the 'additional modules' list
#

MODULES=netboot

If you have anything in /etc/initramfs-tools/conf.d/driver-policy, this line will be ignored.

Create the initrd.img file, and place it in the /root directory. The following command will append the kernel version to the end of the initrd.img file just to keep track of things:

mkinitramfs -o ~ /initrd.img-`uname -r`

You can also accomplish the same result as above with:

update-initramfs -c -k `uname -r` -b ~

However, this has the advantage of choosing the kernel version specified instead of using the most recent installed.


Copy Donor Operating System

Next we copy the donor OS files to the server. Start by mounting the /nfsroot directory on /mnt then copy everything over:

mount -tnfs -onolock [Server IP Address]:/nfsroot /mnt
cp -ax /. /mnt/.
cp -ax /dev/. /mnt/dev/.


From this point forward we will be working on the server, so open a root terminal.

Copy kernel and initrd to tftp root.

cp /nfsroot/root/vmlinuz-xxxx /var/lib/tftpboot/
cp /nfsroot/root/initrd.img-xxxx /var/lib/tftpboot/

The /var/lib/tftpboot/pxelinux.cfg/default file can be edited to reflect the previous vmlinux-xxxx and initrd.img-xxxx parameters:

vim /var/lib/tftpboot/pxelinux.cfg/default

As such:

LABEL linux
	KERNEL vmlinux-xxxx
	APPEND root=/dev/nfs initrd=initrd.img-xxxx nfsroot=[Server IP Address]:/nfsroot ip=dhcp rw


Configure Client Operating System

When booting over the network, the client will already have carried out a DHCP discovery before the OS is started.  To ensure that the client does not try to reconfigure the interface later edit your /etc/network/interfaces file and set your network interface to be "manual" not "auto" or "dhcp".  Change the file from:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

To:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface, commented out for NFS boot
#auto eth0
#iface eth0 inet dhcp
iface eth0 inet manual

Many new installations do not have the eth0 interface configured in this way, simply add the last line to the interfaces file, as in:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

iface eth0 inet manual


The /nfsroot/etc/fstab file contains the information the client will use to mount file systems on boot, edit it to ensure it looks something like this ('note no swap')

# /etc/fstab: static file system information.
#
#[File system]	[Mount point]	[Type]		[Options]	[Dump]	[Pass]
proc		/proc		proc		defaults	0	0
/dev/nfs	/		nfs		defaults	1	1
none		/tmp		tmpfs		defaults	0	0
none		/var/run	tmpfs		defaults	0	0
none		/var/lock	tmpfs		defaults	0	0
none		/var/tmp	tmpfs		defaults	0	0
/dev/hdc	/media/cdrom0	udf,iso9660 	user,noauto	0	0

If you have entries for other tmpfs it's fine to leave them as they are.


DONE!!


Set your client to boot to the network and have fun...