May 032011
 

I was in the mood to refresh a few of my Xen virtual machines, and saw that Ubuntu 11.04 had been released, so I figured I’d give it a try. Ubuntu has typically been pretty decent under Xen, working well as either a hardware virtualized (HVM) or paravirtualized (PV) guest, but standards appear to have slipped with this latest release. I ran into problems with natty properly detecting and using both the NIC and the hard disk at multiple points in the install and setup. The instructions below will walk you through setting up a paravirtualized guest running Ubuntu 11.04. The instructions are pretty standard for any moderately recent release of Ubuntu or Debian, with the gotcha’s specific to Ubuntu 11.04 specifically marked.

Some notes before we get started: I use LVM volumes as my disk images, but this is irrelevant to this guide, just substitute some appropriate commands for making your disk backed by a file. Also, I’m naughty and run all of these from a root shell, rather than using sudo everywhere. Substitute as appropriate if you have better habits than I.

1. Create your LVM volume (or use a file) for your virtual machine.

# lvcreate -L10G -n example.mmacleod.ca VolumeGroup

2. Get the kernel, initrd, and xen config

# wget http://ca.archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/current/images/netboot/xen/xm-debian.cfg
# wget http://ca.archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/current/images/netboot/xen/initrd.gz
# wget http://ca.archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/current/images/netboot/xen/vmlinuz

3. Edit the config file

Edit the config file to taste, paying attention to the memory, name, vcpus, vif, and disk options. Also, find the line that says “bootloader=pygrub” and change it to the absolute path “bootloader=/usr/sbin/pygrub”.

4. Start the install

xm create -f xm-debian.cfg -c install=true install-kernel="vmlinuz" install-ramdisk="initrd.gz" install-mirror="http://ca.archive.ubuntu.com/ubuntu" install-arch=amd64 install-method=network

4.1 Select a language

4.2 Select your location

4.3 Configure the network

Configuring the network fails at first with natty. You need to manually load the network driver. The following steps are not required for other versions of Ubuntu.

When you arrive at this stage, just select ‘Go Back’ and you’ll be dropped to a menu.

At this menu select ‘Execute a shell’

Use the following to manually load the NIC module.

# modprobe xen-netfront
# exit

Select ‘Detect network hardware’

And we’re passed the network driver hurdle. From here it should behave as a standard network install.

5. Fix the boot stage

The first time you boot your new virtual machine, it’s going to fail to find the hard disk because the xen-blkfront module isn’t loaded. Fix it by loading it manually.

(initframfs) modprobe xen-blkfront
(initramfs) exit

Once the host finishes booting, log in and sudo to root. Then enter the following:

root@ubuntu:~# echo "xen-blkfront" >> /etc/initramfs-tools/modules
root@ubuntu:~# update-initramfs -u
update-initramfs: Generating /boot/initrd.img-2.6.38-8-generic

And that should be it. You now have Ubuntu Natty Narwhal running as a paravirtulized domU.

  6 Responses to “Ubuntu Natty Narwhal and Xen”

  1. Hi Mike!

    You’re great! You’ve saved me from going totally insane, trying to installing a ubuntu machine on natty with xen 4.1.0, as all the other tutorials didn’t work the way they should.

    Well, I’m quite familiar with debian systems, but totally new to xen … And to me it seem’s that most of the tutorials written for debian/xen 4.0.1 are not working with debian/xen 4.1.0

    If it’s not to foolhardy, may I ask you whether you also have coped with the task to get a win xp machine running on debian/xen 4.1.0? Maybe you can prevent me for going insane one more time ;)

    Many thanks!
    Andreas

    • I’m glad that the post helped, though I guess I should mention that I’m actually running Xen 4.0.1. But if it worked for you wit Xen 4.1.0, then that’s awesome.

      As to Windows, I haven’t tried to run it under Xen 4.0.1 or 4.1.0. What problem are you encountering?

  2. Re-Hi!

    Many thanks for responding to my question … Well, the situation is as follows:

    I have a win xp vm, originally running on oracle’s virtualbox. I’ve exported the partition from the vdi to an img file and copied it with dd into a lvm partition on my newly installed ubuntu/xen server. if i mount the lvm everything looks fine, just like a windows installation should look like. ;)

    now i try to create the machine with this configuration:
    ##### DomU-JackieBoy #####
    #
    kernel = ‘/usr/lib/xen/boot/hvmloader’
    builder = ‘hvm’
    memory = ’1024′
    device_model = ‘/usr/lib/xen/bin/qemu-dm’
    disk = [ 'phy:/dev/mapper/SinCity-JackieBoy,ioemu:sda,w' ]
    name = ‘JackieBoy’
    vif = [ 'type=ioemu, bridge=br0' ]
    boot = ‘c’
    vnc = 1
    vncviewer = 1
    #
    #####

    Then there are two problems: One is that I do not get a vnc connection to the domu. And then, after about 30 seconds, the domu automatically switches itself off.

    Here is what the log-files say:

    root@sincity:/var/log/xen# cat xend.log

    root@sincity:/var/log/xen# cat xen-hotplug.log
    RTNETLINK answers: Operation not supported

    root@sincity:/var/log/xen# cat qemu-dm-JackieBoy.log
    domid: 16
    config qemu network with xen bridge for tap16.0 br0
    Using file /dev/mapper/SinCity-JackieBoy in read-write mode
    Watching /local/domain/0/device-model/16/logdirty/cmd
    Watching /local/domain/0/device-model/16/command
    Watching /local/domain/16/cpu
    qemu_map_cache_init nr_buckets = 10000 size 4194304
    shared page at pfn feffd
    buffered io page at pfn feffb
    Guest uuid = 5e390574-a3c0-971d-faf1-13600bb2f825
    Time offset set 0
    populating video RAM at ff000000
    mapping video RAM from ff000000
    Register xen platform.
    Done register platform.
    platform_fixed_ioport: changed ro/rw state of ROM memory area. now is rw state.
    xs_read(/local/domain/0/device-model/16/xen_extended_power_mgmt): read error
    xs_read(): vncpasswd get error. /vm/5e390574-a3c0-971d-faf1-13600bb2f825/vncpasswd.
    Log-dirty: no command yet.
    I/O request not ready: 0, ptr: 0, port: 0, data: 0, count: 0, size: 0
    vcpu-set: watch node error.
    xs_read(/local/domain/16/log-throttling): read error
    qemu: ignoring not-understood drive `/local/domain/16/log-throttling’
    medium change watch on `/local/domain/16/log-throttling’ – unknown device, ignored
    xen be core: xen be core: can’t open gnttab device
    can’t open gnttab device
    xen be core: xen be core: can’t open gnttab device
    can’t open gnttab device
    xen be core: xen be core: can’t open gnttab device
    can’t open gnttab device
    xen be core: xen be core: can’t open gnttab device
    can’t open gnttab device
    xen be core: xen be core: can’t open gnttab device
    can’t open gnttab device
    xen be core: xen be core: can’t open gnttab device
    can’t open gnttab device
    xen be core: xen be core: can’t open gnttab device
    can’t open gnttab device
    xen be core: xen be core: can’t open gnttab device
    can’t open gnttab device
    xen be core: xen be core: can’t open gnttab device
    can’t open gnttab device
    cirrus vga map change while on lfb mode
    mapping vram to f0000000 – f0400000
    platform_fixed_ioport: changed ro/rw state of ROM memory area. now is rw state.
    platform_fixed_ioport: changed ro/rw state of ROM memory area. now is ro state.

    I am still googling around for hints but by now not very successfully. Maybe you – or anyone who reads this – knows what is wrong and can help me out.

    Thanks & Greetings
    Andreas

  3. Alright, there’s a few things I’d take a look at. First, your replace your VNC options with something like this:

    vfb = [ 'vnc=1,vncdisplay=1' ]

    That’ll start the VNC console on either localhost or whatever you set ‘vnc-listen’ to in xend-config.sxp. That should let you do a better job of debugging, since you’ll see the error messages that appear on the console.

    That said, I have a suspicion that the problem is the disk image. HVM guests expect to find a real “disk”, with an MBR and (in particular) a partition table. Here’s the disk entry from one of my HVM guests:

    disk = [ 'phy:/dev/Data/example.mmacleod.ca,hda,w' ]

    And here’s the partition table (units in sectors):

    root@monolith:~# fdisk -lu 512 /dev/Data/example.mmacleod.ca

    Disk /dev/Data/example.mmacleod.ca: 10.7 GB, 10737418240 bytes
    255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 65536 bytes / 262144 bytes
    Disk identifier: 0x0008b675

    Device Boot Start End Blocks Id System
    /dev/Data/example.mmacleod.ca1 2048 18860031 9428992 83 Linux
    /dev/Data/example.mmacleod.ca2 18862078 20969471 1053697 5 Extended
    Partition 2 does not start on physical sector boundary.
    /dev/Data/example.mmacleod.ca5 18862080 20969471 1053696 82 Linux swap / Solaris

    As you can see, the LVM volume actually contains a partition table, which lets the HVM guest believe that it is connected to a regular disk. Also, I’m not using the ioemu option in the disk entry. Now, it may be possible to get Xen to emulate the partition table and whatnot for you, but at present I suspect you’re passing a single partition to the guest, but it’s trying to pretend that it’s an entire disk, not just a single partition.

    Let me know if that gets you anywhere.

  4. Hello!

    So many thanks for your help! At least I am now able to get the machine running and using xm vncviewer to access to it.

    Now I just have to investigate, why the windows machine crashes with a blue screen during boot. Perhaps it have something to do with IO-APIC, as this was enabled when the machine was originally installed on oracles virtualbox.

    Best wishes,
    Andreas

  5. You’re a lifesaver – nothing less. Been struggling with this problem for hours. Cheers.

Sorry, the comment form is closed at this time.