Solved

Resizing VHD

Posted on 2010-08-12
15
3,277 Views
Last Modified: 2013-11-06
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?
0
Comment
Question by:cmb991
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 15

Expert Comment

by:msmamji
ID: 33423050
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
0
 
LVL 1

Author Comment

by:cmb991
ID: 33423160
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.
0
 
LVL 15

Expert Comment

by:msmamji
ID: 33423300
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.
0
Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

 
LVL 1

Author Comment

by:cmb991
ID: 33423443
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?
0
 
LVL 15

Expert Comment

by:msmamji
ID: 33423522
did you try only the VHDresizer again? what is the min suggested size does it give you for the target VHD?
0
 
LVL 1

Author Comment

by:cmb991
ID: 33423691
Min is 19GB.  So your saying I should put in 20GB again?
0
 
LVL 1

Author Comment

by:cmb991
ID: 33423695
Also, the type is Dynamic by default.
0
 
LVL 15

Expert Comment

by:msmamji
ID: 33423800
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?
0
 
LVL 1

Author Comment

by:cmb991
ID: 33423816
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.
0
 
LVL 15

Expert Comment

by:msmamji
ID: 33424013
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?
0
 
LVL 1

Author Comment

by:cmb991
ID: 33424036
Yes.  
0
 
LVL 15

Expert Comment

by:msmamji
ID: 33424137
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.
0
 
LVL 1

Author Comment

by:cmb991
ID: 33426167
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.
0
 
LVL 1

Author Comment

by:cmb991
ID: 33426183
Disregard.  I do remember you can shrink and extend volumes.  But when I right click on the C:, there is no shrink volume available.  
0
 
LVL 15

Accepted Solution

by:
msmamji earned 500 total points
ID: 33427121
This are issue with diskpart and disk management tools in windows XP (infact any windows below Vista), you don't have the option to shrink the volumes. Thats why, I was a little baffled as to how you do got it to shrink using VHDResizer.
There are a couple of thing you can do.
If you have a Windows Vista/2008/Win7/2008 R2 VM available. You can add this VHD as a secondary disk in to the VM and then use there disk management tools to shrink you vhd you added as a secondary disk. Once you have done that you can detach the VHD from the VM and use the resizer as you did before.

If your Host is running Windows 2008 R2, then you can attach the VHD directly to the host and then use disk management to shrink the VM. Once done detach and run resizer. This attach VHD option is also available in Windows 7.
How to attach a VHD
If you don't have a Vista/2008/Win7/2008 R2 VM and you host is Windows 2008 (not R2), you can install VHDmount tool available in Virtual Server 2005 R2 SP1 setup and use it to mount the VHD and then use the disk management tools to shrink the VHD.
Mount a VHD file with VHDMount

Before performing any of the above operation I would advise to backup the VHD in question.
Hope that helps.
Regards,
Shahid
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question