Installing Xen on a Mac Mini

An extremely quick and dirty guide using Debian Etch and LVM

5 Feb 2008

This is what I did to get Xen up and running on a Mac Mini. The unit I've got was purchased February 2008 - it's a 2.0Ghz Intel Core Duo 2, which has the IntelVT feature you need for full virtualization (this was enabled by default). Because these boxes have (pretty much) uniform hardware I'm going to skip most of the detail and just go through what I did. Some design decisions I made included: Use a minimal dom0, use LVM, keep OS X around and no swap - 2GB ought to be enough for anyone, right?

  1. Boot your Mac Mini, fire up BootCamp assistant and partition your disk. I used 80GB of my 120GB disk for "Windows" (not for long).
  2. Download and install rEFit. I used version 0.10.
  3. Optionally modify "refit.conf" to set "LegacySystemsFirst", if you want to boot into Linux by default.
  4. Run enable-always.sh to cause the rEFit boot loader to load for every boot.
  5. Download Debian Etch "business card" image and burn it to disk (chosen because it was small and quick to download).
  6. Reboot, and when rEFit boot loader appears boot into Linux install from CD.
  7. Partition the disk. I created a 1GB partition for dom0 and the remainder as an LVM physical storage.
  8. Install the base system only - i.e. when prompted to install packages for Laptop, Server, etc., deselect all the boxes.
  9. When prompted to install a Grub boot loader select no (it will fail). Carry on without installing a boot loader, finish the install and reboot.
  10. When the rEFit boot loader appears, select "Partition Manager" and enter "y" to sync the MBR with the AFI partition.
  11. Reboot again, then select "install from CD" again.
  12. Do exactly as you did before, but this time you won't have to repartition the disk. When you're prompted to install a boot loader, install grub - it should work this time.
  13. Finish the install and reboot. Debian Etch should load.
  14. Run apt-cache search xen-linux-system to see what the most recent Xen kernel is. For me it was "xen-linux-system-2.6.18-xen-686".
  15. Run apt-get install ssh openssh-server less ntp pciutils file parted lvm2 lvm-common xen-utils xen-docs-3.0 bridge-utils xen-tools libc6-xen xen-ioemu-3.0.3-1 xen-linux-system-NNN-xen-686. Naturally NNN is the version you found in the previous step.
  16. Reboot - when Etch loads again it should be your new Xen dom0 (confirm this with xm list).
  17. Run pvcreate /dev/sda4 to create an LVM physical volume from the rest of your disk.
  18. Run vgcreate vg /dev/sda4 to create a Volume Group.
  19. Edit eetc/xen-tools/xen-tools.conf to use the LVM group you've just created.
You can now create as many domU's as you want. Some notes on the above. Some other things I did which it may be useful to document are:
  1. I wanted my domU to autoboot and use Network Bridging - this didn't happen by default (i.e. nowhere in the above process was a xenbr0 network interface created). Maybe this is because the Ethernet comes up as eth1 rather than eth0, I don't know. What I did to start it was:
  2. I also want to play audio in the domU (from Java, to compound my problems). The only way to do this is to prevent dom0 from using it, and pass the PCI device through to a single domU. This is quite easy - you need to do the following:
The end result is working well - dom0 has about 200MB remaining from the Gigabyte of disk it was given, and my domU is running Java, Tomcat and my home-grown Java MP3 server very nicely. I allocated 512MB to domU of the 2GB physical RAM, and it's ticking over very nicely without any noticeable load in dom0 or domU. I haven't tried getting the Atheros wi-fi driver working, and when I tried running the OS X as a Xen guest it immediately rebooted the whole box, so I'll let greater minds than me figure that one out.

Followup Not quite as smooth as I'd hope. The Marvel 88E8053 Gigabit Ethernet card has problems, and hangs under load using the "sky2" drivers - this is a known problem. I've followed the instructions at http://www.sumardi.net/2007/06/21/how-to-install-madwifi-on-debian-40-etch/ and it's worked, after a bit of fiddling (this page was also very useful).

Parts of this were derived from the following:

PS. here's my domU config file, in /etc/xen/tiny.cfg

kernel  = '/boot/vmlinuz-2.6.18-6-xen-686'
ramdisk = '/boot/initrd.img-2.6.18-6-xen-686'
memory  = '512'
root    = '/dev/sda1 ro'
disk    = [ 'phy:vg/tiny-disk,sda1,w', 'phy:vg/tiny-swap,sda2,w', 'phy:vg/public,sda3,w' ]
name    = 'tiny'
pci     = [ '00:1b.0' ]
vif     = [ 'ip=10.1.1.99' ]
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'