Diskless Slackware Installation using NFS and PXE
Project: Run Slackware on a diskless machine using TFTP, NFS and PXE to boot over the network.
This project requires two computers. The first will be called SERVER and the second will be CLIENT. At the conclusion of the project SERVER will have an installation of Slackware that CLIENT boots over the network. The IP address for SERVER is 192.168.3.1 and CLIENT is 192.168.3.2
SERVER Configuration
The first step is to make a fresh install of Slackware in a new directory. Obtain the Slackware installation ISOs for the version you would like to install. The examples use the Slackware 12.0 CD sets but the instructions could easily be adapted to any version or the installation DVD.
Don’t bother burning the ISOs to disc. Create a directory in the same folder where the ISOs are and mount the first one using loopback.
root@SERVER:~/slackware-12.0# ls slackware-12.0-install-d1.iso slackware-12.0-install-d3.iso slackware-12.0-install-d2.iso root@SERVER:~/slackware-12.0# mkdir tmp root@SERVER:~/slackware-12.0# mount -o loop \ > slackware-12.0-install-d1.iso tmp
Create the directory /nfsroot for the the new installation. This can easily be moved to a new or sub directory later if desired. Set the environment variable ROOT to this directory so when the packages are installed in later steps they will install to /nfsroot.
root@SERVER:~/slackware-12.0# mkdir /nfsroot root@SERVER:~/slackware-12.0# export ROOT=/nfsroot
The next step is to perform the actual installation. For each disk set to be installed change to the directory containing the set and run the install-packages script. Make sure you have set the ROOT environment variable or you will be installing packages into your current installation.
root@SERVER:~/slackware-12.0# env | grep ROOT ROOT=/nfsroot root@SERVER:~/slackware-12.0# cd tmp/slackware/a root@SERVER:~/slackware-12.0# ./install-packages
Select the packages you want installed and Select OK. The packages will be installed to /nfsroot. Change to the other disk set directories to install and run the install-packages script to continue installation. I recommend at least A and L disk sets to get a usable system.
The only file that needs to be created in the new installation is fstab. The Slackware setup script creates an fstab during a normal install. This would be a good time to add entries for the CDROM and floppy on CLIENT. Edit the file and add the line to mount the NFS export on /.
192.168.3.1:/nfsroot / nfs noauto 0 0 /dev/cdrom /mnt/cdrom auto noauto,owner,ro 0 0 /dev/fd0 /mnt/floppy auto noauto,owner 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 proc /proc proc defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0
There are a few more configuration changes that need to be made on SERVER. It must be running tftpd, serving DHCP requests, and have the ability to export directories using NFS. Slackware provides all of these features, they just need to be configured and enabled.
tftp Server
The tftp server can be run from inetd or as a daemon. I prefer to use inetd so open /etc/inetd.conf and find the line for tftp. Remove the comment indicator (#) from the beginning of the line. Note the directory /tftpboot from which the Linux kernel and PXE configuration files will be served. Restart inetd after making the changes.
tftp dgram udp wait root /usr/sbin/in.tftpd in.tftpd -s /tftpboot -r blksize root@SERVER:~# /etc/rc.d/rc.inetd restart
NFS
Now the /nfsroot directory needs to be exported via NFS. Edit the /etc/exports file and add a new line for the export. After exports has been modified run exportfs.
/nfsroot 192.168.3.2{rw,no_root_squash,no_all_squash,no_subtree_check}
root@SERVER:~# exportfs -av
exporting 192.168.3.2:/nfsroot
DHCP
The dhcp server must be updated to tell CLIENT about the tftp server. A number of lines need to be added to /etc/dhcpd.conf. They are the DNS server IP, network gateway IP and the specific options for CLIENT. If you don’t know the MAC address for CLIENT you can get it from a later step. Come back and modify dhcpd.conf then restart dhcpd.
# dhcpd.conf
#
# Configuration file for ISC dhcpd (see 'man dhcpd.conf')
#
option domain-name "example.com";
option domain-name-servers 192.168.3.1;
option routers 192.168.3.1;
subnet 192.168.3.0 netmask 255.255.255.0 {
server-name "SERVER";
host CLIENT {
# hardware ethernet is the MAC address of CLIENT's NIC
hardware ethernet 00:40:63:C0:AB:XX;
fixed-address 192.168.3.2;
next-server 192.168.3.1;
filename "pxelinux.0";
option root-path "/nfsroot";
}
}
Restart dhcpd
root@SERVER:~# /etc/rc.d/rc.dhcpd restart
PXE
The last step in configuring SERVER is setting up the PXE environment. Create the /tftpboot and /tftpboot/pxelinux.cfg directories
root@SERVER:~# mkdir -p /tftpboot/pxelinux.cfg
Copy the contents of the boot directory of the new Slackware install. Create a softlink from the kernel you want to use to bzImage.
root@SERVER:~# cp -a /nfsroot/boot/* /tftpboot root@SERVER:~# cd /tftpboot root@SERVER:/tftpboot# ln -s vmlinuz-huge-2.6.21.5 bzImage
Copy pxelinux.0 from the current file system to /tftpboot
root@SERVER:~# cp /usr/lib/syslinux/pxelinux.0 /tftpboot
Create a PXE config file in the pxelinux.cfg directory for CLIENT. The name of the config file is the IP of CLIENT in hexadecimal format. You can use gethostip to calculate the value but it will be C0A80302 for 192.168.3.2.
root@SERVER:/tftpboot/pxelinux.cfg# gethostip 192.168.3.2 192.168.3.2 192.168.3.2 C0A80302 root@SERVER:/tftpboot/pxelinux.cfg# touch C0A80302
Edit the config file. (The APPEND line includes ip=…, it shouldn’t be on a separate line it just looks like it here)
# C0A80302 DEFAULT linux LABEL linux SAY Now booting the kernel from SYSLINUX ... Good Luck! ... KERNEL bzImage APPEND ro root=/dev/nfs nfsroot=192.168.3.1:/nfsroot ip=192.168.3.2:192.168.3.1:192.168.3.1:255.255.255.0
CLIENT configuration
There isn’t much to do on CLIENT. Boot it up and go into the BIOS configuration. Find the option to boot from the network and move it to the top of the list. Save the BIOS settings (F10) and reboot. When CLIENT is booting it should display the MAC address. If you didn’t know it when configuring dhcpd it’s time to go back and update /etc/dhcpd.conf.
After booting CLIENT run the scripts that are usually installed at the end of a normal Slackware setup. Run pkgtool and select Setup. Select the scripts to run and select OK. Do not select liloconfig since PXE is the bootloader, not lilo.
There are a lot of ways to optimize this setup. This is merely an example to get you started. If you are running the same version of Slackware on SERVER and CLIENT then exporting some directories such as /bin and /lib over NFS and then mounting them on CLIENT could help save some disk space.
Posted: December 25th, 2008 under Slackware.
Comments: none