Creating guests using xl in Xen

This post is about creating guests after Xen is installed. There are several ways to do that. But after using them this is the one that I preferred i.e. creating guest manually using xl. If you want a fancy GUI then one can use virt-manager but that going to create a mess if you installed Xen from source. So if you are installing Xen using source code then this is worth a try. 🙂 My mentors suggested and helped me to try it and I can say its pretty amazing and simple. So the following steps create a guest ubuntu-guest. The following steps create an disk image for the guest ubuntu-guest4.

sudo mkdir -p /var/lib/xen/images
sudo dd if=/dev/zero of=/var/lib/xen/images/ubuntu-guest4.img bs=1M seek=15096 count=0
sudo mkfs.ext4 -F /var/lib/xen/images/ubuntu-guest4.img (optional if using iso for installation)

Then create file /etc/xen/ubuntu-hvm4.cfg for configuration details of guest. Mine looks like the below.

In line stating the disk home/uma/Desktop/OS/ubuntu-12.04-desktop-amd64.iso should be replaced by the address of your iso file.

blog

xl create /etc/xen/ubuntu-hvm4.cfg

(This will open your guest console :D)

After installing OS you can shutdown the guest and change the disk line in /etc/xen/ubuntu-hvm4.cfg to

disk = [‘phy:/var/lib/xen/images/ubuntu-guest4.img,hda,w’]

And start using your guest. 😀