Monday, November 21, 2011

Install Windows 7 with boot camp on mac (Part 2)

Small resume from Part 1:
  • I am the (un)happy owner of a late 2008 Macbook Pro
  • My super Drive is DEAD
  • I have Mac OS X Lion installed on my mac
  • For whatever (foolish) reason I want to install Windows 7 on a Bootcamp partition
  • I used Bootcamp 4.0.1

In the guide below i will explain how i managed to (finally) install Windows 7 on my bootcamp partition. But before we go further, some important warning. This whole procedure is at best dangerous, and is not for the faint hearted. It can possibly screw up your disk, follow it at your own risk. I strongly advise that you read this guide completely before starting this whole procedure by yourself. Now that you've been warned, let's get started.



Pre-requisite:
  • Have Virtual Box installed on you Mac
  • Have everything back up because there's a possibility that this procedure screw up your disk
  • Download and put on a separate USB disk the WindowsSupport (using bootcamp assistant)
What this guide does is essentially do the initial install step of windows (copying all the files, formatting ...) from inside a VM, stop the VM right after the first reboot,  and then reboot your real machine this time to continue and finish the install. 

At the time of writing this guide i have VirtualBox 4.1.6 r74713, and i'm running Mac OS 10.7.2.

Step 0: BACK UP ! and make sure you have an install CD / DVD / USB handy.
Use whatever solution you like, to backup your data, be it Time Machine, SuperDuper or iBackup.  If you still don't have back up do it now.

Step 1: Create a Bootcamp partition using the boot camp assistant

Step 2: Unmount / Eject Bootcamp partition if you can see it in your Finder


Step 3: Create Virtual disk 
I created a folder that will contain the virtual disk and the VM itself.

mkdir -p ~/VirtualBox VMs/B7
cd ~/VirtualBox VMs/B7
sudo chmod 777 /dev/disk0s3
VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0 -filename bootcamp.vmdk -partitions 3
sudo chmod 777 *.vmdk

The step above assume that your boot camp partition is the 3rd one on the first disk (using "diskutil list" in a terminal):



Step 4: Create a VM Using the vmdk you just created:
Once you have the virtual disk created, you can start VirtualBox and create a new virtual machine, make sure you use the disk you just create as the VM disk.




Step 5: Format and Install Windows 7
Once the above is done, you can start booting up the VM on your install CD/ISO. When you get to the screen of partition selection make sure to select the one named "BOOTCAMP":


Then Click on "Drive options" and then "Format":




Note that after formatting the disk the name of the partition is changed to basically nothing. Nothing to be alarmed about. You can then proceed to the next step and let windows do its job, until it reaches the first reboot.

When you reach the first reboot, let the VM shutdown properly, but when it restarts, turn it off for good. It now time to reboot your real machine and continue the setup in "Hardware mode" so to speak. When your Mac reboots, don't forget to hold the "Option" key to be able to boot on the windows partition.

Thanks to Anil Dash from which i got the idea of create a virtual disk pointing to a real partition.

Hope this guide will help.

Don't forget to click the "+1" button if that was helpful.

PS: There was an unforseen Part 3 where the Windows Installer got stuck.