Monday, June 29, 2009

Xen Kickstart

Below is an example of passing a kickstart config file to virt-install. It took a lot of searching to find how to do this and it is not in the man page. The trick is to use -x (for extra) and then pass it "ks=$URL". The following command will produce a VM named xen-guest with 2 CPUs, 2G of RAM and 8G of disk which will be installed from a kickstart config file:
name="xen-guest"
cpu="2"
ram="2048"
disk="8"
virt-install \
--paravirt \
--file=/var/lib/xen/images/$name.img  \
--name $name \
--vcpus=$cpu \
--ram $ram \
--file-size=$disk \
--nonsparse \
--check-cpu \
--nographics \
--location=http://kickstart.server.com/rhel5.3/ \
-x ks="http://kickstart.server.com/xen.cfg"
Note that the --location option contains the contents of a mounted ISO file, not the ISO file itself. I.e. it was made by mounting the ISO file for the distro as a loop back device inside of /var/www/html/rhel5.3. It is from this mounted ISO file that virt-install downloads the initrd and kernel to boot from and start the install. The kickstart file is then followed and should contain where to get the medium for the install. I did this because I wanted to have a VM which was based on a config which is standard to all of my servers. However, now that I have a Xen guest that I like I've just been using virt-clone and variations of my backup script to create copies and move them between servers.

No comments: