From Segfault
< Xen
Jump to navigation Jump to search


apt-get install xen-system-amd64 grub-xen-host bridge-utils xen-tools qemu-system-x86

After that, the GRUB configuration should look like this:

$ grep -A6 Xen /boot/grub/menu.lst
title           Xen 3.2
root            (hd0,0)
kernel          /xen-3.2.gz
module          /vmlinuz-2.6.26-2-xen-amd64 root=/dev/mapper/vg01-xen--root ro console=tty0
module          /initrd.img-2.6.26-2-xen-amd64

Or, for GRUB2:

$ cat /boot/grub/grub.cfg
submenu "Xen 4.1-amd64" {
menuentry 'Debian GNU/Linux, with Xen 4.1-amd64 and Linux 3.7-trunk-amd64' \
          --class debian --class gnu-linux --class gnu --class os --class xen {
       insmod part_gpt
       insmod ext2
       set root='(hd0,gpt1)'
       search --no-floppy --fs-uuid --set=root 59c3d59a-36de-457d-a688-bd0b1c7fa9c0
       echo    'Loading Xen 4.1-amd64 ...'
       multiboot       /boot/xen-4.1-amd64.gz placeholder
       echo    'Loading Linux 3.7-trunk-amd64 ...'
       module  /boot/vmlinuz-3.7-trunk-amd64 placeholder root=UUID=59c3d59a-36de-457d-a688-bd0b1c7fa9c0 ro
       echo    'Loading initial ramdisk ...'
       module  /boot/initrd.img-3.7-trunk-amd64

To prioritize the Xen HV over the other kernels, we can use dpkg-divert

dpkg-divert --divert /etc/grub.d/09_linux_xen --rename /etc/grub.d/20_linux_xen

This will put the Xen HV ahead of other images:

$ ls -1 /etc/grub.d/

Don't forget to update /boot/grub/grub.cfg:


Set the Xen toolstack in /etc/default/xen

  • xl was named "xm" before
  • libvirt/virsh tries to be virtualization technology agnostic and is used in KVM extensivly
  • XAPI/xe is used for XenServer (the commercial version of Xen/XCP) and XCP (Xen Cloud Platform)


Prepare LVM:

$ pvcreate /dev/sdc                              # Replace sdc with your target disk
$ vgcreate vg0 /dev/sdc
$ vgs
VG   #PV #LV #SN Attr   VSize VFree
vg0    1   4   0 wz--n- 4.00g    0


To install a Debian distribution, we can use xen-create-image (from the xen-tools package). The following will install Debian/wheezy on /dev/vg0/xen-debian0-disk

xen-create-image --hostname xen-debian0 --ip --gateway= --netmask \
                 --vcpus 2 --memory 128m --noswap --pygrub --fs ext4 \
                 --dir /mnt/lv0 --lvm vg0 --size 1g --dist wheezy

Available distributions are configured in /usr/lib/xen-tools/:

$ ls -1d /usr/share/xen-tools/*.d | tail

Note: during installation, debootstrap will download the needed package files from the installation source specified in sources.list. Depending on the connection speed / distribution, this can take a long time. We can't install from an ISO image directly[1], but did the following instead:

mount -t iso9660 -o ro debian-7.1.0-amd64-netinst.iso /mnt/cdrom

Point xen-tools to the CDROM:

$ grep ^mirror /etc/xen-tools/xen-tools.conf
mirror = file:/mnt/cdrom/debian

Now, while the netinst image contained all the package files, it was missing the Release.gpg files and debootstrap would fail in the process. As a workaround, we created a debootstrap wrapper:

$ cat /usr/local/sbin/debootstrap.sh
debootstrap --no-check-certificate --no-check-gpg $@

Let's use this wrapper for xen-create-image now:

xen-create-image --hostname xen-deb0 --dhcp --vcpus 2 --memory 128m --noswap \
                 --pygrub --fs ext4 --dir /mnt/xen/lv0 --lvm vg0 --size 1g --keep \
                 --dist wheezy --debootstrap-cmd=/usr/local/sbin/debootstrap.sh

If all goes well, we now have:

$ lvs
 LV               VG   Attr     LSize    Pool Origin Data%  Move Log Copy%  Convert
 xen-debian0-disk vg0  -wi-a--- 1.00g

$ xen-list-images
Name: xen-debian0
Memory: 128

The configuration is stored in /etc/xen/xen-debian0.cfg:

name            = 'xen-debian0'
bootloader      = '/usr/lib/xen-4.1/bin/pygrub'
# extra         = 'clocksource=jiffies'
vcpus           = '2'
memory          = '128'
root            = '/dev/xvda1 ro'
disk            = [
vif             = [ 'ip=, mac=00:10:1E:19:0A:11' ]
on_poweroff     = 'destroy'
on_reboot       = 'restart'
on_crash        = 'restart'

If something is missing in our new Xen image, we can try to fix it manually:

mount -t ext4 /dev/vg0/xen-debian0-disk /mnt/
mount -t devtmpfs udev /mnt/dev/ && mount -t devpts devpts /mnt/dev/pts && mount -t proc proc /mnt/proc/ && mount -t sysfs sysfs /mnt/sys/
chroot /mnt
> apt-get -o APT::Install-Recommends=false install linux-image-cloud-amd64 dropbear xenstore-utils                                       # Or whatever was missing :-)

Umount, and then try again to start:

umount /mnt/{{{dev/pts,dev},proc,sys},}