Showing posts with label virtual hard disk. Show all posts
Showing posts with label virtual hard disk. Show all posts

Thursday, January 13, 2011

Windows 7: Native Virtual Hard Disk (VHD) Boot

I was interested in making Windows 7 Ultimate run faster.  One possibility that came to my attention was using native virtual hard disk (VHD) boot in connection with RAID0.  This post discusses that.

A virtual hard disk was just a hard disk in virtual form.  Normally hard disks were physical.  A virtual hard disk, like a virtual machine (VM), would exist as a file (or a set of files) on a physical hard drive, not as a physical device in itself.  In other words, the user would have a physical hard drive in his/her computer, and somewhere on that drive s/he would have a VHD.

The "native" part of "native VHD boot" meant that the user would have direct access to the VHD.  Ordinary VM software (e.g., VMware, VirtualBox, Virtual PC) would require the user to install an operating system (e.g., Windows 7, Ubuntu) to serve as host (also called "parent").  Then the user would have to install the VM software (e.g., VMware) to manage the guest, and then install another operating system (e.g., Windows XP) inside the VM software as guest.

The VHD concept seemed to be that the host layer would be removed from the equation.  There would be a virtual hard drive that could be loaded or unloaded, perhaps without rebooting the computer.  The computer would be running the "guest" machine (e.g., a Windows XP installation) in virtual form.  For example, a packaged Windows XP installation could run on computer A, or on computer B, without having to be reinstalled and without having to install a host and a VM program like VMware.  In addition to simplicity, this scheme would presumably have the advantage of improving performance by removing extra layers and tasks.

In Windows 7, native VHD boot was apparently available only in the Ultimate and Enterprise versions.  This meant that it could be out of the reach of ordinary users who were not inclined to spring for such expensive software, unless perhaps they had access to it through their jobs or through academic versions.  It did not appear that Ubuntu, for one, would be developing a comparable capability in the near future.  There were hypervisors like VMware's ESXi that apparently provided somewhat similar bare-metal functionality, but ESXi seemed unavailable for my purposes.

I was interested in the possibility of using native VHD boot with RAID0.  This interest arose from a desire to make Windows 7 and other operating systems run quickly.  New installations of operating systems would typically perform well, I found, but then time and the addition of more programs and other demands would slow them down.  So, for example, I had found that Windows XP running as a VM inside VMware Workstation on an Ubuntu host was much more stable than native WinXP, but its performance had slowed dramatically.  My attempts to fix it (even through reinstalling both Ubuntu and VMware) had failed.  After several years of experimentation, I had therefore recently given up on Ubuntu for my purposes.

VHD seemed to offer a good way to run Windows 7 in a RAID array.  I had found that Win7 did not, itself, support booting from the software RAID0 arrays that Win7 was capable of creating.  In other words, a Win7 user could use Win7 to create RAID0 arrays, and could speed things up somewhat by putting some programs and data files on such arrays; but the user could not boot Win7 from a Win7 software RAID0 array, and would therefore have to install and run some Win7 program files from a basic hard drive.

As an alternative, the user could create a RAID array using hardware, either on the motherboard or on a third-party controller.  Hardware RAID had potential advantages of performance, bootability, level support (i.e., the ability to choose versions other than RAID0 and RAID1, including some I had not previously heard of), multiple operating system access (i.e., the data would remain available regardless of how the machine is booted), and reliability.  The performance story was a bit controversial.  I had seen indications that motherboard RAID was no faster than software RAID, and I had heard some claim that RAID0 was no faster than non-RAID, but my own experience (in Ubuntu) was consistent with tests indicating that even a software RAID0 was markedly faster than non-RAID.  Cost was a consideration.  While RAID5 was perhaps ideal, a Newegg search for a SATA RAID5-capable controller would cost hundreds of dollars.  Removing the RAID5 constraint led me to a $30 Rosewill item.  I didn't need that myself; I had motherboard RAID 0, 1, and 10.  For reasons of cost, noise, and heat, I wasn't going to be installing four drives to have RAID 10 (a/k/a RAID 1+0, which Wikipedia (apparently backwardly) called a stripe of mirrors, as distinguished from RAID 0+1, a mirror of stripes).  So for my purposes, it was a choice between hardware RAID0 or software RAID0; and since I was now using Win7 rather than Ubuntu, the desire to boot in RAID0 meant I would be using motherboard RAID -- unless VHD gave me a good alternative.

At this point, I had a general sense of what VHD sounded like.  Among other things, it sounded great.  But it seemed that I wouldn't run into the actual drawbacks and impossibilities until I created my own VHD and tried to use it.  As described in another post, the first step in doing so was just to create and play around a bit with a VHD, within a regular, running Win7 system.

Windows 7: Creating a Bootable Virtual Hard Disk (VHD)

As described in other posts in this blog, I was in the process of installing Windows 7.  I had discovered virtual hard disks (VHDs).  I was at the point of wanting to create a VHD that would boot Windows 7.  This post describes that creation process.

There appeared to be several ways to create a bootable Win7 VHD.  I could:

  • install it from scratch, using the Windows 7 installation DVD; or
  • convert an existing physical Win7 installation into a bootable VHD; or
  • convert a Windows Imaging format (WIM) file to a bootable VHD; or
  • deploy a WIM file into a VHD without conversion, and then boot the WIM file.
The fourth option was interesting, but I did not discover it until later.  The first option was tempting, insofar as it, too, would avoid a conversion process.  My prior experience in converting physical Windows XP machines to VMware virtual machines (VMs) using VMware Converter suggested that a conversion process might leave me with a buggy, poor-functioning VHD.

I chose to start with a conversion option nonetheless because I felt it offered some advantages over the approach of installing Win7 from scratch in the VHD.  For one thing, I had heard that a bootable Win7 VHD would not be upgradeable.  In that case, I would probably want to have a reference source -- a physical installation, that is -- that I could go back to, upgrade, and repackage into a new VHD.  Maintaining a reference physical installation could also mean that I could start with a smaller fixed-size VHD and then create a new, larger one as the size of the total Win7 installation grew, instead of taking what sounded like the more problematic approach of using a dynamically expanding VHD.  I also thought it would probably be handy, at times, to have that physical installation readily available, in case something went wrong with the VHD, or if it turned out that there were limitations on what the VHD could do.  That concern came from working with Windows XP VMs, in VMware, that were not able to access USB devices that a physical WinXP installation could access.  In addition, of course, a successful conversion strategy would save me the whole process of doing yet another installation from scratch.

As I looked into the conversion options more closely, it seemed there were a number of useful tools for the purpose.  WinImage was said to be a capable shareware, command-line tool that could create images in VHD format.  WIM2VHD was a freeware tool from Microsoft for the same purpose.  It appeared that Acronis True Image might be able to restore an image to a VHD.  Disk2VHD, another Microsoft offering, provided a way to create a VHD on a Win7 machine while it was running.  I preferred a GUI, if I could get it, and Acronis had recently disappointed me, so I narrowed down my choice to the two Microsoft tools.  Now it was just a question of whether I wanted to use WIM2VHD to convert a WIM to a VHD, or Disk2VHD to convert a running machine to a VHD.  I decided the latter was the more straightforward approach, so I started with that.

To create the VHD with Disk2VHD, I downloaded, unzipped, and ran Disk2VHD.  It was a portable program, so it did not need to be installed.  It recognized the partitions on my system, and asked which ones I wanted to put into the VHD, and where I wanted the VHD to be created.  For the target location, I designated a Win7 software RAID0 partition.  The source was a 70GB partition of which 32GB was used.  The target was a 100GB partition.  The process of creating the VHD (with source and target on different hard drives) took about five minutes.  The resulting VHD file was 26GB.  This, unfortunately, was not the right size.  It would not be big enough to accommodate any growth in the size of the Win7 installation.  It appeared that there were ways to expand it, but the methods I saw seemed to promise another layer of hassle, complexity, and potential failure. 

Back at the drawing board, WIM2VHD was advertised as creating sysprepped VHDs for native VHD booting.  It turned out that WIM2VHD was an automated way of doing the "deploy" (fourth) option listed above, so there were really only three options.  To run WIM2VHD, I had to download and install the 1.7GB Windows Automated Installation Kit.  I found a Microsoft website with authoritative information about VHDs.  At this point, however, I decided to postpone this project in favor of other pursuits.