Ramblings from another nerd on the grid
Question: I need to run a hyper-v virtual machine but Windows 7 is my production operating system. Do I need to re-build my machine?
Answer: Absolutely not.
If you are running Windows 7 today, there’s no reason to tear down your machine, re-partition your drive, and reinstall your world. Instead, you can simply install Windows Server 2008 R2 into a .VHD file and make it bootable. After that is accomplished you can choose the OS you want when you power up your machine. The following steps are the simplest way (currently) to do this. It really doesn’t get any simpler.
Implement Windows Server 2008 R2 the Easy Way
1. Install Windows 7. I’m assuming you have already done this and it’s your normal work environment. You are going to need the Windows Server 2008 R2 bootable installation disk later in these steps. If you haven’t done so already, download the .ISO from the products servers or the download area of MDSN or TechNet (subscriber area).
2. Do a full backup of your system. We aren’t anticipating any issues but you never know. You can create a Full System Image in Windows 7 Enterprise or Ultimate. This is an exact clone of your hard drive. To create the backup, go to Control panel | System and Security | Back up your Computer. You’ll see “Create a system image” in the task list on the top left corner of the screen.
3. Launch the Win 7 Computer Management console. This can be accomplished from the Administrator Tools or by right mouse clicking Computer and selecting the Management menu item.
4. Click Disk Management
5. Click the Action menu and select Create VHD as shown in the screenshot below.
6. You will be presented with the following dialog box. As you can see, I am creating a 30GB dynamic .VHD on drive C:. The assumption here is that C: is not BitLockered. When using BitLocker, the .VHD must reside on an unencrypted partition or drive. Since I routinely use drive D: for storage, this doesn’t present a problem for me. If you only have a single disk and plan to use BitLocker, you must create a partition to store the unencrypted bootable VHD’s. For now, we’ll assume BitLocker is not used.
Drive C must always have 30GB of free space whenever I boot the R2 .VHD because it will be fully expanded at boot. I may only be using 12GB of the 30GB, but all 30 must be there or you can expect a BSOD. I normally create my bootable .VHD’s on a high capacity drive in the multibay of my laptop. The target subdirectory must already exist.
7. You’ll notice when you click OK, the Microsoft VHD HBA driver is installed and the .VHD is created. It’ll be about 62KB in size initially.
8. Right mouse click the newly created disk in the disk management console and select Initialize as shown below.
9. After you init the disk, right mouse click the unallocated space and create a simple volume. Quick format the entire 30GB as NTFS. You are nearly ready to install Windows Server 2008 R2 at this point.
10. Place the Windows Server 2008 R2 installations DVD in your CD/DVD drive and reboot your machine.
11. When prompted, hit enter to boot from the install DVD.
12. Click the Install Now button in setup to proceed.
13. Select Enterprise (Full Installation) from the SKU selector.
14. Accept the EULA.
15. Click the Custom Installation button.
16. Proceed in the R2 setup program until you get to the dialog box where you select the target disk and partition. You’ll notice we do not see the .VHD file we created. Shell out to the command line via the SHIFT+F10 shortcut key sequence.
17. Enter DISKPART to launch the disk and partitioning utility.
18. Enter SELECT VDISK FILE=C:\R2\WS2008R2.vhd.
19. Enter ATTACH VDISK
20. At this point you can click refresh on the drive listings and the VHD will be available as the target of the install. Select the VHD and click next to proceed with the install. You can ignore the warning about installing Windows to the VHD target.
That’s it. After Windows Server 2008 R2 installs, you’ll have a dual boot system. You will of course need to install the Hyper-V role, learn how to create or import virtual machines, and do other tasks in the operating system but this should get you well on your way. And you didn’t need to re-install your entire world to do this.
[Note] As I have previously indicated on other blogs posts, this installation method is technically unsupported. In fact, the steps above have been covered before. I sent the information above to a couple of internal email distribution lists because some of our developers have not used Hyper-V and I wanted to give them the condensed, short form of the information.
Ok, so this is a pretty cool exercise, but what are the advantages to doing it this way vs. just creating a second partition? With Windows 7, can't you just use the "Shrink Volume" option?
Ever tried to move a partition? Moving a .VHD is a heck of a lot easier.