Installing Linux on a single box is easy, but try extending that to a room, or even building, full of computers and you’ll face a massive headache. To save you from running back and forth between all those computers, we’ll show you how to set up an automated network install.
This project has two main stages. Firstly, a working boot server must be established. Secondly, a Kickstart file must be created in order to satisfy the installer and ensure that it does not require any interaction from the administrator.
Some solutions of this type favour making a bootable respin of the installation medium, but the problem with that method is that it becomes extremely tricky to make changes to the setup on installation day. So instead we’re going to look at an approach that works from within a normal Linux installation, Fedora in this case. If you need it to be portable, no problem – just install Linux to a flash drive and work from that.
It ought to go without saying, but… be a bit careful when connecting the server up to the switch/router of the clients. When fully configured, this machine will happily wipe and configure anything with which it comes into contact.
Working Fedora box
Two network adaptors
Fedora installation DVD ISO
Network of at least two machines
Step by step
These examples use Fedora Linux, but any Red Hat-derived distro should work. If you install to a removable medium, make sure that you have enough free space to make a copy of the installation DVD ISO. 16GB of free space is a sensible minimum.
Make yourself root (type su into a terminal), then use YUM to add to extra packages withyum install dhcp tftp tftp-server xinetd. You’re going to be working as root most of the time, so, if you need to launch a GUI tool suchasgedit,usesudo gedit(asroot).
Set up network
These examples use a machine with two network adaptors – one for connection to the outside world, and one to connect to the machines that need to boot from it. The second network card probably doesn’t have an IP address assigned yet, so we’ll set this via the GUI.
Configure second adaptor Right-click on the network icon and select Edit Connections…. Now locate the second adaptor, click on Edit and select the IPv4 Settings tab. Change the method from Automatic (DHCP) to Manual. Add a static IP address for your adaptor. For example, if your first adaptor is on 10.0.1.1, adding the second adaptor with an address of 10.0.5.1 and a netmask of 255.255.255.0 will give you space to connect up to 255 machines to the boot server.
DHCP assigns IP addresses and starts the boot process on clients. Visit the official Fedora documentation (tinyurl.com/luad-dhcp) site to cut and paste an example DHCP configuration for a boot server. Load the existing file (/etc/dhcp/dhcpd.conf) into a text editor.
Modify the example dhcpd.conf to match your network. The subnet for our example would be changed to 10.0.5.0, and routers is the same address as your second network adaptor. Setting range dynamic-bootp to 10.0.5.50 10.0.5.100; gives space for 50 machines. The parameter next-server should be set to the same address as your second network adaptor. Change filename “linux-install/pxelinux.0”; to filename “pxelinux.0”; Save the file and then start the server with systemctl start dhcpd.service.
TFPT is a basic file transfer protocol that the NIC firmware uses to fetch the bootloader. Load /etc/xinetd.d/tftp and change the line disable = yes so that it reads disable = no. TFTPD is managed by xinetd, so start with systemctl start xinetd.service.
PXELINUX is the Linux bootloader which works over Ethernet. To get it, install SYSLINUX withyum install syslinux.Thefileweneed is pxelinux.0. Copy it to the TFTP folder with cp /usr/share/syslinux/pxelinux.0 /var/ lib/tftpboot/. Type mkdir pxelinux.cfg to create the configuration directory.
Type cd /var/lib/tftpboot/. Make a directory with mkdir pxelinux.cfg. Within this directory, create a text file called default. Add the following lines DEFAULT netinstall, LABEL netinstall, kernel vmlinuz, append initrd=initrd.img repo=http://10.0.5.1/fedora/, implicit 1 and prompt 1 so that it looks like the picture above. If you’re feeling adventurous, try adding prompt 0 so that clients won’t wait for user confirmation before beginning the install. Be careful with that option!
Configure web server
Add Apache 2 with the yum install httpd command, and start it with systemctl start httpd.service. Test that it is up and running by navigating a web browser to http://10.0.5.1. If everything’s working, you should see the Apache startup page.
Extract the ISO image
Create two directories: /var/www/fedora and /media/loop. Copy the Fedora DVD ISO image to the current directory and type mount -o loop -t iso9660 [path to ISO] /media/ loop. Use rsync to copy the files: rsync -v -a -H/media/loop/ /media/var/www/fedora.
Copy vmlinuz and initrd.img
Enter the directory that TFTP can see with cd /var/lib/tftpboot/. Execute wget http://10.0.5.1/fedora/isolinux/vmlinuz. Copying the file like this makes a good test that the server is working. Now retrieve initrd.img from the same directory.
Open the Firewall configuration application. Select persistent configuration. Add http, https, tftp and tftpclient to the list of trusted services. Select Reload firewalld from the Options menu.
Ready the clients
Enter the BIOS setup screen of a client PC and make sure that the boot order specifies network booting as the priority. When carrying out the installation, you will disconnect the router/switch from the internet and connect it to the boot server instead.
A connected machine should now boot from the server. If it doesn’t work, there are some things you can try. Does the machine that is attempting to boot indicate that it has been assigned an IP address? If not, the problem lies with DHCPD on the server, so recheck /etc/dhcp/dhcpd.conf.
If the client tries but fails to load a file called pxlinux.0, it is communicating with DHCP, but TFTP may not be working. Try using the command tftp 10.5.0.1 -c get pxelinux.0 on the server. If this retrieves the file, try executing it again on another machine. If the installer begins to boot, can find pxelinux.0, vmlinuz and initrd.img but stops at that point, try retrieving one of the files in /var/www/http/ fedora/manuallybyusingthewget 10.0.5.1/ fedora/[name of file] command.
Make services permanent
Control Fedora services with systemctl [command] [service]. The main commands you’ll need are start, enable to make permanent, and restart when you make configuration changes. This project requires running httpd.service, dhcpd.service and xinetd.service.
Create Kickstart file
A Kickstart file supplies the installer with answers to avoid prompting the user. To begin, create a file called ks.cfg in /var/ www/html/fedora/. Go to the official Fedora Anaconda/Kickstart page for a complete list of commands (tinyurl.com/luad-kickstart). When a Fedora system has been successfully installed, a (fully commented) Kickstart file is deposited in /root/anaconda-ks.cfg; this makes a good starting point for building your own. If you installed via the ISO, remove the line that sets install type to CDROM.
Configure Kickstart file
You must specify a root password using the rootpw command to avoid a prompt. You may want the installer to erase all partitions (or preserve some). The upgrade command causes the installer to upgrade the targets rather than carry out a fresh install.
Save your custom Kickstart file as /var/www/html/fedora/ks.cfg and then add ks=http://10.0.5.1/fedora/ks.cfg to the append line in your default file. By default, the finished target machines will begin in first-run mode and ask the user to specify details such as username and password on the first run.