I am interested in trying out Xen;

  • What packages do I need to install?
  • How do I set up a DomU instance?
  • 2
    You don't mention what version of Ubuntu you are running, but have you checked out this Wiki page? help.ubuntu.com/community/Xen Sep 17, 2011 at 1:16
  • I assumed Natty for my answer (Xen with Natty seems broken at the network detection phase). Use the link above for Lucid.
    – Rinzwind
    Sep 17, 2011 at 6:39
  • this question has some directions on what you need to install askubuntu.com/q/83846/17034
    – hwjp
    Nov 30, 2011 at 15:03

1 Answer 1


Paravirtualized guest and Ubuntu 11.04

When installing a Xen virtual machine, you need to determine what kind of block devices you want to work with. There are three possibilities: installing directly on a dedicated partition (maximum performance) or by using an important disk image file or create your own disk image file with dd (resizable; You can use snapshots for making backups)

All commands assume root (ie. sudo su). I also assume using LVM but have also included an untested method where you use dd to use your own image. So skip 1 if you want to use a file (and not LVM) and skip 2 if you do use LVM.

  1. Create a new LVM volume for your virtual machine. Change the name (after -n) to suit your needs:

    lvcreate -L10G -n example.ubuntu.natty VolumeGroup

    lvcreate is part of lvm2 Install lvm2 but it is already installed when you are using lvms.

  2. You can also use a file (dd). I have not found a suitable method for this with Ubuntu but this should come close. If you go with this I have experience with it but all the next steps should be the same. Copied from the link the method to create one using dd (the link also includes other methods of getting a file):

    Create a 4Gb empty file with at /var/lib/xen/images/disk1 (change either size and location to fit your needs):

    dd if=/dev/zero of=/var/lib/xen/images/disk1 bs=1M count=4096

    Apart from creating empty image files using the dd utility, you can also use ISO files as an alternative for your physical optical drives. The usage is the same as the usage of a disk image file created with dd. Don't have an ISO file yet? Then we have good news for you; it's easy to create one. If the cd-rom of which you want to create an ISO file is in your optical drive, use the following to copy it to a file with the name cdrom.iso:

    dd if=/dev/cdrom of=/isos/cdrom.iso

    After creating either a disk image file or an ISO file, you need to include the disk image file in your virtual machine configuration using the file option in the disk definition:

    disk=[ 'file:/var/lib/xen/images/disk1,hda,w', 'file:/isos/cdrom.iso,hdc,r', ]
  3. Get the kernel, initrd, and xen config. wget versions for nl and installer-amd64 (so change the country code nl and also use installer-amd64 in the URL to fit your needs):

    wget http://nl.archive.ubuntu.com/ubuntu/dists/natty/main/installer-i386/current/images/netboot/xen/xm-debian.cfg
    wget http://nl.archive.ubuntu.com/ubuntu/dists/natty/main/installer-i386/current/images/netboot/xen/initrd.gz
    wget http://nl.archive.ubuntu.com/ubuntu/dists/natty/main/installer-i386/current/images/netboot/xen/vmlinuz
  4. 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.

  5. Start the install (again pay attention to the command: change server country code and architecture to your needs):

    xm create -f xm-debian.cfg -c install=true install-kernel="vmlinuz" install-ramdisk="initrd.gz" install-mirror="http://nl.archive.ubuntu.com/ubuntu" install-arch=i386 install-method=network
    • select a language
    • select a location
    • configure your network card. If it fails you will need to configure it manually (choose back, drop to a shell and issue a modprobe xen-netfront && exit. Configure the network card again.
    • select detect network hardware and insert a hostname

    and it starts installing.

  6. Fix the install.

    The xen-blkfront module isn’t loaded at first so xen will fail to boot.

    (initframfs) modprobe xen-blkfront
    (initramfs) exit

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

    echo "xen-blkfront" >> /etc/initramfs-tools/modules
    update-initramfs -u
    update-initramfs: Generating /boot/initrd.img-2.6.38-11-generic

Untested and from memory + googling to fix my memory

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.