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.
#!/bin/bash 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 \ --nographics
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 install text reboot 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" zerombr clearpart --all --initlabel autopart #Just core packages %packages @core %end
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.)
6 responses to “Unattended guest install with a local kickstart”
Nice script, I was about to write the same using pxe, libvirt api and so on, this helped me to finish sooner.
Glad it helped :) . Share your script(if you can) for the benefit of rest of the community.
is there a bug using the kickstart file as described here ? http://fedoraproject.org/wiki/QA:Testcase_Kickstart_File_Path_Ks_Cfg
Pingback: Creating a Qcow2 virtual machine | Kashyap Chamarthy
Hey, this is exactly what I was looking for! :)
Thanks, –initrd-inject is exactly the parameter I needed for my install to take into account a local .ks file!