Have you ever wanted to run a discless Linux box? Maybe, like me, you have a Windows PC for someone else in the family that you want to run Linux on, you might want to take advantage of an existing backed-up RAID array and avoid additional hard discs, or you might simply want a cheaper or quieter PC.
Most PCs these days have a BIOS that supports PXE booting, this will allow you to boot a simple file from a server. Linux has an amazing feature where you can create a kernel and initrd (initial ramdisc) which can be booted via PXE, which will then start your system up using an NFS share as the root filesystem with no need for local storage at all.
There are various HOWTOs on the ‘net explaining this, however these all seemed to make two assumptions that caused me problems…
- They basically involved installing to a local hard disc, then copying the image onto a server
- They assumed that everything (client and server) was running exactly the same distribution version
Now I intended to create a few of these and didn’t want to be stuffing around with hard discs all the time, plus I’m a bit of a purist in some ways and wasn’t keen on installing temporary hard discs just for installation if there was a better way. I also had the issue that all my servers were running 64 bit versions, whereas my clients were only capable of 32 bit. In addition, since I was planning to do a few of these I wanted to use a local (on my home LAN) Yum repository to reduce bandwidth usage and to speed up the installs.
So, here is my step-by-step procedure for installing and running a discless Fedora system (I used Fedora 19) with a custom repository, with different architecture between server and client, and without any temporary client hard discs. You will need to be logged in as root for at least some of these steps.
- Create a new directory on the server for the root filesystem of the remote client. I called mine “remoteFamily”
- Create a repository location in the server’s /etc/yum.repos.d/ directory. I called mine “fedora32-local” as it was a 32bit repository (as opposed to the server’s usual 64bit one). This new repository configuration should have “enabled=0” to stop the server from using it.
- Now use yum to install @core (which is basically a minimal installation) from only the 32bit repository and using /mnt/remoteFamily as the root directory.
- Now that we have a minimal install (including yum repo config) yum will use the client’s repository configuration, so we need to copy the config for the local repo to the client’s yum config directory.
- Now to install a few items which are critical for NFS root systems…
yum --installroot=/mnt/remoteFamily --disablerepo=* --enablerepo=fedora32-local install nfs-utils
Dracut for creating the initial ramdisc images for booting.
yum --installroot=/mnt/remoteFamily --disablerepo=* --enablerepo=fedora32-local install dracut-network
And the kernel.
- Create an /etc/fstab file with a reference to the nfs root directory on the server. This is used by dracut later on to link what is mounted on bootup, so it is very important that this is correct. If this changes, you will need to re-run dracut and copy the new initrd onto the tftp server
- Enable the root user (with no password) by deleting the “x” between the colons
- Disable SELinux by changing to “disabled” in the config file.
- OK, now chroot to the client’s root so that kernel and modules are able to be found in their final locations, and you can set passwords
- Create the ramdisc image. Note that we explicitly define the kernel image, otherwise the server’s currently running kernel would be used. If you used a different version of Fedora then you will need to look in /boot to find which kernel version to use (they start with “vmlinuz”).
- Set root’s password.
- Disable a couple of services that cause difficulty when you are using NFS as root.
- Exit from the chroot
- copy the kernel and initrd to server, don’t forget chmod444
yum --installroot=/mnt/remoteFamily --disablerepo=* --enablerepo=fedora32-local install @core
cp /etc/yum.repos.d/fedora32.repo /mnt/remoteFamily/etc/yum.repos.d/
yum --installroot=/mnt/remoteFamily --disablerepo=* --enablerepo=fedora32-local install kernel
This should contain something like…
192.168.131.3:/mnt/remoteFamily / nfs defaults 1 1
dracut --filesystems nfs -H --fstab -f /boot/initramfs-3.9.5-301.fc19.i686.img 3.9.5-301.fc19.i686
systemctl disable firewalld.service
systemctl disable NetworkManager.service
Now the client should be able to boot up.
Once the client has booted you will get a plain old command line login prompt, you should be able to log in and then install more packages as you would with a “normal” installation.
A couple of (in my opinion) packages that are essential, but aren’t in the minimal install.
- Net-Tools (such as ifconfig)
yum install net-tools
- Mlocate (with the “locate” and “updatedb” programs)
yum install mlocate
Now, if you want to install X with graphical logins, follow the instructions Here.