How to expand a VHD disk
NB, MAR 2009: It was brought to my attention (thanks Fernando) that utilities like VHDResizer ( https://vmtoolkit.com/files/default.aspx ) may do the job in a simpler way. I did not check myself.
I was working on a Virtual PC 2007 virtual machine with a dynamically expanding disk of a maximum of 16 Gb.
This disk was the C: system drive on the virtual machine and I was running out of virtual space (I had enough space on the hardware host disk).
A dynamically expanding disk can only grow to its predefined maximum size. The name comes from the fact that if you store 10Mb in a 16Gb dynamically expanding disk, vhd file size will only be ~10 Mb. You'll find much more at https://support.microsoft.com/kb/825092/en-us
So the virtual guest machine had a 15.5 Gb system drive for a maximum of 16Gb.
Here is what worked for me.
Let's call C.vhd the file of the 15.5 Gb C: drive.
- shut down the guest virtual machine
- Create thru the Virtual Disk Wizard a new dynamically expanding disk with a max size of 100 Gb => this creates Cbis.vhd with an initial size of a few Kb.
- close Virtual PC 2007
- use VHDMount (installed it on my Vista machine from the Virtual Server 2005 SP1 installation) to issue the following commands
(if prompted to format a disk, don't do it, if X: or Y: drives don't get created, don't worry)- vhdmount /m /f C.vhd X
- vhdmount /m /f CBis.vhd Y
- go to Disk Management (Computer, Manage, Disk Management) on the real Vista machine
- assign X: to the disk corresponding to C.vhd if it's not already done
- format the disk corresponding to CBis.vhd. NTFS, quick formatting is OK
- assign Y: to the disk corresponding to Cbis.vhd if it's not already done
- Copy all the files from X: to Y:
- robocopy X:\ Y:\ /E /COPYALL /R:5
- Fix any remaining copy issues (for instance ACL not authorizing administrators group to read)
- go to Disk Management (Computer, Manage, Disk Management) on the real Vista machine
- Mark Y: partition as active
- Unmount X: and Y:
- vhdmount /u All
- Change the virtual machine .vmc file (with notepad) and replace C.vhd by Cbis.vhd
- Restart virtual machine
Then you can delete C.vhd and keep CBis.vhd.
Comments
- Anonymous
October 04, 2007
PingBack from http://www.artofbam.com/wordpress/?p=5268