And now for something completely different for Windows: Virtual Hard Drives.
Have you discovered all Windows 7′s secrets yet? There’s one you need to know about that will have you doing back flips: Virtual Hard Drives (VHDs). Last week’s post, â€œWindows 7 a la XP Mode,” gave you an overview of 7′s capability to host a Windows XP virtual machine (VM) plus share applications with the VM instance. This week you learn how to use virtual hard disks with Windows 7 and the best part is that you don’t have to install any other software to do it. Windows 7 has everything you need by default.
Windows 7 has native support for Microsoft’s VHD format. You can create, attach (mount), detach (unmount) and delete VHDs from within Windows 7′s Disk Management application. There are command line options for automating these procedures as well.
The Windows Way
Learning the Windows way of doing anything means that you’ll have mouse in hand and go a-clicking away until your carpal tunnel syndrome flares up. To that end, let’s begin with the anatomy of your fabulous new Windows 7 computer. You must have Windows 7 Enterprise or Ultimate installed on a physical machine (It doesn’t work on a Windows 7 virtual machine), CPU(s) with hardware-assisted virtualization extensions turned on and enough disk space to create VHDs with which to work.
With your Windows 7 computer humming away and your hand on mouse, direct your attention to the Disk Management program. My usual path to it is to click on the Start button, right click Computer, select Manage, expand Storage and then select Disk Management. Here, you’ll see your current disk(s) and the System Reserved partition. To create a new virtual hard disk, click Action from the Computer Management menu and select Create VHD. Enter a location, or browse to one, for the new VHD, a size in MB, GB or TB (Yes, TB!) and select dynamically expanding or fixed size and then click OK to finish.
Once your new VHD finishes its build process, it appears in the disk inventory as unallocated space. You’ll notice that right clicking the unallocated space now yields no selectable options. Right click the Volume column and select Initialize Disk from the menu. You’re prompted to select the partition table style for the new disk (MBR or GPT). Make your selection then click OK. Right click the unallocated space to create a New Simple Volume. The New Simple Volume Wizard appears and directs you through its creation, drive letter assignment, partition-formatting selections (filesystem type, allocation unit size, volume label, quick or standard format and folder compression).
When complete, your new VHD is ready for use as a mapped drive. This mapped drive is not persistent after a reboot nor can you map it with a NET USE command but more on that in Part Two of this article.
The Unix Way
Well, sort of the Unix way. In Unix, you can mount a filesystem on a directory and work with the contents in that directory as if they were part of the original filesystem. When finished with the directory, you can unmount it and use your original filesystem unchanged. You can also make the mount persistent (permanent) by entering it into the /etc/fstab file but it works a bit differently in Windows 7â€”actually, it works a lot different in Windows 7 but there are similarities and the behavior is a real departure for Microsoft operating systems.
To mount a VHD on a directory, create a new VHD as previously described but instead of assigning the VHD to a drive letter; you’ll assign it to a folder (directory). The folder you assign the VHD to must be NTFS and empty (unlike Unix). Once mounted, your new mounted volume appears in Windows Explorer ready to use. This mount, like the mapped drive, is not persistent through a reboot. Next week, I’ll show you how to do that.
Windows 7 comes to you ready for virtualization on two fronts; first as a host operating system and, second, as an operating system equipped with the tools to create and use VHDs. Windows Server 2008 has these same virtualization-ready capabilities. Next week, we’ll do this all over again at the command prompt, which is the only place where you can build in automation and persistence for these virtualization features.
Kenneth Hess is a Linux evangelist and freelance technical writer on a variety of open source topics including Linux, SQL, databases, and web services. Ken can be reached via his website at http://www.kenhess.com
. Practical Virtualization Solutions by Kenneth Hess and Amy Newman is available now.