Obviously if you are dealing with a large number of servers and VMs, using RPM repositories with PXE, xenpvnetboot or templates is the way to go. But if you are dealing with only a few VMs on your laptop or with manual server installation, custom ISOs are simple and very fast. You can literally create one in less than 10 minutes. This first part will be presenting how to customize an ISO with a simple kickstart file. It will be using the Oracle Linux 7 Early Adopter ISO but other Redhat Based distributions and other releases are not much different...
Extracting the distributionIn order to customize the distribution, you must download it and extract its content to a directory; we will use a directory named
mkdir /tmp/iso sudo mount -o loop \ linux/OracleLinux-R7-U0-Server-x86_64-dvd.iso \ /tmp/iso [sudo] password for gregory: mount: /dev/loop0 is write-protected, mounting read-only mkdir OL7 sudo cp -Rp /tmp/iso/* OL7 sudo umount /tmp/iso
Adding a kickstart fileTo customize the ISO, add a kickstart file to the root of the distribution. You should be able to manage most aspects of the installation from that file and the various kickstart directives. If you don't, you should even be able to deploy and execute custom scripts. Below is an example of a configuration file that:
- perform the installation from the CDROM
- configure the first available network link with DHCP
- change the keyboard to french
- define the root password as manager
- disable SELinux
- set the timezone
- erase the content of /dev/sda and install Linux on it with the default layout
- avoid running the initial setup program
- shutdown the server once the installation done
cd OL7 sudo cat ks.cfg install cdrom lang en_US.UTF-8 keyboard fr network --onboot yes --device link --bootproto dhcp --noipv6 rootpw manager firewall --service=ssh authconfig --enableshadow --passalgo=sha512 selinux --disabled timezone Europe/Paris --isUtc --nontp bootloader --location=mbr --boot-drive=sda text skipx zerombr clearpart --all --initlabel autopart firstboot --disabled poweroff %packages @base @core %end
Customizing the boot menuYou can add a menu in the
isolinux/isolinux.cfgfile so that you can boot with the kickstart file as a parameter. Add the section below to the file:
label auto menu label Oracle Linux 7.0 ^Kickstart install menu default kernel vmlinuz append initrd=initrd.img inst.ks=cdrom:/ks.cfg inst.stage2=hd:LABEL=OL-7.0\x20Server.x86_64
Don't forget to remove the
menu defaultdirective from the menu it is attached to; If you want to speed up the installation, you can also change
It's important you reference the disk label in the
inst.stage2as you will name it when creating the ISO file.
Rebuilding the ISOTo end with the process, create the ISO from the directory you've been working with, i.e.
sudo mkisofs -r -T -J -V "OL-7.0 Server.x86_64" \ -b isolinux/isolinux.bin -c isolinux/boot.cat \ -no-emul-boot -boot-load-size 4 -boot-info-table \ -o /tmp/OracleLinux7.iso OL7/ sudo implantisomd5 /tmp/OracleLinux7.iso checkisomd5 /tmp/OracleLinux7.iso
If you don't have access to the command above, make sure the genisoimage and isomd5sum RPMs have been installed on your system.
Testing your ISOLast but not least, you can test your new installation as well as the associated options:
Redhat Enterprise Linux 7
Chapter 23. Kickstart Installations