Of course he was all in favour of Armageddon in *general* terms - Terry Pratchett & Neil Gaiman, Good Omens


Pre-compiled Linux distros for Xen virtual machines

Thursday 27th April, 2006 | 10:38 pm

Having spent a couple of weeks now playing with Xen, I have found it quite a struggle to find decent documentation explaining exactly how to install various Linux distros to act as virtual machines. After going through setting up Debian as my Xen server and a sample domU, any instructions on installing Gentoo, CentOS, Fedora, etc. all assumed you were already running those distros as the base distro. debootstrap could get me running Ubuntu, but that was about it and domi didn’t seem workable on Debian.

Xen SourceSo, having trawled through some Xen newsgroup posts, I stumbled across jailtime.org, which provides pre-compiled, compressed images for CentOS 4.3, Gentoo 2005.1, Slackware 10.2, Debian 3.1, Fedora Core 4 + Fedora Core 5. As I’m not running my Xen server in a production environment, I don’t have any real qualms in putting my trust in someone not to have compiled something naughty into these images, though I don’t have any reason to believe there would be! Each distro is about 100Mb-120Mb in size, and each image takes about 5 minutes to extract and configure making it very quick + easy to have multiple distros running with the minimum of fuss.

Pick an image for the distro you require, and don’t forget to check the steps involved in using each image:

A slight problem has been in that the sample configs are assuming /dev/sda to be the drive in use, and the images are pre-configured with fstab’s reflecting this, along with network configurations grabbing addresses via DHCP. After changing the Xen configs to use /dev/hda (or whatever hard drive layout you’re running) and then using ‘xm create‘ to load your new virtual machine, you’ll probably get an error thrown as the system can’t mount the drives, dropping you to a recovery console. Simply remount the drive read-write, edit fstab to reflect your hard layout, and reboot:

mount -o remount,rw /
nano /etc/ftsab
Ctrl-D

And bob’s your proverbial uncle :-) Might look at expanding on some already-available scripts to handle the automatic creation of whichever domain is required, including the downloading of the image if not already available locally, though I’m already being distracted from at least two other little coding projects at the moment!

    6 Responses to “Pre-compiled Linux distros for Xen virtual machines”


  1. Gravatar jailtime (3 comments)
    United States | Internet Explorer 6.0 | Windows XP
    May 3rd, 2006 at 8:59 pm

    There should not be any need to change the fstab. These are virtual devices — they don’t correspond to any real hardware. Of course if you have some particular attachment to /dev/hda then go for it.

  2. Gravatar fouldsy (63 comments)
    Great Britain (UK) | Mozilla Firefox 1.5.0.2 | Linux
    May 3rd, 2006 at 9:11 pm

    I know they’re virtual devices, but when the domU loaded it would then examine the local fstab, find the devices didn’t exist and fail. As soon as fstab was adjusted to point to /dev/hda as my other domU’s, up they came. I also found the local network config files within each image over-rode those specified by the Xen config, whereas ideally they should maybe have been removed allowing Xen to control them.

  3. Gravatar jailtime (3 comments)
    United States | Internet Explorer 6.0 | Windows XP
    May 4th, 2006 at 7:35 pm

    I’ll have to play around with that some and add a note to the site. I am still confused though: ‘… domU loaded it would then examine the local fstab, find the devices didnâ��t exist and fail’

    The /dev/sda device nodes *do* exist in the images. I thought that they did not need to exist in the dom0 filesystem but it has been a while since I experimented with that. As an alternative to editing the image’s fstab I am wondering if you could have created a /dev/sda using mknod in dom0 to resolve the problem.

  4. Gravatar fouldsy (63 comments)
    Great Britain (UK) | Mozilla Firefox 1.5.0.2 | Linux
    May 4th, 2006 at 11:09 pm

    I’ve no expert on Xen, so is probably me fumbling around here and getting crossed wires!

    My other config’s for the domU’s sets up /dev/hda as the virtual drives. When creating the configs for the images from your site, I used the same settings. This may be causing problems, but the logic still holds true that the OS within the image shouldn’t be reading from fstab. It could be that Xen thinks it should be /dev/hda, but the fstab within the image looks for /dev/sda and they conflict. To be honest, I didn’t try adjusting one of the Xen config files to leave it as /dev/sda and then try loading one of your images. Maybe I should :-)
    As for mknod’ing the filesystems from dom0, I don’t think it would make a difference since dom0 doesn’t have a problem, it’s the images themselves during their own boot that are failing to find the correct devices.

  5. Gravatar jailtime (3 comments)
    United States | Internet Explorer 6.0 | Windows XP
    May 5th, 2006 at 5:34 pm

    OK - it’s pretty clear to me now. When you change the cfg file to use hda you absolutely have to change the fstab in the guest image.

    Here is where I think you are getting confused: “the OS within the image shouldnâ��t be reading from fstab”. The guest image absolutely does read its own fstab — this is just common sense and is pretty well documented in the xen docs. The devices mentioned in the guest’s fstab should be the ones “exported” by the dom0 config.

    Had you kept the config file the same and the image the same you would have been fine. In any case I’m glad you were able to get it working. I may add a note for people who want to change their device names to make things clearer.

  6. Gravatar fouldsy (63 comments)
    Great Britain (UK) | Mozilla Firefox 1.5.0.2 | Linux
    May 6th, 2006 at 12:08 am

    To be honest, I didn’t find the Xen docs or wiki very clear on actually creating your virtual machines. In terms of configuring the server, allowing access to hardware, the networking filtering routing, yeah, it was excellent. For installing Gentoo, for example, as a domU when your dom0 is Debian or another distro, very confusing for someone just starting out.

    As I mentioned before, I think the problems were caused by my lack of understanding, and by keeping in-line with the configs as in my other virtual machines, those available from jailtime didn’t work.

    But yes, I’m quite happy with the way they’re running now. As a test, I changed one of the fstab’s and the Xen config back to how they were (/dev/sda) and it did load fine. Moral of the story is don’t tinker with the default config I suppose :D Maybe a short paragraph on the site explaining this could be helpful, since I guess there might be quite a few people just starting out with Xen such as myself and looking for images to use that may run into a similar issue.

    Thanks again for your help support, and also for providing the images in the first place!

Leave a Reply


If you must, please use valid XHTML
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>