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?
You can now create as many domU's as you want. Some notes on the above.
- Boot your Mac Mini, fire up BootCamp assistant and partition your disk. I used 80GB of my 120GB disk for "Windows" (not for long).
- Download and install rEFit. I used version 0.10.
- Optionally modify "refit.conf" to set "LegacySystemsFirst", if you want to boot into Linux by default.
enable-always.sh to cause the rEFit boot loader to load for every boot.
- Download Debian Etch "business card" image and burn it to disk (chosen because it was small and quick to download).
- Reboot, and when rEFit boot loader appears boot into Linux install from CD.
- Partition the disk. I created a 1GB partition for dom0 and the remainder as an LVM physical storage.
- Install the base system only - i.e. when prompted to install packages for Laptop, Server, etc., deselect all the boxes.
- 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.
- When the rEFit boot loader appears, select "Partition Manager" and enter "y" to sync the MBR with the AFI partition.
- Reboot again, then select "install from CD" again.
- 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.
- Finish the install and reboot. Debian Etch should load.
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".
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.
- Reboot - when Etch loads again it should be your new Xen dom0 (confirm this with
pvcreate /dev/sda4 to create an LVM physical volume from the rest of your disk.
vgcreate vg /dev/sda4 to create a Volume Group.
eetc/xen-tools/xen-tools.conf to use the LVM group you've just created.
Some other things I did which it may be useful to document are:
- I didn't partition exactly as described above - I left the remainder of the disk free during install and used "fdisk" to create space after I was up and running. This was a mistake because fdisk changes the MBR, but not the EFI records. Don't use it - use gnu
parted instead if you want to mess with partitions.
- If GRUB tells you it can't write to the MBR during install, it's because the EFI and MBR partition tables are out of sync. You need to sync them using the Partition Manager in rEFit. Naturally doing so will erase your nice new partitions.
- I didn't create any swap, you might want to.
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.
- 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:
/etc/xen/scripts/network-bridge start vifnum=0 bridge=xenbr0 netdev=eth1 to the end of
/etc/init.d/rc.local. Although I might go back and add that to the
/etc/init.d/xend instead, as it should happen before the domU boots. Maybe there is somewhere better, I'm still figuring out debian.
mkdir /etc/xen/auto and
ln -s /etc/xen/host.cfg /etc/xen/auto/host.cfg, to auto-boot the "host" domU.
- 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:
- In dom0, edit
/boot/grub/menu.lst and search for the line that loads the linux kernel as a module in the Xen hypervisor. It will look like
module /boot/vmlinuz-.... To the end of that line, add
pciback.hide=(0000:00:1b.0) (if you run "lspci" it will list the PCI devices, in case you want to pass anything else through.
- In dom0 again, edit the config file for your domU in
/etc/xen, and add the line
- Log into the domU and run
apt-get install libesd-alsa0 alsa alsa-utils. You might need to reboot the domU at this point, and then run
alsaconf to configure the sound card.
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
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'