Jan 03 2007 - Explore expanding VHDs for development, using Microsoft Virtual Server and WAIK for copying onto larger VHDs when space ran low.
This article is a bit old, but some still find it helpful. Links to URL's that are no longer available have been removed.
I have a standard set of Virtual Machines images that I do much of my development with. For the most part, I created the virtual machines and their associated virtual drives using the default settings. As I'm using Microsoft Virtual Server 2005 R2 (x86), the default size for a new virtual drive is 16 GB (this changes with Service Pack 1 to 126 GB). This has been plenty of space and all things have ran well, until I started to install the Microsoft .NET Framework 3.0, Visual Studio 2005 Extensions for Windows Workflow Foundation, Vista and .NET 3.0 SDK, Visual Studio 2005 Extensions for .NET 3.0, and much more. I didn't run all the way out of space, but I was getting close. So I needed to expand my virtual hard drive.
At the moment, there isn't a feature in Microsoft Virtual Server 2005 R2 (not even with the Service Pack 1 beta) to expand the size of a virtual hard drive. So begins the challenge…
Since I couldn't make a modification to the original virtual hard drive (VHD) in order to increase the amount of space, I would need a way to copy the contents of the original VHD and store that data on a new VHD. There were two options that I looked into. The first was to leverage the new feature available in Microsoft Virtual Server 2005 R2 Service Pack 1 named, "Offline VHD Mounting". This enables me to mount a VHD drive as a local drive on my workstation and access it like a physical drive. So in theory, I could simply copy and paste the content. I tried this out with not much success. The issue I ran into was trying to mount to a newly created VHD. To be fair, I didn't spend much time working through this issue as I quickly dove into my second option.
The next approach was to leverage the newly released Windows Automated Installation Kit: (Link no longer available from Microsoft)
The Windows Automated Installation Kit (WAIK) is a deployment and imaging technology the enables IT administrators to take snapshots of a base image, deploy the image, and even directly edit the image while in its compressed form. There ton's of cool stuff in there and I encourage you to read the following article to learn more:
There are many advantages to leveraging WAIK to solve this problem:
Another very interesting component of WAIK is the WindowsPE component. WindowsPE enables you to create a bootable CD the provides support for network connections, manage the disk partitions, and (of course) kick off a capture or attach (aka deploy) an image. Here's a great article to learn more:(Link no longer available from Microsoft)
Before you get started, make sure you download and install the following software components:
OK, so let's get down to how I used WAIK to create a copy of a VHD with an increased disk size. In the steps provided below, I provide the steps I took and the command line arguments that I used. This doesn't mean that this is the only way it can be done, but points out what I used to get the results I was looking for and that matched my configuration/environment. Also, many of the WAIK steps noted below can be found in the "Getting_Started_ITPro.rtf" document provided as part of the WAIK.
cd Program Files\Windows AIK\Tools\PETools\
copype.cmd x86 c:\winpe_x86
copy "c:\program files\Windows AIK\Tools\x86\imagex.exe" c:\winpe_x86\iso\
Oscdimg -n c:\winpe_x86\ISO c:\winpe_x86\winpe_x86.iso -n -bc:\winpe_x86\etfsboot.com
net use z: \\computername\wim /user:computername\username
imagex.exe /compress fast /capture c:\ z:\myimage.wim "my image" /verify
diskpart
select disk 0
clean
create partition primary
select partition 1
active
format
exit
net use z: \\computername\wim /user:computername\username
imagex.exe /apply z:\myimage.wim 1 c:
At this point, you should be all set. What you'll now have on your local hard drive is your original VHD (not assigned to an Virtual Machine), a WIM file which is a snapshot of your original VHD, and a new VHD (larger in size) with the content from the Original VHD.
I've had this up and running for a few days now without any issues. I hope this helps and I plan on doing some more posts on this subject as I start to use it more
Feel free to leave a comment below. Keep in mind that all comments are moderated and will be approved before being published.