KVM: Install CentOS / RHEL Using Kickstart File (Automated Installation)

Kickstart is a network installation system for RHEL, Fedora and CentOS Linux distributions. Another good option is Cobbler which is a Linux provisioning server that centralizes and simplifies control of services including DHCP, TFTP, and DNS for the purpose of performing network-based operating systems installs. In this tutorial, I’m going to show you how to use kickstart file to install CentOS.

Create Kickstart file

An automated installation method to install CentOS / Fedora or RHEL is recommend to automate procedure. Using kickstart, a system administrator can create a single file containing the answers to all the questions that would normally be asked during a typical RHEL Linux installation. Use kickstart GUI tool called “Kickstart Configurator” (run system-config-kickstart command to start the tool) to create a file called ks.cfg as follows:

auth  --useshadow  --enablemd5
bootloader --location=mbr
clearpart --all --initlabel
firewall --enabled --port=22:tcp
firstboot --disable
keyboard us
network --device eth0 --bootproto static --ip --netmask --gateway --nameserver, --noipv6
network --device eth1 --bootproto static --ip --netmask --gateway --nameserver, --hostname centos.nixcraft.in --noipv6  
lang en_US
logging --level=info
url --url=http://mirrors.nixcraft.in/centos/5.5/os/x86_64/ 
rootpw --iscrypted $1$somepassword
selinux --enforcing
timezone  America/New_York
part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
part swap --recommended
echo ' via' > /etc/sysconfig/network-scripts/route-eth0
sed -i 's/LABEL=//& console=ttyS0/' /etc/grub.conf
echo 'S0:12345:respawn:/sbin/agetty ttyS0 115200' >> /etc/inittab
echo "ttyS0" >> /etc/securetty
echo 'IPV6INIT=no' >> /etc/sysconfig/network
echo 'install ipv6 /bin/true' >> /etc/modprobe.conf
) 1>/root/post_install.log 2>&1

Upload this file to a web server as ks.cfg. You can use nfs server too.

virt-install: Install CentOS using Kickstart

Type the following command:
# virt-install
-n centos
-r 2048
-w bridge:br0
-w bridge:br1
--disk path=/emc/kvm/centos.img,size=100
-l http://mirrors.nixcraft.in/centos/5.5/os/x86_64/
-x "ks= ksdevice=eth0 ip= netmask= dns= gateway="

The -x option is used to pass additional kernel command line to the installer when performing a guest install. The ks option sets ks file location and rest are networking options so that installer can fetch ks.cfg and do automated installation for you.

This entry is 5 of 14 in the CentOS / Redhat (RHEL) KVM Virtulization series. Keep reading the rest of the series:

  1. CentOS / Redhat: Install KVM Virtualization Software
  2. CentOS / Redhat: KVM Bridged Network Configuration
  3. KVM virt-manager: Install CentOS As Guest Operating System
  4. KVM virt-install: Install FreeBSD / CentOS As Guest Operating System
  5. KVM: Install CentOS / RHEL Using Kickstart File (Automated Installation)
  6. Troubleshooting KVM Virtualization Problem With Log Files
  7. KVM Virsh: Redirect FreeBSD Console To A Serial Port
  8. KVM: Starting / Stopping Guest Operating Systems With virsh Command
  9. Linux KVM: Disable virbr0 NAT Interface
  10. FreeBSD / OpeBSD Running in KVM Does Not Accept FTP Traffic
  11. KVM: Start a Virtual Machine / Guest At Boot Time
  12. KVM virt-install: Install OpenBSD As Guest Operating System
  13. Linux KVM: OpenBSD Guest Hangs At Starting tty Flags
  14. KVM Virtualization: Start VNC Remote Access For Guest Operating Systems

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.