First steps with Xen in my Debian notebook

For my Master‘s Systems Integration subject, students are expected to build a system with two virtual machines (a webserver and a database server) running in a Linux host, using external USB storage for the virtual machine files (using LVM) and usign KVM or Xen for the system virtualization (details here).

This practice is a multiple challenge for me, not only for my sysadmin skills (poor, but getting richer thanks to the contents of the subject and teachers, and also with lots of documentation out there), but also for my humble netbook, a Compaq Mini 110c with an Atom processor, with no virtualization instructions.

Hardware limitations

So this was my situation, and my approach:

  • No virtualization instructions, and 32bit processor, so I would use Xen for the virtualization, not KVM.
  • 1 GB of RAM so all my machines would be text-only, without GUI (on the other side, this is near to a real production environment).
  • I have two USB drives (4GB, and 2GB) so I would allocate initially small sizes for my systems, and if needed, add more storage later.
  • My installed systems are:
    • Supposedly preinstalled Windows XP in \dev\sda1 (but I broke it accidentally creating a LVM on it, and now I will leave it untouched until I have time and an external disk to image it and try to recover it).
    • Debian testing, minimal install in \dev\sda3 (I unselected all the options when debian-installer showed tasksel)
    • Debian stable (with GUI but quite a minimal install) in \dev\sda5
    • Debian testing  in \dev\sda6. This is the one that I use most, and is plenty of installed packages so if I find an error I would get crazy to diagnose it so I prefer not to put Xen on it.

I broke my Windows partition and the partition table some days ago; I recovered it with testdisk but although I can boot my Linux systems, the partition table is not 100% ok so for example I cannot run GParted, resize partitions, nor install a brand new system (debian installer does not recognize the partition table so it shows my disk as empty or corrupted). I will fix this later, now I need to go to the exercise, so I decided to use Debian stable in \dev\sda5 or Debian testing in \dev\sda3 as my Linux host.

Xen dom0 + domU, first try (in Debian Wheezy, ext4, + USB, ext3)

My Wheezy partition \dev\sda3 was ext4 formatted. As I was going to use LVM in an external USB drive, and the existing installation was minimal, I had to install lvm2 package in order to create the physical and logical volume in\dev\sdb1 (my USB drive). I formatted the logical volume as ext3.

I have a 3.2.0-2-686-pae kernel, and I installed xen-hypervisor-4.1-i386, xen-utils and xen-tools.

When you install Xen the system calls update-grub so GRUB will show several new entries: your original kernel, the kernel with xen included, and the Xen entry that means that not only the xen kernel is run, but also the Xen hypervisor.

I had GRUB installed in my MBR, so the update-grub call did not change my ‘real’ GRUB menu. I had to run grub-install /dev/sda so I got the Xen entries showed when I reboot my system.

When I booted my Xen kernel with the Xen hypervisor, “xm list” command showed my brand new dom0. I configured the required files in order to create a small virtual machine to host my webserver. With no GUI, 2 GB for disk image and 512 MB for RAM should be enough isn’t it? When I create the virtual machine (with xen-create-image and subsequent debootstrap) bad things began to happen: from time to time I was loosing the display (going black or with strange, coloured lines, see picture), and soon or later (I tried several times) I was getting “segmentation fault” errors, or ext3-fs errors.

I tried setting more or less memory to the virtual machine, and also with bigger and smaller disk sizes, and also in different USB drives, and also without using external storage and allocating 6GB for the disk in my host partition. No way. I could not get a complete Debian install. If the errors were coming late in the script (after installing the system, in the part of “Running hooks…”), I tried to log into the virtual machine, but soon or later I was having the “Segmentation fault” error or something like that. My dom0 was also unstable.

The Xen Debian Wiki explained that Debian has a meta package for installing xen: xen-linux-system (well, in my case, xen-linux-system-i386). I installed that package and more libraries and other packages got installed. I thought that was going to solve my problem, but no luck again… I realized that my display problems and segmentation faults were happening not only creating the virtual machine, but some times only trying to copy a file, or with xm list command… I read something about problems in dom0 with ext4, so I decided to stop here and give a try to my debian stable partition as linux host.

Xen dom0 + domU, second try (in Debian Squeeze, ext3, no USB)

Debian stable Xen packages install Xen 4.0. First I thought to use debian-backports in order to have the 4.1 version, but that meant to install the 3.2 kernel in my Debian stable so probably it would not be stable anymore, so I decided to use my current kernel version (2.6.32-5) and go with Xen 4.0.

After installing Xen, updating GRUB (installing GRUB again in my MBR) and reboot, I found that I can boot without problems in my new xen kernel (2.6.32-5-xen-686-pae) but not in the Xen 4.0 system (the same kernel, plus the hypervisor). Aarrgh! I looked at the logs and it seems that everything was going ok until the time of launching the graphical desktop (gdm3)… I rebooted and used the XEN entry but in recovery mode: everything goes well until root password is required (or Ctrl+D for continue). I give root password and I get the root prompt; I rebooted and tried again, but using Ctrl+D, and then it tries to launch the desktop and again the black screen (with no keyboard, so I could not change to tty2). After googling a bit, I tried to tweak the GRUB entry adding “text”  to the normal XEN 4.0 entry, and Bingo! The graphical environment was skipped and I had all the services up and the root prompt waiting my commands.

This time I decided to go step by step, and install the virtual machine in a directory of the host partition (not using an external USB drive), so I could give more disk space and also swap space, and the installation was going to be quicker (both for not using USB, and also allocating more swap).

I configured the required files in order to use NAT and not a network brige. When I restarted the xend service, I noticed errors, complaining about a missing /etc/xen/scripts/ This bug was fixed in version 4.1.0 (Aargh!) so I mounted my /dev/sda3 partition and copied the file from there. I restarted xend service, and this time it seems it was ok.

So I finished tweaking my config files, and launched xen-create-image in order to create a virtual machine for my webserver, with 6 GB of disk in my host partition, 1 GB swap, 512 MB memory and a static ip. This machine was going to be debian stable as the Linux host… And it worked! No ext3 I/O errors, no segfaults. The NAT was also working.

So next step is repeating the process creating the virtual machine in the LVM on the USB disk.

I will tell you how this finishes!!

About larjona

My name is Laura Arjona, I am a libre software user and fan of the free culture. If you want to contact me you can write an email to larjona [at] larjona [dot] net I am @larjona at in the social network. --- Me llamo Laura Arjona, soy usuaria de software libre y fan de la cultura libre. Si quieres contactar conmigo puedes escribir a larjona [en] larjona [punto] net Soy @larjona en el servidor, de la red social
This entry was posted in My experiences and opinion, Tools and tagged , , , , , , . Bookmark the permalink.