Anyone who knows me personally knows that I run all of my work in a virtual environment. Back in 2009 when Hanselman posted about the Boot-to-VHD option of Windows 7, I had it up and running by the next morning. I’ve not stopped using it since.
My Setup
I have VHD’s for:
- Different Clients – Therefore I can join their domain and have a computer (VHD) dedicated to their setup. Since each client usually requires a particular set up that normally conflicts (if I were running a single machine) with another client, booting to a VHD allows me to have various configurations with different tools and sets up.
- Beta products – I’m in the process of creating a Windows Phone 7 app, yet the tools are in Beta. We all know about Windows Tools and the “beta” work – AKA:Your stuff might come to a crashing halt. Therefore I have a couple VHDs for testing various environments and tools.
- Android – I have a VHD that I use specifically for Android development.
- Personal Use – Sometimes I need to develop code in VS2010 or Eclipse or RubyMine and would like it to be separate from the rest of the code I have. This is where I put this stuff.
This process has worked great and I love booting to VHD, I think its one of the best things about Windows 7, hands down.
Can I run it on a Mac?
I’ve never been a Mac person until recently. My wife got a mac about a year ago and I’ve only used it to surf the web and fix some minor issues she had with printing. Other than that, I haven’t really touched it. However I have the need to develop iPhone and iPad apps as I’ve been getting a ton of inquires at my mobile devleopment firm – Agilevent to do so. My Dell D630 was on the way out (video card was pooping out on me) and it was time to buy a new PC before Heartland Developers Conference, which I’ll be presenting at in less than a month.
So, with some advice from Aaron Kardell (thanks Aaron) I picked up a refurb MacBook pro from the Apple Store online.
Booting to Windows and Creating a VHD
I knew that with the MacBook Pro I could run Windows 7 (as it was Intel based). This was possible to do through Bootcamp. This is something thousands of people do every day. Nothing big. However I wanted to install Windows 7, and then create multiple VHD’s for the MacBook pro environment. I followed the instructions in the Bootcamp documentation to set up Windows 7 on a different partition. I have a 500 GB HD, so I split the space equally between OSX and Windows 7. I then installed Windows 7 on the Windows partition.
When you boot a MacBook Pro with Bootcamp, you’ll get two options (if you hold down the options key on the Mac while booting). One is the Mac partition, the other is the Windows partition. I select the Windows partition to boot to Windows. Once I was able to do that, I followed Hanselman’s instructions to create a 80GB expandable vdisk using diskpart after booting to the Windows 7 DVD. This allowed me to create a virtual disk which I was able to install Windows 7 to.
When you select this new partition in the Window setup, it will warn you that you cannot (or likely should not) install windows because of possible driver issues. Blaaaah… nonsense, do it anyway. 🙂
After I let the install rip for awhile it was done. The system did reboot a couple of times and here’s where the a small problem started. When I added the vdisk and attached it, Windows gave it the boot loader name of “Windows 7”. However my default instance was also named “Windows 7”. Therefore when I booted into Windows 7 I had TWO “Windows 7” options. I eventually figured out which one was the correct one – but watch out for this because it can be tricky.
Fixing the Same Name Issue
After everything is installed, you’ll want to go back into your default Windows 7 installation and fire up bcdedit from the command line.
Issue the command:
bcdedit /v
This will show you all of the entries in the boot loader for Windows. On one of those you’ll see a path to your .vhd file. That one is your VHD boot. Grab the id (the long guid deal) and copy it to the clipboard. Then type the following command –
bcdedit /set {GuidGoesHere} description "VHD"
Of course, replace the “GuidGoesHere” with the guid you copied from the previous step, also give it a different name other than VHD if you wish.
After that, issue another bcdedit /v command and you’ll see the name has changed. Now, when you reboot into the Windows partition you’ll see the following two options –
- Windows7
- VHD
Creating Multiple VHD’s
Once your VHD is set up, you’ll want to boot back into your default Windows 7 install and then copy the .vhd file somewhere safe. This will be your boilerplate Windows 7 install. At a later time if you’d like to have ANOTHER VHD to boot from (maybe to test beta software, you go to a new client, etc), you can copy this same VHD into a new folder on the default Windows 7 install, perform the bcdedit commands to add the VHD to your boot loader (as listed in great detail in Hanselmans post) and now you’d have three options to boot from:
- Windows7
- VHD
- <YourNewEntryHere>
Booting to the VHD
To recap, I have a MacBook pro, which I’ve used Bootcamp to install Windows 7. Once that was installed I created a VHD (after choosing Windows 7 from the initial boot loading screen). I have created, perhaps, many VHD’s to boot to, and used the bcdedit tool to add them to my Windows boot loader options.
To boot the any of the VHD’s I perform the following steps –
- Power on the Macbook Pro while holding down the option key
- Select the Windows Partition to boot into.
- Once Windows start to boot I will receive an option of what Windows installation I want to boot into (the default “Windows7” or any of the VHD’s)
- I select the VHD, and Windows starts, running with full hardware support*
Its that simple. I can now copy over a new VHD, install some software and test it out.
* Drivers & Full Hardware Support – Because the MacBook Pro hardware is different than a regular PC, you’ll need to put the OSX install CD into the drive and install the Bootcamp tools for Windows. This will install ALL of the hardware drivers you need. You will then be able to use the “command” key on the MacBook Pro keyboard AS the “Windows Key” as you would on a normal Windows keyboard. I advise that you install the Bootcamp tools and then create a copy of the VHD as your baseline/boilerplate VHD. This will allow you to quickly copy over the VHD and get up and running smoothly.
Visualizing the VHD Install
To help you understand what just happend, I’ve created the diagram in Figure 1-1 below. Click it for a larger view.
Figure 1-1: Visualizing the VHD install. OSX and Windows are boot options. If booted to Windows 7, the other options then become available during the boot process of Windows
james swanson says
Excellent post! I have a similar setup with MBP and Win7 vhds (32bit) and everything works great. Recently I bumped memory to 8GB but I've hesitated moving to Win7 (64bit) because I didn't want to deal with potential driver issues. Are you using 64bit versions? Have you run into any sticky driver issues.
Donn Felker says
Hi James,
I'm running 64 Bit Windows as the default install as well as in the VHD's and I have not run into any issues yet. Full screen support, audio, keyboard, everything is supported thus far. I'd say reinstall with 64 bit and give it a go!
Donn
Paulk says
Great article. I'm a Windows soft. eng. and am needing to do x-platform on the OSX. Was thinking about this kind of setup but wondered if I really wanted to go this route or just get 2 laptops. You're article contained some great tips and helped me to get over my MacBook anxiety. Gonna go out and get one this weekend! Thanks much for taking the time to write this.
Paul Kissel says
See my post below for my thanks. One other scenario that I was considering:
Why not create/save/run multiple Windows VMs using VMware Fusion directly under OSX. Is the performance hit just too high? Just curious if you've played with VMware or read something that made you decide not to go that route.
Here's why I ask. One downside of your solution is that it requires a reboot to get from OS to the other. I'm doing cross platform Windows/OSX development and need to verify that code I've written and works under one OS works under the other. So I can see myself bouncing back and forth from one OS to the other to get code from from our SCCS and build and test it. VMWare or a similar solution SOUNDS ideal for this but at the same time if the compiler speed or battery life sucks then it isn't. Thanks for any thoughts that you have on this point.
Donn Felker says
Paul,
I'm actually using Fusion right now with great success. I agree switching OS via rebooting REALLY STINKS. So now I run fusion. It works great.
L2nex says
Is there any chance to trick it and set the .vhd in the hfs+ partition ? (I have a dream)
L2nex says
And can I delete the base windows system ?
I mean, keep the .VHD file only in the ntfs partition ?
So I’ll escape disk corruption, slow booting etc ?
Coach Outlet Online says
http://www.mycoachoutletstoreonline.com
Coach Factory Outlet says
http://buycoachfactoryoutletsz.com
Anonymous says
have you tried creating VHDs from the install environment and never actually doing a full base install of windows 7? youve really piqued my interest with this.
Anonymous says
there is always a performance hit when running in a virtual environment. especially so when crossing platforms (OS x/windows/*nix)
Best Website Hosting says
Well, the publish is actually the best on this suitable subject. I recognize with your findings and will desperately look ahead to your inbound up-dates.
research paper custom says
the content can be seen that many of the themes uncovered Pts … just what I needed … but I would like to more information on package development environment and a built-in programming language
toxin wash says
Hey! Can I install Windows on my External HDD? And how do I go about doing that? Thanks!
Anonymous says
Is it true this only works if you have Win7 Ultimate or Enterprise? I currently have Win7 Pro Bootcamped on my MBP (Lion). I would like to give Win8 a try.
Jaspreet Singh says
ya
try easybcd