As I was doing some experiments with my Virtual PC setup, I realized my base disk image was just too small. I was trying to install the Windows Driver Development Kit, and the installation failed because the disk simply had no room for it. When I first created my disk image, which is a basic Windows XP installation on a single NTFS partition that filled the VHD with a variety of utilities added to it to make my work easier, I created the VHD using the disk wizard with the disk size to 4 GB. I thought that because I had set it to be a dynamically expanding disk that it would allow the disk to grow to any size I needed later. Unfortunately, I was wrong; the disk is limited to 4GB but it will only be as large as is needed to store the used sectors. This makes sense now that I know more about it, but I was left with a decision to either reinstall XP from scratch or find some way to extend the partition.
I originally tried a utility called 'VHD Resizer' for extending the disk, but unfortunately it didn't work for me; booting the modified VHD resulted in a disk error. I was probably doing something wrong, but I couldn't think of any way to do it differently with the tool so I moved on to another option.
I downloaded the 'Ultimate Boot CD', which I had used in the past and is now on version 4.11. The plan was to create a new dynamically sized virtual disk at 50gb, larger than I expect it to ever need to be (this is just a test environment after all), and just copy the first VHD over into the new one. Seemed pretty straightforward, but my first attempt at it didn't work so I thought I'd describe what did work in case it helps someone else in the future.
First, create a new VHD that is as big as you ever think it might ever need to be. Bigger is fine, as long as it's dynamically resized it won't be any bigger than you actually need it to be. Change your VHD settings so that the new VHD is disk 1, and the old (too small) VHD is disk 2. We will be copying from disk 2 to disk 1 in a moment.
Next, download the latest Ultimate Boot CD ISO. Boot up the Virtual PC, and immediately "Capture ISO Image" which is off the "CD" menu. If you didn't do that fast enough, just reboot once it is set.
From here, go to the hard disk tools menu, then cloning tools menu, and finally run CopyWipe. I have no doubt other tools on this menu can do the same job here, but I used CopyWipe and it worked. Once selected, it will boot a minimal linux kernel and eventually CopyWipe will appear. Select "Copy a Hard Drive", then "BIOS HD", then "Hard Drive 1". Now you select the target hard drive; select "BIOS HD", "Hard Drive 0", and "Scale Size". Follow through with the copy.
When the copy is completed, disk 0 will be an expanded clone of your original disk 1. Shut down the Virtual PC, and remove the original VHD that is attached to Hard Disk 2 in the VPC settings. When you reboot, the new, larger VHD will be ready to go with the partition expanded to fill the disk.
Comments
How to use VHD resizer
For those who still whish to use VHD-resizer, I have posted the procedure:
http://kb.dutchalps.com/microsoftvirtualpc.htm#Resizing%20A%20Virtual%20...
Fantastic!!!!
Fantastic!!!!
I tried the vhdresizer method but the "resize" option was greyed out no matter what I specified.
Then I tried this method and it worked with no problems.
You are a complete and total Genius!!!!
Many Thxs
Thanks for the suggestion, it worked for me!
Eric
Thanks a million for the suggestion... I too had issues with the VHD expander, and couldn't get it to work for me. But using this mechanism, I was able to create a new VHD of the appropriate size, and then replicate the HD into it. I'm sure that the replication technique will be useful elsewhere (erm... TiVo HD replication, anyone? :-) ).