This document describes the steps needed to create a basic environment for
suporting diskless linux nodes. This howto mentions three different node types:
the prototype (golden client), server, and client.
The prototype node (described below) is a
node with a disk that is used for the initial installation of the operating
system. For the purpose of this document, the server node also runs linux.
The server node is responsible for holding and serving files and filesystems
that the client will need. The client is the machine which will be booted using
the diskless methods described here. The prototype node may be used as the client.
Install Linux on a prototype node. The prototype's filesystems will serve
as the basis for our diskless nodes. This installation should remain
so that it may be updated later. I was using kickstart for node imaging so
now I can use it to create the prototype. Here's the
ks file I was using for the initial install.
Cleanup unwanted cruft, this script can help get rid
of unwanted rpms.
Build a kernel that uses few or no modules, here's an example
CONFIG. After installing the kernel (make install)
and you've ensured it's correct, run "make clean" - this save about 700MB of
disk space. Be sure to set the ramdisk size to 64MB or above.
Copy the kernel to your server's /tftpboot/ directory.
# scp prototype:/boot/vmlinuz /tftpboot/vmlinuz
cp pxelinux.0 /tftpboot/
The "pxelinux.0" file may be found on your system if you've
installed the syslinux rpm, otherwise download pxelinux and
use the prebuilt "pxelinux.0" file.
Create bootfile for client(s) in /tftpboot/pxelinux.cfg/, the name
of the bootfile is the client's ip address in hex.
/tftpboot/pxelinux.cfg/0A000069 would be for the client 10.0.0.105. Bootfiles
may also be named after the clients MAC address
Preparing RootFS Image
Now that the "golden client" (borrowed from systemimager) is created
you want to appropriate the root and usr filesystems to be used respectively
as a ramdisk and nfs mounted /usr directory.
** Take caution in this phase not
to accidentally delete vital directories on your server. When making modifications
to your ramdisk make sure to use "chroot".
mkdir /cluster/rootfs; cd /cluster/rootfs
# Create a directory to hold the root dump
ssh prototype "tar cl /" | tar xf -
# Grab the entire root directory
mkdir /cluster/userfs; cd /cluster/userfs
# Create a directory to hold the usr dump
If the prototype doesn't have a separate /usr/ partion then
move the contents of the /cluster/rootfs/usr directory to /cluster/userfs
ssh prototype "cd /usr; tar cl ." | tar xf -
Add /cluster/userfs to /etc/exports for nfs mounting.
Creating the Ramdisk
Next step is take our wonderfully tailored rootfs and turn it into
a compressed file to be used as a initrd ramdisk by our clients.
cd /tftpboot; dd if=/dev/zero of=rootfs.img count=1024 bs=65536
# Make a 64MB, zero-filled file to serve as the ramdisk image
/sbin/mke2fs -F -N 25000 -L ROOT rootfs.img < /dev/null
# Create a filesystem in the image file
/sbin/losetup /dev/loop2 rootfs.img
# Bind the image file to a block device
/sbin/tune2fs -r 0 -C 0 -c -1 /dev/loop2; /sbin/fsck.ext2 /dev/loop2
# Tune up and fsck the filesystem on the image
mkdir /loop; mount /dev/loop2 /loop
# Verify the image is mountable.
cp -a /cluster/rootfs/* /loop
# copy the rootfs files into the ramdisk.
umount /loop; losetup -d /dev/loop2
gzip -c rootfs.img | dd of=rootfs.img.gz
# zip the ramdisk file.
Now you have an initrd file that your kernel can use as a root filesystem!
Back to PXE
Verify that the bootfile is correct.
The first line is the name of the kernel that the client will request -
you should have a kernel by that name in the /tftpboot/ directory.
The append line is where the initrd root filesystem is specified. In this
example we used the "rootfs.img.gz"
Set your client's bios to boot from the network card. This can be done
via the boot menu in your system bios. Something labeled "IBA" or "INT18" is a
probably network device. The network devices should be placed before the hard drive.
Reboot your client while watching (tail -f) /var/log/messages
on your dhcp/tftp server. Your client machine should boot up with the diskless image.