Thursday, 9 June 2011

Install Red Hat Enterprise Linux automatically using Kickstart

Kickstart allows you to install the Red Hat automatically, this can be very useful if you have many servers or workstations that share the same configuration, e.g. an HPC cluster, a computer lab with many workstations or for virtualized environments.

By default, the Red Hat installer, anaconda, will write a kickstart file to the /root directory. This file, anaconda-ks.cfg contains the details needed to install your server, so you could consider it an kickstart image of your server.

Note that this also includes the root password, which should be encrypted by default. Assuming that you want to change this, which you should, you could either create a dummy user and look at the encrypted password in /etc/shadow or use grub-md5-crypt to generate a md5 encrypted password.

The simplest way of starting a kickstart installation does involve a manual step, and that is to indicate where the ks file is.Thus, when you have booted up and are presented with this screen:

Make sure you press tab and edit the line so that it points to your ks file, this document gives you a list of different ways of sharing your ks.cfg so that it is accessible to for installation, like this, where I have made the ks.cfg available via a web server.



This is all well and good if you have a couple of machines or probably good enough for the exam, but if you have hundreds of machines you actually want to automate the whole process. The way to do this is to customize the boot iso, so that it boots your ks.cfg file by default.

Mount the Red Hat boot iso to a directory called /iso and amend the /iso/isolinux/isolinux.cfg file, so that the source of the ks.cfg file is added to the default menu line, e.g.
append initrd=initrd.img ks=http://myserver/myksfile.cfg
Change directory to /iso and run the following command:
mkisofs -J -T -o ../ks.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -m TRANS.TBL .
This will create an bootable iso called ks.iso in /. You can now use this iso to automate the deployment, without the need to provide a ks file location every time.
You can of course copy your ks.cfg file to the /iso directory and just use it from there, thus negating the need for a network server to be available, in this case the line above will need to be:
append initrd=initrd.img ks=cdrom:/ks.cfg
The advantages of using a network server (web, ftp, share) is that you can change the kickstart file without the need to burn a new CD, good if you are a cheapskate like me :)

No comments:

Post a Comment