Multi-booting Windows 7/2008R2 From VHD
One very useful feature of Windows 7 and Windows Server 2008 R2 is the ability to boot the OS directly from a virtual hard disk file (VHD). This can make it pretty straightforward to be able to run a number of different versions of Windows on a single machine.
I just finished converting my test machine to a boot-from-VHD scenario; before that, I was using a native Windows Server 2008 R2 install with Hyper-V. Here's some of my observations about the tradeoffs (remember, I DO NOT speak for Microsoft):
- Boot-from-VHD is not virtualized; you are just running the OS out of a mounted VHD file
- Because of this, you might expect boot-from-VHD to be a bit faster than a virtualized OS.
- Since a lot of our work is based on virtualization technologies, it seems weird to test it in Hyper-V (a VM within a VM) and sometimes I wonder if issues I see are a result of my environment.
- With Hyper-V, you can run all your test operating systems at once; boot-from-VHD is one OS at a time
- VMs in Hyper-V have snapshotting, so it's easy to roll back to a pristine state
There's a few other minor tradeoffs in the boot-from-VHD scenario, but not enough to fret about too much. So I thought I'd give it a try.
To start out, just plop in your Windows 7 media and start a clean new installation of Windows 7. Or, if you are like me, you can pixie boot it. Start the Windows 7 installation. Once you've passed the language selection screen, hit SHIFT+F10. This brings up a WinPE console. Type "diskpart" in the console to bring up the disk partitioning tool.
If you need to, reformat your primary drive:
- sel disk 0
- cre part pri
- format fs=ntfs quick
- assign
Now, create a VHD for each OS you want to install (put in a value for maxfilesize, in megabytes):
- create vdisk file=c:\vhdname.vhd maximum=maxfilesize type=expandable
- select vdisk file=c:\vhdname.vhd
- attach vdisk
- cre part pri
- format fs=ntfs quick
Exit diskpart and WinPE. When you get to the destination media selection screen, where you decide which volume to install your OS to, select the first VHD in the list, not your base drive. The size should be close to what you specified. IMPORTANT: Ignore the warning that Windows can't install to that disk - it will work just fine.
After you finish installing your first OS, you can insert the media for the next OS and restart. Go into setup the same as before, and just like before, enter WinPE after the language selection by pressing SHIFT+F10. This time you don't need to create the VHDs. They are still there, you just need to attach them again:
- select vdisk file=c:\vhdname.vhd
- attach vdisk
I attached all of mine in the same order as before. I don't know whether this is the right thing to do or not but it seems to have worked okay.
After exiting diskpart and WinPE, you should see the mounted VHDs listed in the media selection screen again. This time install to the second VHD in the list. You should be able to tell the difference because the first one shows less available space than the other VHD(s). Again, run through the install as before.
Now once you finish you can boot to any of the options in your boot loader menu, if you can distinguish them. You may wish to edit the boot loader config. Do the following:
- Launch an elevated command prompt
- Run bcdedit. Take note of the identifiers (GUIDs) for each of your machines - you will need this information momentarily.
- To change the description of an entry, type bcdedit /set {identifier} Description "a meaningful description" where:
- identifier is the GUID of the machine you want to change. {current} and {default} work for the machines they pertain to in bcdedit
- a meaningful description is the text you will use to identify this machine in the bootloader
- To set a different entry as the default, type bcdedit /default {identifier}
- To set the timeout value for the bootloader, type bcdedit /timeout <seconds> where <seconds> is the number of seconds you want to wait
- For help with bcdedit, type bcdedit /?
Using this technique, I set my machine up for a triple-boot with Windows 7 32-bit, Windows 7 64-bit, and Windows Server 2008 R2. And, within Windows Server 2008 R2, I should be able to run Hyper-V, where I can run additional Windows 7 test VMs with snapshotting. The best of both worlds!
-
http://www.codingfrogs.net/2010/10/21/automounting-a-vhd-at-system-boot-on-windows-7/ Automounting a VHD at system boot on Windows 7 | c o d i n g f r o g s
