Xen with image disk files (instead of LVM)

xen

I am currently running virtualbox on linux to run some simple webserver linux hosts. This is because I like the portability and extra isolation security.

Because the host (and guests) are Ubuntu, and because it looks like Sun is winding down Virtualbox, I want to see if I can move to Xen. I installed the Ubuntu host Xen packages, rebooted, converted my virtualbox disk file into a raw partition, and created a .conf file. With some modest hand-editing to protect the innocent, it looked like this:

# ls -lth /home/me/Xen-VMs/domains/test.img
-rw-r--r-- 1 me me 20G Feb  3 16:02 test.img
# file test.img
test.img: DOS/MBR boot sector
# cat /etc/xen/test.conf
name="test"
bootloader="pygrub"
disk = ['file:/home/me/Xen-VMs/domains/test.img,sda,w']
memory = 2048

I then did an xl create /etc/xen/test.conf which worked (cause xl list showed test), and I could start it (xl reboot test) after I had memset the 0 domain. I then even got this VM started, but it always blocked or paused (and the network to the guest was not yet up). Well, maybe it is not a good idea to start with an existing VM. who knows what guest virtualbox addins the xen hypervisor is blocking for.

So I wanted to try Xen from scratch. I tried something similar following this guide,

xen-create-image --hostname=tutorial-pv-guest \
  --memory=512mb \
  --vcpus=2 \
  --dir=/home/me/Xen-VMs \
  --dhcp \
  --pygrub \
  --dist=wheezy

where I replaced the LVM with a raw dir, but that one died with an error in the creation. I tried the example in the xl perl script, but

# xen-create-image --size=2Gb --dhcp --dist=stable --dir=/home/ivo/Xen-VMs --hostname=testmexen
...
xt-install-image --hostname=testmexen --location=/tmp/y3U0xqhG18 --dist=stable --install-method=debootstrap --mirror=http://us.archive.Ubuntu.com/ubu
ntu/ --cache=yes --cachedir=/var/cache/apt/archives/ --arch=amd64 2>&1' failed with exit code 32512.

Digging deeper, this may or may not be the case

W: Cannot check Release signature; keyring file not available /usr/share/keyrings/debian-archive-keyring.gpg
I: Retrieving Release
E: Failed getting release file http://us.archive.Ubuntu.com/Ubuntu/dists/stable/Release
Running command '/usr/sbin/debootstrap  --arch amd64 stable /tmp/J06gK4zZ0i http://us.archive.Ubuntu.com/Ubuntu/ 2>&1' failed with exit code 256.

Not having a base makes it difficult for me to trace what is actually needed to get Xen to work.

  • Is Xen even the right tool for the job? That is, I want one raw image disk file that I can move around, if need be, to another computer, with good isolation of the guest from its host.

  • Is there a GUI (like the VirtualBox one) that shows me what's happening in my running but blocked VM?

  • Did I make any easily correctible mistakes here, especially in the "start-from-scratch" attempt?

advice appreciated.

Best Answer

I've been Xen for about 5 years and find excellent for my needs. To answer you questions:

Is Xen even the right tool for the job? That is, I want one raw image disk file that I can move around, if need be, to another computer, with good isolation of the guest from its host.

I use Xen and raw disks as part of a HA cluster, so the answer is yes.

Is there a GUI (like the VirtualBox one) that shows me what's happening in my running but blocked VM?

Yes. Libvirt. Actually developed for KVM, it works just fine with Xen.

Did I make any easily correctible mistakes here, especially in the "start-from-scratch" attempt?

Here's a little recipe that might make your life a bit less complicated. Firstly I convert VirtualBox HDDs to raw HDDs as follows:

qemu-img convert -f vdi -O raw vbDefault.vdi xenDefault.img

The Xen configuration (xenDefault.cfg) can be spare. You a need name, ram, vcpu and a HDD. That's it.

name = "xenDefault"

memory = 2048

vcpus=2

disk = [ 'file:/srv/xen/xenDefault.img,hda,w' ]

Now I can create a virtual machine.

xm create xenDefault.cfg

And I can see my virtual machine per

xm list

and connect to it using

xm console xenDefault

That's it. Try it out. Hope this was helpful.