February 20, 2014

Automatic RHEL 6 Installation with Kickstart

Introduction

Today the requirement are higher to quicker responds to the market. For a computer operation that means, they must be quicker to bring up new machine. The Red Hat solution for this is to use kickstart to standardize and automate the installation of a new RHEL instances.

The simplest way to create a working kickstart file is to actually install a new system (the way you want) and then use the kickstart created by anaconda to install new machine with.

The more advanced way is to start from scratch and use the system-config-kickstart tool and create you kickstart file. But there are some shortcoming with this tool and that is it can not handle LVM.

The pragmatic way is to start from a anaconda generated kickstart file and then edit with system-config-kickstart and finally manually add the LVM partition.

Here I will show you the easy way and use the anaconda generated file.

Prerequisite

Lets get started and install a new RHEL instance the manually way. We will install this machine as a virtualized machine and as hypervisor we will use KVM.

The requirement for this machine are:

  • 8 GB Disk Space
  • Basic Storage Devices
  • Use All Space

We will select the last checkbox 'Review and modify...', so we can see what is actually done.

What we see above is that two primary partitions are created - vda1 and vda2.

  • vda1 will contain standard ext4 file system for boot. The size of 500 MB is good for boot partition and should rarely be changed.
  • vda2 will be formatted with LVM and will fill up the rest of the available disk. This is also good.

The next step is the logical volumes: lv_root and lv_swap.

Note the few partition that are here created. For a server installation you would probably create more partitions, e.g. a separate partition for /var/log directory for a production server and for desktop installation you would probably create a separate partition for /home. But here we will keep to the basic suggested partition layout.

The second thing that is noteworthy is the small swap space. The thumb rule for a minimal installation production server is:

  • < 2GB RAM, use 2 * RAM
  • >= 2GB RAM, use RAM + 2GB

But remember these are not hard rules and dependce how often you will restart you system. For a desktop installation you will get away with smaller swap space.

Finally we will select to install a minimal installation. When installation is finish we will end up with a anaconda generated kickstart file located in /root/anaconda-ks.cfg.

Kickstart file

To make this kickstart file automatic we need to do three things:

  1. Uncomment the LVM partitioning. I also renamed the volume group to vg_rhel6.
  2. Add zerombr, to answer yes to the prompt question that all existing partitions will be destroyed.
  3. And finally automatically restart the system after installation.
# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
cdrom
lang en_US.UTF-8
keyboard sv-latin1
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$...$...
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone --utc Europe/Stockholm
bootloader --location=mbr --driveorder=vda --append="crashkernel=auto rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
zerombr
clearpart --all --drives=vda --initlabel

part /boot --fstype=ext4 --size=500
part pv.253002 --grow --size=1
volgroup vg_rhel6 --pesize=4096 pv.253002
logvol / --fstype=ext4 --name=lv_root --vgname=vg_rhel6 --grow --size=1024 --maxsize=51200
logvol swap --name=lv_swap --vgname=vg_rhel6 --grow --size=819 --maxsize=819

reboot

%packages
@core
@server-policy
%end

Test

The last step is to test it. First we need to make it accessible during installation. The easiest way to do that, is to use either a FTP or HTTP server. There are also other ways, such as using a shared network disk, accessible via NFS or CIFS. But I would recommend using a known FTP server.

Now start a new RHEL installation. At the first menu, press TAB.

Then at the end enter 'ks=ftp://<server>/<path>' and press ENTER.

Reference

No comments: