Recently, one of my projects required the ability to disklessly boot a bunch of machines. Initally, I was doing this with DRBL, however DRBL has a lot of cruft that was unnecessary for us, and wasn’t really what we wanted. DRBL relies on a number of NFS mounts back to the server, so if your DRBL server crashes, all the machines go down. I took a look at LTSP, but the project appears to be msotly dead at this point, and seems to suffer from the same issues as DRBL.
Thankfully, the actual process for setting up a diskless image to boot from isn’t terribly difficult. It took a bit of fiddling with it, but in the end it turned out pretty simple. Basically, you set up a chrooted environment containing your entire system, then compress that into the inital ramdisk for the system.
This would be the setup process for a Centos 5 x86_64 OS. It’s pretty similar for Centos 6, I’ve not attempted it with any other operating system. I run this on another Centos 5 machine. I’ve found that it can be very difficult to bootstrap the OS from another OS. Attempting to create a Centos 6 image on a Centos 5 machine fails due to some missing libraries and incompatible rpm formats.
# This would be needed to get the centos-release RPM. # Alternatively, just wget it from one of the mirrors. # pigz will make compressing the image a lot faster (it's parallel gzip) yum install yumdownloader pigz yumdownloader centos-release mkdir /root/diskless # centos-release contains things like the yum configs, and is necessary to bootstrap the system rpm --root=/root/diskless -ivh --nodeps centos-release-5-7.el5.centos.x86_64.rpm yum --installroot=/root/diskless -y install basesystem filesystem bash kernel passwd cd diskless # This next line is important, your system won't boot without it ln -s ./sbin/init ./init echo NETWORKING=yes > etc/sysconfig/network chroot . pwconv # Set your root password passwd exit find | cpio -ocv | pigz -9 > diskless.cpio.gz
Now, take your newly created diskless.cpio.gz file, and the vmlinuz file from your chroot’s /boot/ directory, and copy them into your TFTP root. Assuming you are using PXELinux to boot this, you would need a menu option like this:
label diskless # Change the name here to match your actual kernel kernel vmlinuz append initrd=diskless.cpio.gz
If you are using SysLinux >= 5.10, you can make this process faster by grabbing the files via HTTP instead.
label diskless kerenl http://YOURSERVERHERE/vmlinuz append initrd=http://YOURSERVERHERE/diskless.cpio.gz