There are many ways to get a Linux system to boot from the network. There are also many ways to boot a diskless Linux system. Being both diskless and booting from the network was a little more challenging, given my constraints and unwillingness to go to more effort than necessary.
One of the best ways to get Linux booted diskless from the network is to simply set up a DRBL server. Unfortunately, I have Cobbler installed for provisioning, and while it’s possible that Cobbler and DRBL can play together, I wasn’t in the mood to figure out how, so, with regrets I had to put DRBL aside.
I played with real machines and virtual machines, looked at various distros, even considered BSD. My primary goal was simply to get a physical machine that boots off the LAN in an era where you can no longer expect to have a floppy or CD drive to boot from and can’t resort to booting from a thumb drive. Just to make the task even more challenging, I’m running Xen 3 para-virtualized systems. Proper support for VMs installing off virtual DVD/CD drives and netbooting is something that I won’t have until Xen 4 takes over my servers. Which will require replacing the older boxes that don’t have full hardware VM support.
My preferred OS for this experiment would have been CentOS 5.10. Unfortunately, I managed to get so far as a kernel panic and no further. So after much swearing, I considered using Debian or Ubuntu. These are systems that have a lot of stuff written up on what I wanted to do, but since my physical boxes are all CentOS, the standard recipes were useless. I’d hoped to be able to debootstrap and chroot from within CentOS and go from there, but without the ability to get an actual Debian up and running, that wasn’t sufficient.
So try one more thing. I determined that I was going to bring up an actual Debian system and follow existing recipes. Since Xen 3 makes it excruciatingly difficult to get a cold iron VM setup going, I went to my desktop and cranked up VirtualBox. I downloaded the Debian latest “mini.iso” and did a VirtualBox install-from-iso to a local VM.
Now that I had a Debian VM running, I needed to mod it to support being booted from the LAN and install the OS image onto my actual boot server.
LAN boot support was simple. All that’s required is to modify Debian for my purposes was to alter its /etc/fstab, make a netboot initial ramdisk, and modify the /etc/network/interfaces file. I used the instructions I found here: http://jeffwelling.github.io/2011/05/02/Diskless-Debian-Squeeze.html.
To make a new initrd requires the mkinitrd-anaconda package, but that seems to have been included in the mini.iso, so I didn’t have to install it. Just run it. Again, I got the instructions from the URL listed above.
I did have to install rsync (apt-get install rsync). I needed rsync to clone the modified OS to my server, where I had a “debian” directory waiting to receive it:
rsync -avz -e 'ssh' --exclude=/proc --exclude=/sys / boothost:/export/osimages/debian/
Probably should have excluded /dev as well, but no harm done. Having successfully cloned from my live VM, I shut the VM down. I no longer need it.
Most howto’s spend a lot of time on telling you how to setup tftp booting, dhcp, and nfs shares. Feel free to consult one. I won’t waste space repeating the process. Besides, I already had most of that in place at this point.
The one thing I did have to change in that area was adding the new OS image as an NFS export:
Added this line to /etc/exports and restarted NFS to make it visible.
Now the fun begins. I had a directory under the tftpboot tree that remote booting is done from, so I added a debian subdirectory and copied the netboot ramdisk and vmlinuz files from the Debian export’s boot directory,
Then, I updated the /tftpboot/pxeliniux.cfg/default file containing the default grub menu and added the following boot stanzas:
label Debian Diskless
APPEND root=/dev/nfs initrd=/images/debian/initrd.img.netboot nfsroot=10.0.1.2:/export/osimages/debian ip=dhcp rw
One last thing: Because of the way I cloned the Debian OS onto the NFS mountpoint, the cloned image lacked /proc and /sys directories. So I created new, empty ones for the network boot to use as mount points.
OK. Now the fun begins. Sat down at the client machine, made sure its BIOS was set up to do PXE booting, and fired it up. Menu came up, selected the “Debian Diskless” choice on the Grub menu and we’re off to the races!
This system image was set up to be the one and only netbooted image. It’s good for disaster recovery, but if I actually wanted multiple clients without the overhead of cloning the entire OS image for each client, I’d need to set it up as a master read-only image with snapshots. The “pxeos” command is supposed to help with that.
Plus, I’d like to be able to netboot images as Xen 3 VM guests. For that, I’ll probably have to steal the netboot scripts from Xen 4 and hack on them.