How to install Xen on MacBookPro

Please note: the contents of this page are old (2009), and as such, they may no longer be relevant.  The information is kept here for historical purposes.

What’s a Virtual Machine?

The concept of a “Virtual Machine” (VM) can be a little confusing to someone who has never heard of one before. Let’s say I have a Mac, and I want to run some Windows software. We know that Macs and PCs can’t run the same software, so we need a way to make your Mac “speak” the PC “language”. That’s where a VM comes in. A VM is a software application– just like Microsoft Word, or Photoshop– that essentially pretends it’s a computer. Once you have this “fake” computer, you can then install Windows on it, and it will run the Windows software for you. Windows doesn’t know any better, and assumes it’s running on a real computer.

VirtualBox is a free Virtual Machine that runs on Windows, Linux, and Mac.

VMWare Workstation is a Virtual Machine that runs on Windows or Linux, and VMWare Fusion is a VM that runs on Mac.

Here’s a screenshot of VMWare Fusion running Windows. As you can see, VMWare fusion runs just like any other application would, inside of its’ own window.

AppleScreen.jpg

Why Xen?

I can hear you saying, “VirtualBox and VMWare look cool! What the heck do you want to run Xen for? Their website looks boring.”

Well, VirtualBox and VMWare are cool. But Xen is a little different. VirtualBox and VMWare are full-blown applications; they are big and bulky and they “pretend” to be real hardware for a computer. You can imagine, doing that takes up a lot of your computer’s resources and is probably much slower than if you ran Windows right on your computer. The creators of Xen said, “Hey… you’re running VirtualBox and VMWare on a real computer. Why the heck do you need to run a fake computer on top of a real computer? Why not just run everything on the real computer, and split up its’ resources?”

A computer has a real processor and physical memory. Xen basically creates a thin software layer on top of that hardware and allows you to split up those resources among several operating systems like Windows, Mac OS, Linux, etc. It supposedly uses a lot less resources than a virtual machine does, so that each VM will run faster than if it were being run as an application. This thin layer is referred to as a Virtual Machine Monitor, or VMM.

I want to run Windows, OS X, and Linux, but virtual machines are slow. My theory is that if I can get Xen working on my MacBook Pro, I’ll be able to run all 3 without having to reboot or run a wholly separate virtual machine. They won’t run as fast as they would on the physical hardware, but they won’t be as slow as a VM, either.

It’s also an experiment because I like to tinker.

Installing Xen

XenOnDebian.jpg

Got this working.

  1. First installed Debian directly onto hard drive, and used Grub Legacy to boot into Xen.
    1. My kernel version is 2.6.26-2-686, so I installed these packages in Aptitude:
      linux-image-2.6.26-2-xen-686
      xen-linux-system-2.6.26-2-686

      Aptitude also auto-selected some other packages for me.

      Aptitude also automatically added Xen to my legacy grub installation. Note that Xen only works with Grub Legacy version as far as I am aware. I have tried installing it with Grub2 but I couldn’t get it to work, as of late October, 2009. If you don’t have grub legacy installed, you will need to install it (I’m using GNU GRUB 0.97).

  2. Had to recompile madwifi to get wireless operational. System temp seemed to run very hot until I turned on CPU frequency scaling (see section on installing Linux on USB drive)

Notes

Xen is an open-source Virtual Machine Monitor (VMM). It’s also called a “hypervisor” by the Xen docs.

My xend-config.sxp:

(network-script 'network-nat netdev=ath0')
(vif-script     'vif-nat')
(dom0-min-mem 196)
(dom0-cpus 0)
(vncpasswd '')
greystar:/home/russosv# cd /etc/xen
greystar:/etc/xen# brctl addbr br0
greystar:/etc/xen# xm create /etc/xen/win01.cfg
Using config file "/etc/xen/win01.cfg".
Started domain win01
greystar:/etc/xen# ifconfig vif0.0 192.168.2.39 up
greystar:/etc/xen# ifconfig vif1.0 10.0.1.39 up
greystar:/etc/xen# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.00ff604cd3de       no              tap0
                                                        vif1.0
eth0            8000.0017f2c30723       no              peth0

greystar:/etc/xen# brctl addif br0 vif0.0
greystar:/etc/xen# ifconfig br0 up
greystar:/etc/xen# route add -net 10.0.0.0 netmask 255.0.0.0 dev br0
greystar:/etc/xen# echo 1 >/proc/sys/net/ipv4/ip_forward
greystar:/etc/xen# iptables -t nat -A POSTROUTING -o ath0 -j MASQUERADE

Windows TCP/IP config:

IP Address: 10.0.1.19
Subnet Mask: 255.0.0.0
Default gateway: 10.0.1.39
Preferred DNS Server: 192.168.2.1