This post is an extension to my article about setting up a triple-boot Mac.
It describes how to use a linux partition from a natively installed linux in VMware Fusion on a Mac. I did this with Ubuntu 11.10 after I had set up my triple-boot system and therefore I'm able to boot the same Ubuntu both natively and in a virtual machine using VMware Fusion in Mac OS X.
1. Create a new virtual machine
First of all, you have to create a new virtual machine.
- click on "Create New"
- select "Continue without disk" and then "Create a custom virtual machine"
- select "Linux" and "Ubuntu 64-bit" on the next page
- click on "Finish" or "Customize Settings" if you want to change something (like the memory or number of processors)
- save the file
2. Create a new virtual raw disk based on the Ubuntu partition
To be able to use the physical ubuntu partition as a virtual disk in VMware, you have to create a new "raw disk" using the vmware-rawdiskCreator which is included in the VMware Fusion.app.
- open a terminal
- navigate to the VMware Fusion.app/Contents/Library folder
"cd /Applications/VMware\ Fusion.app/Contents/Library/"
- list all available partitions with
"./vmware-rawdiskCreator print /dev/disk0"
- create the rawdisk (in my case the linux partition is partition 4) and save it to the folder of your created VM (I named the file "ubuntu-partition")"./vmware-rawdiskCreator create /dev/disk0 4 ~/Documents/Virtual\ Machines.localized/Ubuntu\ 64-bit.vmwarevm/ubuntu-partition ide"The tool will create two files ("ubuntu-partition.vmdk" and "ubuntu-partition-pt.vmdk")
- to set the new virtual disk file as the default hard drive in the VM, go to the folder of the VM, open the .vmwarevm file (in Finder: right-click and select "Show Package Contents") and edit the file with the extension .vmx in a text editor.
Add or edit the following lines
ide0:0.present = "TRUE"
ide0:0.fileName = "ubuntu-partition.vmdk"
ide0:0.deviceType = "rawDisk"
and remove the current disk entry (look at the lines starting with "scsi0:0").
When I started the VM after these steps, I got an error from grub saying "No such partition". Why? Well, the problem is that I installed GRUB directly to the partition to boot it from rEFIt in my triple-boot setup. But in the VM this doesn't work (maybe because there is only this partition and it is not bootable)!
So, I had to find a way to boot ubuntu in the VM with a different GRUB installation than on the physical partition.
3. Make it bootable in VMware Fusion
Finally, I found a solution/workaround for the problem described above:
- add a small new virtual disk to the VM(Settings... -> Add Device.. -> New Hard Disk -> Add...)
- boot the VM with a live system like GParted or the ubuntu installation disk (yes, the VM has a BIOS and you can open a boot menu or change the boot order pressing "Esc" ;-) )
- create a partition on the new virtual disk (ext3) and flag it as bootable
Now we have to install GRUB to the MBR of that virtual disk:
- boot the VM from the ubuntu live system
- once it is started:
Open a terminal and run "sudo fdisk -l" to find out the partition where the real ubuntu system is installed
- mount it using "sudo mount /dev/sda4 /mnt" (assuming that the ubuntu partition is /dev/sda4)
- install grub to the MBR of the new virtual disk:
"sudo grub-install --root-directory=/mnt /dev/sdb"
(assuming /dev/sdb is the small virtual disk)
- reboot the VM and setup the VM-BIOS to boot from the new (small) virtual disk where you installed GRUB
Now it should be possible to boot ubuntu in the VM!
It's not possible anymore to boot ubuntu from rEFIt! ;-) But there is also a solution to that:
4. Reinstall GRUB to the physical partition
You also have to reinstall GRUB to the ubuntu partition to be able to boot ubuntu from rEFIt as before.
- boot your Mac to the ubuntu live systemCAUTION: You need to insert both the installation DVD and the USB-stick and hold down "C"
- open a terminal and follow the steps from above to find and mount the ubuntu partition to the live system, e.g.:
"sudo fdisk -l"
"sudo mount /dev/sda5 /mnt"
- reinstall GRUB to the partition (NOT to the MBR of your disk!!!)
"sudo grub-install --root-directory=/mnt /dev/sda5 --force"
Now it should be possible to boot ubuntu from rEFIt AND also from VMware Fusion!