This is the story of how I spent an entire saturday roasting a turkey and getting Windows 7 onto my computer.
The Problem: On current (2011) MacBook Pro notebooks, Windows 7 can not be installed from a USB-DVD drive. If your internal superdrive is broken or you chose to remove it for some flashy reason, getting Windows installed on your computer can be a real pain.
The things that did not work:
- Attempting a standard boot camp install from a USB-DVD drive results in you staring on a blinking cursor on a black screen forever.
- Attempting to install windows from a USB flash drive created by the Boot Camp Assistant on a MacBook Air will not work either, did not even get recognized by the computer as a bootable device. Why this is possible on the MBA but not on same generation MBPs is a bit strange to me and I wonder what weird things the MBA firmware has to do to allow this method of installation.
- Attempting to boot the Windows setup from a USB flash drive created by the Microsoft tool failed as well, giving either the blinking cursor infinitely or with the EFI BIOS emulation layer complaining about a missing boot medium.
How it finally worked:
As far as I am able to reconstruct from the tabs still open in my browser, the idea of using virtualization to achieve my goal came from this Macrumors forum thread. I did not read it completely, because I find it to be quite a hassle extracting coherent information out of a multiple page forum thread with tons and tons of quotes and chaos. This is also what motivated me to do a popper writeup here.
Since I already had a complete installation of Windows in a VirtualBox guest that I used to create the second installation flash drive, it seemed logical to use it. What I wanted to do was to put the Windows partition from the virtual hard disk onto the preexisting but empty Boot Camp partition on my physical hard drive. That meant I had to loopback mount the VirtualBox .vdi into my OS X. Unfortunately I can not find the tabs anymore that lead me to success on that front, but the steps I took were these:
The two step process of creating an image of the mounted volume and then restoring said image onto the Boot Camp partition on my hard drive was painless and without problems. A quick reboot confirmed the preliminary success: The newly cloned Windows shows up in the computers boot selection menu. Unfortunately Windows crashed with a blue screen sometime during the boot process. I took a quick detour here, booting Windows from the physical partition in a special VirtualBox Guest to prevent Windows from automatically rebooting in case of fatal errors, which is just a setting. To create a VirtualBox disk that points to a physical partition, you can use
$ sudo VBoxManage internalcommands createrawvmdk -filename myos.vmdk -rawdisk /dev/disk0 -partitions 4
To figure out which disk to use as -rawdisk, use
The appropriate argument for the -partitions switch can be determined by using
$ sudo VBoxManage internalcommands listpartitions -rawdisk /dev/disk0
I had to make sure that at least the partition itself is not mounted for creation of the .vmdk file as well as for running the VirtualBox guest using it. For permissions reasons I ran the VirtualBox machine as root, check the documentation to see what I’m doing here, basically I just import the VirtualBox machine into the VirtualBox config for root, attached the .vmdk that I just created and fired it up:
$ sudo VBoxManage registervm /path/to/my/virtualbox/win764.vbox $ sudo VBoxManage storageattach win764 --storagectl SATA-Controller --medium /vmtests/myos.vmdk --port 0 --type hdd $ # again, this may vary according to your VM config $ sudo VBoxManage startvm win764
Some information on this came from this blog post by a guy named Garret.After disabling automatic reboot in Windows it turned out that the blue screen did not reveal any useful information, it was just a very generic STOP error.
Now the guys at the opensuse forums and a friend steered me to the idea that the crash is most likely caused by Windows using drivers it configured while in a VirtualBox guest.
I used the utility sysprep.exe to modify the windows installation to not use the exisiting hardware configuration. The process relatively well documented on TechNet, so I won’t go to deep into it here.
You only need to follow the steps under “Generalize the Image”. After that, just reboot into your new Boot Camp Windows as before. If everything worked your Windows installation configures itself, reboots and then you’re done.
The things I would do differently now:
I am pretty sure that I did not do this in the most efficient way because I was figuring out what to do as I went along. The following procedure has not been tested, but if I had to do this on another machine now I would try something along the lines of:
- Create the Boot Camp partition
- Create a VirtualBox guest using that partition and installing Windows 7 in it.
- Now either you shut down the VirtualBox guest before it performs its first reboot and continue the setup by booting the half installed windows normally now
- or you finish the installation virtually and then generalize.
Either way should get you to a working Windows installation much quicker.
If you try any of this or find it useful, you’re welcome to leave any comments or additional information in the comments section of this blog post. -@rpl
Software I used:
- Virtualbox 4.1.6
- Winclone 2.3.2
- Microsoft Windows 7 Professional with Service Pack 1 64-bit (English)
- Boot Camp Assistant Version 4.0.1 (429)
- Mac OS X 10.7.2 (11C74)
- Create Boot Camp partition using Boot Camp Assistant
- Install Windows 7 into a virtual machine
- Convert the virtual disk image to a fixed size and then to a raw file
- Mount the raw image as a loopback device
- Use winclone to transfer it on to the Boot Camp partition
- Boot & fail with BSOD
- Boot the Boot Camp partition in Virtual Box
- Generalize the Windows install using sysprep
- Boot the Boot Camp partition and
- Be happy!
UPDATE: Hugues Valentin wrote about his experience with this process, his article is also available in french. He especially covers the steps involved in generalizing the Windows installation in more detail, so head over to his site and check that out.