Unattended guest install with a local kickstart

Up until recently, I was doing all my unattended installs to provision linux guests with a kickstart hosted over http. Now, with this neat flag ‘–initrd-inject‘ in virt-install , guests can be created using a local kickstart file. This is available in python-virtinst-0.500.4-1 and above)

Here is the invocation, it assumes network bridging is configured. Refer this to quickly configure bridging (if you haven’t already).

This creates a minimal guest w/ these specs: 20G disk image(RAW format); 2GB ram ; 2 Virtual CPUs.

set -x

# Note: Replace this with your local Fedora tree if you have one.
tree= http://download.fedoraproject.org/pub/fedora/linux/releases/15/Everything/x86_64/os

virt-install --connect=qemu:///system \
    --network=bridge:br0 \
    --initrd-inject=/export/fed-minimal.ks \
    --extra-args="ks=file:/fed-minimal.ks \
      console=tty0 console=ttyS0,115200" \
    --name=f15testbox \
    --disk /var/lib/libvirt/images/f15testbox.img,size=20 \
    --ram 2048 \
    --vcpus=2 \
    --check-cpu \
    --accelerate \
    --hvm \
    --location=$tree \

Also a serial console(ttyS0) is configured so that all the booting/package-install process(complete install should take around around 4-5 mins) could be seen from the shell.

Later on, for remote management using libvirt, you can connect to guests using:

  $ virsh console f15testbox 

And the contents of the kickstart file ‘fed-minimal.ks’. This is the smallest possible install:

# Minimal Kickstart file
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
#Choose a saner password here.
rootpw testpasswd
firewall --enabled --ssh
selinux --enforcing
timezone --utc America/New_York
#firstboot --disable
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH"
clearpart --all --initlabel

#Just core packages

I placed all the above in a quick script

A note on bridging, network device names:
With the recent Fedora 15 feature Consistent Network Device Naming , network device names from here on would be renamed from ethX to something like emX . Refer the Fedora test day for more information and a script to determine if your system is impacted due to the Biosdevname change. (I had to do this for my DELL optiplex Xeon test box.)



Filed under Uncategorized

6 responses to “Unattended guest install with a local kickstart

  1. Nice script, I was about to write the same using pxe, libvirt api and so on, this helped me to finish sooner.

  2. Pingback: Creating a Qcow2 virtual machine | Kashyap Chamarthy

  3. Hey, this is exactly what I was looking for! :)

  4. Drax

    Thanks, –initrd-inject is exactly the parameter I needed for my install to take into account a local .ks file!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s