Link to home
Start Free TrialLog in
Avatar of Pumpernickel
PumpernickelFlag for United States of America

asked on

Resizing VHD

A person before me decided to make VHD for Hyper-V and made them with a ridiculous amount of space.  One of them is at 90GB (HD Space).  I want to resize them that one to about 20GB.  So I used VHD Resize.  It resized the HD to 19.53 GB.  Now the problem is the space that it took away is listed as unallocated space, which is still keeping the .vhd file size at 51GB.  Is there anyway for me to remove that unallocated space so I can get the .vhd file size down?
Avatar of msmamji
msmamji
Flag of Pakistan image

So If I understand you correctly you used the shrink option from inside the VM to reduce its size and therefore you have the resized the "volume", and not the VHD. Well you have done half of the work, now you need to shut down the VM and use the VHDresizer tool to resize the VHD.

http://vmtoolkit.com/files/folders/converters/entry87.aspx
http://www.windowsreference.com/free-utilities/vhd-resizer-resize-microsofts-vhd-hyper-v-files/

Regards,
Shahid
Avatar of Pumpernickel

ASKER

No, I used the VHDresizer already.  I didn't do anything from inside the VM.  I just used the VHDresizer to resize the VHD.  All that did was resize the C:\ from 90GB to 20GB and now there is about 40GB of unallocated space in the Disk Management.  The .VHD file didn't change in size, only the VHD C:\ changed.  It pretty much just took 40GB from the C:\ and made it unallocated.  I want to get rid of that unallocated space now so the VHD will shrink to a smaller size.
Well, the proper way is too shrink the volume from inside the VM OS disk management. What this does is that it takes the look at the volume check and see to what extend it can shrink the volume and then gives you the option to shrink it. These leave you with a volume shrunk to the size you selected and leftover space shown as unallocated space. This makes no difference to the size of the VHD as its unaware of operation as such.

You then have you use the vhdresizer to resize the VHD. The VHDresizer will ask for a VHD and use it as a source. Once selected it takes a look at the VHD (like its type and current size). You then have to make a target VHD, and have the mix and maximum values given. The minimum value for your case should be 20 GB. you select this as the size of the new (target) VHD and click resize. It will make a new VHD and copy all the content form the source VHD.

This is a non distructive exercise, as your source VHD is untouched. Just make sure you select the correct size and type when creating the new VHD.

See if that help. Try the VHDresize again on the VHD. you don't have to do the shrink operation as you already have done that.
The problem now is I have a 20GB Partition and 40GB of unallocated space.  So I can't resize anything in windows from the disk management because there is nothing to resize now.  And I already used VHDResizer to resize it which caused this issue.  So now what should I do?
did you try only the VHDresizer again? what is the min suggested size does it give you for the target VHD?
Min is 19GB.  So your saying I should put in 20GB again?
Also, the type is Dynamic by default.
what is your current default type? fixed or dynamic.
I am guessing it is fixed. Your target type should also be fixed.
If it show 19 GB the select 19 GB and resize.

What OS are you running in the VHD?
Dynamic is the default on VHDResize.  Windows XP is the Target OS.  VHDResize is installed on Server 2008 Standard w/ Hyper-V which is where the .VHD files are stored.
OK.. what you are saying that you have a 51 GB dynamic VHD (total size 60 GB) with a windows XP installation on it. In the disk management inside the XP VM, you see one volume with one partition of 19.53 GB and unallocated space of 40 GB. Is this correct?
Secondly, You want to resize the VHD and make it smaller somewhere in the vicinity of 20 GB. Is this correct?
Yes.  
I would suggest to use the vhdresizer again, this time select the target VHD type as fixed and your size to minimum allowable i.e. 19 GB. Try the resizer with these option.
Fixed size VHDs are better interms of performance and you pre-allocate all the space needed by them at once.
I just set it to fix and it worked.  Now my other issue is I have another VHD that is 96GB.  I want to shrink that to 30GB.  How can I do this with the Disk Management that you were talking about earlier.  I was always under the impression that Windows XP Disk Management can't shrink volumes.  Also, when I opened VHDresizer, it says Min 96 so I have to shrink it first.
Disregard.  I do remember you can shrink and extend volumes.  But when I right click on the C:, there is no shrink volume available.  
ASKER CERTIFIED SOLUTION
Avatar of msmamji
msmamji
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial