Installing a new OS from scratch (physical or virtual) sucks.
From floppy drives to virtual clones, the process has always involved manual instructions and cold coffee. In the Linux scenario, PXE boot can help a little bit.
Basically, PXE is a protocol that allows machines to get something from network booting, usually an image.
What it means for OS deployment is that it can pass a kernel image to the machine over the network with arguments, such as local repositories and configuration files, allowing a full remote and automated installation.
This video contains a good explanation.
You’re gonna need a DHCP, TFTP, HTTP and NFS server.
The DHCP tells the machine where to find the boot image;
The TFTP hosts the boot, kernel and initrd images. It has a menu file with all the arguments for the OS installation;
The NFS has the CentOS installation files (extracted ISO);
The HTTP has the Ubuntu files (extracted ISO) and a the seed files (this files contains the installation arguments, like timezone, disk layout and so on).
In the DHCP server, you must setup two options:
next-server with the TFTP server IP;
filename with the PXE boot image.
The TFTP server hosts some files:
pxelinux.0: the binary boot image;
kernel/initrd: kernel/initial ramdisk images, downloaded to the machine over the network;
menu.c32: the binary menu used to choose the OS to install;
pxelinux.cfg/default: displays a menu with the location of the kernel images and arguments. Like a grub file;
This menu generates this boot screen:
The NFS server exports the installation files from CentOS. It is actually the ISO extracted.
The webserver hosts the seeds and Ubuntu installation files (again, the ISO extracted).
Instead of manually typing the parameters during the installation process, the seed files allow you to pre configure it.
CentOS/RHEL has different names and syntax. The firts one’s called Kickstart File (KS) and the second Preseed file. Here I am going to post what I’m using in my lab, but the official documentation in the references has all the options available.
CentOS/RHEL KS Seed
All together now!
How does it all work together?
The machine makes a network boot.
The DHCP server delivers an IP address, a TFTP address and the file to boot.
The machine locates the TFTP server and downloads the boot image with a menu file.
The menu is displayed and the user chooses one option.
By the option, the kernel/initrd images are downloaded with the specific parameters.
The kernel loads the seed file, which shows the installation options and where the files are.
The installation begins, download the files, prepare the OS and finishes.
Machine reboots. The OS is ready to be used.
Even though it’s cool, this proccess has too many parts that may fail. If it’s not working, here’s a list of things to look out:
Machine boot order;
IP address/names of every server;
Firewall rules (TFTP, HTTP, NFS);
TFTP configuration and access;
DHCP configuration and IP lease;
HTTP configuration and access;
Location of images, source files;
Files and References
These files are on my GitHub (they may be slightly different from the post):
The seed files have a lot of parameters. You can read: