Monday, May 25, 2015

Customizing Redhat/Oracle Linux 6 ISOs

Performing a complete Redhat/Oracle Linux installation when booting from an ISO is very neat. This is an easy and consistent method to quickly start virtual machines with Packer for VirtualBox, VMWare or Parallels.

You can find a complete example of how to do it with Redhat/Oracle Linux 7 in "Customizing Redhat/Oracle Linux CDROMs, ISOs and USBs". However, I had to use this method with release 6 of Oracle Linux this week and, as you can expect, some of the parameters have changed. That's why I've documented how to do it also with Release 6. It should not take you more than 15 minutes to customize your own ISO file and 5 minutes to perform a new installation...

Extracting the distribution

In order to customize the distribution, you must download it and extract its content to a directory; assuming the original ISO file is named OracleLinux66.iso, we will use a directory named OL6 below:
mkdir /tmp/iso

sudo mount -o loop OracleLinux66.iso /tmp/iso
[sudo] password for gregory: 
mount: /dev/loop0 is write-protected, mounting read-only

mkdir OL6
sudo cp -Rp /tmp/iso OL6
sudo umount /tmp/iso
Note:
Make sure you've kept the .treeinfo and .discinfo files as part of the directory copy

Adding a kickstart file

To 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 network 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
  • reboot the server once the installation is done and make sure you eject the DVD first
  • install some specific RPMs
cd OL6
sudo cat ks.cfg 
install
cdrom
lang en_US.UTF-8
keyboard fr
network --onboot=yes --device=eth0 --bootproto=dhcp --noipv6
rootpw manager
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Europe/Paris --isUtc
bootloader --location=mbr --append="rhgb quiet"
text
zerombr
clearpart --all --initlabel
autopart
reboot --eject
 
%packages
@base
oracle-rdbms-server-12cR1-preinstall
zip
unzip
%end

Customizing the boot menu

You can add a menu in the isolinux/isolinux.cfg file 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 6.6 ^Kickstart install
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=cdrom:/ks.cfg
Note:
Don't forget to remove the menu default directive from the menu it is attached to; If you want to speed up the installation, you can also change timeout 600 to timeout 60

Rebuilding the ISO

To end with the process, create the ISO from the directory you've been working with, i.e. OL6:
sudo  mkisofs -r -T -J -V "OL-6.6 Server.x86_64" \
    -b isolinux/isolinux.bin -c isolinux/boot.cat \
    -no-emul-boot -boot-load-size 4 -boot-info-table \
    -o /tmp/OracleLinux66-new.iso OL6/

sudo implantisomd5 /tmp/OracleLinux66-new.iso
checkisomd5 /tmp/OracleLinux66-new.iso
Note:
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 ISO

Last but not least, you can test your new installation as well as the associated options:


Bibliography
Redhat Enterprise Linux 6
Installation Guide
Chapter 32. Kickstart Installations

No comments:

Post a Comment