RHEL/CentOS Diskless Clients

<!> Note: This article seems to have been pasted, but not previewed, before it was commmitted. On its face it reports a mixed success (i.e., a partial failure). You may find that the Linux Terminal Server Project has similar, but more proofread content, and works with CentOS just fine.

Currently CentOS 5 support for system-config-netboot is not working. There are technical difficulties in the package that don't allow for ease of use. You can install the A Fedora Core 6 package for system-config-netboot and it will work, for some definitions of: work but there are many other issues.

This guide may assist in trying to get things to function in a CentOS 5 environment, but the initial author of this article was unsuccessful even after following those instructions.

The Linux Terminal Server Project has similar content, but in a form that works with CentOS just fine.

The original author asserted that Red Hat plans a fix and to include a working system-config-netboot in the future, but no ETA for such a fix was stated. This shouldn't prevent loading CentOS 4 or 5 machines as the actual diskless clients, but only meant he had problems using a CentOS 5 as the NFS Diskless Image Server. Note again, that this is the opinion of the original author; a later revisor of this page, RussHerrold runs such, with SElinux labelling fixes on the NFS server side without incident.

This guide will help you setup an NFS server to dish out diskless clients on your network. This is useful if you want to bring up workstations quickly, without the hassle of hard drives, and or worrying about multiple installations along the way. Some of the commands are from the official Red Hat Docs. This guide will assume you're creating two different installation types, a server and a desktop installation.

Tested System:

CentOS 4.6, CentOS 5.1

<!> Note: That while this section notes particular 'respin' levels of CentOS, the narrative should not vary across the entire Major release of either 4 or 5, due to the expectation of API / ABI compatibility.

Off-Site References:

Official Red Hat Guide
Red Hat NFS Guide

/!\ FIXME with CentOS local references

NFS Server Setup

1. Install NFS and Create Directories

The first step is to create a NFS server if one is not already set up. The client OS filesystem lives (is stored) on that NFS server. As part of the PXE boot process a host with a PXE boot enabled network card, will issue a broadcast for a an IP address, and be provided that IP assignement by DHCP server aloing with a optional field for a so-called 'next-server' and an initial boot image to chain load after the minimal boot image used by the network card (from ROM, or other source) . The host the retreives its files and configurations from the NFS share configured in this section.

Having spare disk space available in the NFS export becomes a necessity as one starts adding more than one variety of an installation, because the entire client system OS will be copied to the NFS server. Customarily, the end user /home is not carried in those images, but separately mounted. Go ahead and install the NFS packages if they aren't already installed on your server.

# yum install nfs-utils nfs-utils-lib sytem-config-nfs

Next, create the directories that you will be needing later on. These will be the actual NFS shares specified. If you want to put these somewhere else, or you can to specify different names, do so. You can share them from anywhere. The first directory will host a server installation of CentOS4, and the second directory a CentOS installation with a desktop environment.

# mkdir -p /srv/diskless/i386/RHEL4S/root
# mkdir -p /srv/diskless/i386/RHEL4D/root

2. Configure NFS Mounts

Now you need to create the actual shares with read-write permission and start the NFS server.

# vim /etc/exports
/srv/diskless/i386/RHEL4S/              *(rw,sync,no_root_squash)
/srv/diskless/i386/RHEL4S/root/         *(rw,sync,no_root_squash)
/srv/diskless/i386/RHEL4S/snapshot/     *(rw,sync,no_root_squash)
/srv/diskless/i386/RHEL4D/              *(rw,sync,no_root_squash)
/srv/diskless/i386/RHEL4D/root/         *(rw,sync,no_root_squash)
/srv/diskless/i386/RHEL4D/snapshot/     *(rw,sync,no_root_squash)

Start the NFS server and verify the NFS shares are ok and start the service. If NFS services are already running, then reload them.

# service nfs start (reload)
# chkconfig nfs on
# nfs-export -l

Directory                               Permissions             Hosts
/srv/diskless/i386/RHEL4S/              rw                      *
/srv/diskless/i386/RHEL4S/root/         rw                      *
/srv/diskless/i386/RHEL4S/snapshot/     rw                      *
/srv/diskless/i386/RHEL4D/              rw                      *
/srv/diskless/i386/RHEL4D/root/         rw                      *
/srv/diskless/i386/RHEL4D/snapshot/     rw                      *

DHCP Server Configuration

If you don't already have a Linux DHCP server going on your network, then please see the documentation regarding setup of a DHCP server. It's completely acceptable to install a DHCP server on the NFS server if you want. For my example, there is a separate DHCP server already running.

1. PXE DHCP Configuration

Place the following configuration within /etc/dhcpd.conf. This specifies that network booting will be allowed. When the DHCP server comes across such a request, it will direct the client to the NFS server you have specified. Please remember or keep in mind that if you already have a DHCP server on the network, be careful with adding a second one.

# vim /etc/dhcpd.conf
allow booting;
allow bootp;
class "pxeclients" {
   match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
   next-server 192.168.1.20;
   filename "linux-install/pxelinux.0";
}

2. Setup tftp

Ensure that xinetd and tftp are installed on the DHCP server.

# yum install xinetd tftp-server

Ensure both services are setup on the DHCP server.

# chkconfig --level 345 xinetd on
# chkconfig --level 345 tftp on

Install/Configure/Copy an Installation

Next you have to actually install an installation. The iptables and selinux services should be turned off on the new installation.

For this experiment, I've installed a fresh basic non-gui load of CentOS 4.6. Completely setup the host as you wish, because this will be the actual copy of all the diskless clients in a bit. For my purposes, I've installed, updated, and copied any local configurations I want or need on my network to my host. Anything you want customized, do it now because it's easier to set it up once the right way. A perfect example of this is if you need third-party RPM packages installed, go ahead and install them on the host now. The only package that is required on the host is busybox-anaconda.

# yum install busybox-anaconda

Once you have your installation configured the way you want, go back over to the NFS server and rsync the installation to the NFS share. If you don't want to see what's being copied, remove the -v switch.

# rsync -v -a -e ssh --exclude='/proc/*' --exclude='/sys/*' host_of_installation://srv/diskless/i386/RHEL4S/root/
receiving file list...
<snip buckets of output>

Diskless Client Setup

1. Netboot Configuration

Head back over to your NFS server now.

# ssh nfs_server

Install the command-line version of the netboot configuration tool if it's not already on the system, and launch the tool.

# yum install system-config-netboot-cmd
# system-config-netboot

You should have a nice little pop up asking you what you want to do. The first time you run this, you should get the little wizard popup. Click Diskless to continue. The steps are outlined for what you have to do. The rsync step has already been completed. Click Forward and enter an OS name and description. The next screen is where you enter your NFS information. In the Server IP Address, enter the NFS server IP. In the Directory section, enter the first NFS share -- /srv/diskless/i386/RHEL4S. On the next screen, pick the kernel that you want running on your diskless clients. When complete, click Apply and wait a few moments as it does its magic. This tool automatically creates and configures an image file and places it in the PXE boot directory.

These steps can also be accomplished using commands (for more help, see man pxeos; man pxeboot):

# pxeos -a -i "centos5.7" -p NFS -D 1 -s 192.168.1.254 -L /srv/diskless/i386/RHEL4S/ centos5.7
# pxeboot -a -O centos5.7 192.168.1.196

Here 192.1681.254 is the NFS server IP, and 192.168.1.196 is the PXE client IP.

After execution, the NFS shares can be given read-only permission:

# vim /etc/exports
/srv/diskless/i386/RHEL4S/root/         *(ro,sync,no_root_squash)
/srv/diskless/i386/RHEL4S/snapshot/     *(rw,sync,no_root_squash)
/srv/diskless/i386/RHEL4D/root/         *(ro,sync,no_root_squash)
/srv/diskless/i386/RHEL4D/snapshot/     *(rw,sync,no_root_squash)

2. Host Configuration

Once the diskless OS environment is setup, you can create and configure a new host system with the configuration tool. If you need specifics of what all the parameters are, then check out the adding hosts section of Red Hat's documenation. In the GUI tool, select New to start the host creation process.

The machine you're adding must have a valid IP or hostname on the network, which shouldn't be an issue. For my instance, I took an existing PC off my network, pulled the hard drive, and used it to boot diskless. In the hostname field, go ahead and enter a valid machine. Since you only have one OS environment setup at the moment, the only option for OS will be the one you just created in step 1 of the netboot configuration. If you have more than one OS, then choose the appropriate OS you desire in the drop-down menu. If you leave the snapshot name blank, then it will automatically fill it in with the hostname it finds on your network. Remember we exported an NFS mount point for this: /srv/diskless/i386/RHEL4S{D}/snapshot. Lastly, if you want the host to log remotely, then fill in your system logger that accepts remote logging. When finished, click ok to create the host.

If you don't want to have to deal with the wrong hostname on any new machine, then go ahead and wipe it out of the synced files. For instance, I'm creating a server install because I want to have it as generic as possible, and I also want to have it boot on multiple machines. If I leave the information in the files, then it'll pick up the hostname of the machine the OS was created on. It's a minor annoyance. If you don't care, leave it alone.

# vim /srv/diskless/i386/RHEL4S/root/etc/sysconfig/network-scripts/ifcfg-eth0{1,2,3} (whatever your NIC is)
HWADDR=  <--- blank this out
DHCP_HOSTNAME=  <--- blank this out

Now when you boot up the new diskless host, it won't get mad about the MAC address being different, and it won't have a hostname. It should only be named localhost. Obviously you can set the hostname at will.

That's it for adding hosts. You can now repeat this entire process for each OS environment type. Don't forget if you create a new OS type, then you're going to want to add a new directory under NFS to export. Think of it as housing different OSes, so make the names distinguishable. For my uses, I'm creating the already mentioned server and desktop installation. You can use it for anything you want, though. Let's say you want to create an instance for a very specific task, but don't have a hard drive for the machine. This allows you to create an instance on VMware, or any other virtual environment, and copy that installation over to NFS. Now you can boot it up on any machine with a PXE network card.

PXE Boot

A note about PXE, which is short for Preboot Execution Environment. Do a Wikipedia search if you really desire deeping meanings. In short, the network card's firmware searches for a PXE redirect, which happily passes this information along from the DHCP server, which then points it to your NFS server specified. It then downloads via tftp the boot file path into memory, and continues to execute it. Ultimately, you have your OS boot up from memory then.

All network cards are different, so consult the manufacturer of the card for information on enabling PXE on your system. Most new cards support it right out of the box, and it's just a matter of turning it on in the BIOS (on board NICs), or by accessing a utility menu from the network card. Again, all cards are different.

Once you have the NIC and system ready to go, fire it up and test it out. You should have it boot to the NIC menu, it might say something about the MAC address, or about bootp loading. It should immediately get passed on to your NFS server, and then boot the Linux image. Now you can go steal all of those hard drives out of your PCs at work, huh.

HowTos/DisklessClients (last edited 2012-10-03 14:04:35 by TimothyLee)