Solved

After shrinking a Hyper-V Virtual HD how to you release the unallocated space

Posted on 2013-05-27
22
643 Views
Last Modified: 2014-11-12
I'm learning on a test server how to increase and decrease the size of a Hyper-V HD.  After I decrease the size, there is unallocated space left.  

How do I release it so the host can use it?

I've looked for some articles, but can't find this answer.
0
Comment
Question by:jrsitman
  • 10
  • 5
  • 4
  • +1
22 Comments
 
LVL 10

Expert Comment

by:Subhashish Laha
ID: 39199419
Refer below article

http://sqlsolace.blogspot.in/2008/05/compressing-hyper-v-disk-images-vhd.html

Note: VM should be Powered Off
0
 
LVL 20

Expert Comment

by:Svet Paperov
ID: 39199425
In Hyper-V Manager: convert the VHD file to dynamic and then run Compact.
0
 

Author Comment

by:jrsitman
ID: 39199452
Tried it and it still shows the unallocated space.  I did a refresh and a rescan.

I powered it off.  Should I shut it down?
0
 

Author Comment

by:jrsitman
ID: 39199487
Sorry I thought the disk was already Dynamic.  I converted it.  However, it still shows the unallocated.

What exactly is a Dynamic disk?  
Is it better for VM HD's to be Dynamic?  
Can you convert it back to basic?
0
 
LVL 20

Expert Comment

by:Svet Paperov
ID: 39199490
What is the OS of the VM and how did you do the resize? Shrinking of VHD file is not suppored by Hyper-V Manager of Hyper-V 2008 R2. However, there are other unofficial methods. Which one did you use?

In some cases convering VHD to dynamic won't help with the compact: for example, if you have multiple partitions on the virtual disk, or if it's a Linux partition.
0
 
LVL 20

Expert Comment

by:Svet Paperov
ID: 39199496
By converting a VHD file to dynamic I meant converting on the Hyper-V level not inside the VM.
http://technet.microsoft.com/en-us/library/cc720363%28v=ws.10%29.aspx
0
 
LVL 10

Expert Comment

by:Subhashish Laha
ID: 39199497
No, you cannot convert Dynamic disk to Basic disk.

The Basic disk and Dynamic disk has different propertise. Read below link
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363785(v=vs.85).aspx


"spaperov" refered to Dynamic VHDs. Read below link for more information on different types of VHDs
http://www.altaro.com/hyper-v/hyper-v-guest-design-fixed-vs-dynamic-vhd/


To resize VHD, you can use VhdResizer. Refer below link for more information and to download VhdResizer
http://www.bursky.net/index.php/2013/02/resize-vhd-volumesize/
0
 

Author Comment

by:jrsitman
ID: 39199541
The OS of the VM is 2008 R2

I right click the drive and chose shrink

Since I misunderstood the VM HD is now Dynamic

I just Extended it to the full available size.  

I have VHDresizer.  Should I use it now from the HOST?

So now how do you suggest I proceed?  Keep in mind this is a test server, so if I've screwed it up, no big deal.
0
 
LVL 10

Accepted Solution

by:
Subhashish Laha earned 250 total points
ID: 39199570
As you want to decrease the size of VHD.

First, Shrink the volume to the desired size you want inside VM i.e. in Windows 2008 R2.

Then shutdown the VM.

Open VHDresizer on Host and select VHD file

Provide new size and destination of new VHD. (Make sure the new VHD size should not be less than the volume size inside VM - otherwise Data inside VM will corrupt.)

After VHDresizer is completed, you can attach the new VHD and boot VM.

Once everything is fine inside VM, you can delete the old VHD.
0
 
LVL 20

Expert Comment

by:Svet Paperov
ID: 39199580
I've already used the following procedure when I did P2V of Windows Server 2003 disks. You could give it a try:

http://blogs.technet.com/b/tonyso/archive/2008/10/09/hyper-v-how-to-shrink-a-vhd-file.aspx
0
 

Author Comment

by:jrsitman
ID: 39199649
@subhashishlaha  I followed the steps and shrank the drive from 125 to 90.  I shut it down and ran VHDresizer.  In the new size it will only let me enter 125 or higher.  It won't let me reduce it.  See attached.
resize-VHD.png
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 38

Expert Comment

by:Philip Elder
ID: 39200158
Three methods to do what you ask:
http://bit.ly/12KkFYs

Note that there is a bug in Resizer (as per the linked blog post) that won't allow the smallest size. Do Smallest size +1.

Philip
0
 

Author Comment

by:jrsitman
ID: 39202459
@MPECSInc, if you look at my last post, the problem is I can't shrink it.  It states the smallest size is 125.

So I don't know how to proceed.  See the attached in this post.
VHD-size.png
0
 
LVL 38

Expert Comment

by:Philip Elder
ID: 39202811
Isn't the drive supposed to be "FIXED"? Your original snip earlier stated "Dynamic".

Sorry, not 100% up on running the resize tool.

Philip
0
 

Author Comment

by:jrsitman
ID: 39202910
I believe so, but in an earlier post it said to make it Dynamic, but he was referring to the Host not the VM.  However, I changed the VM.  I just tried converting it back to Fixed and it fails stating there is not enough room.

I'm getting the impression it's time to create a new VHD.  Anybody got any thoughts?
0
 
LVL 38

Expert Comment

by:Philip Elder
ID: 39202925
Not enough room on the host's storage?

Probably as the process probably needs current storage plus migrated storage available plus some space for a temporary file.

Try again. Start fresh making sure you have enough storage to make the necessary changes. At least your error was different the second time. :)

Philip
0
 

Author Comment

by:jrsitman
ID: 39202966
I host drive is very small 150 gig.  The VM is 125, so I doubt it will work.  It's not a big deal.  I built the server strictly for testing.
0
 
LVL 38

Expert Comment

by:Philip Elder
ID: 39202977
You could go 65GB for the VM and then run through the process. 2012 Server OS will start complaining about storage if the volume to install to is less than 65GB IIRC.

Since you are looking to run a test set up in 90GB and then run through to decrease to 70GB or thereabouts. Hopefully that will give you enough room to work. :)

Philip
0
 

Author Comment

by:jrsitman
ID: 39203056
I shrank it all the way to 40GB and it still states not enough room.
0
 
LVL 38

Assisted Solution

by:Philip Elder
Philip Elder earned 100 total points
ID: 39203070
Your source VHD is still 125GB though.

I am saying start fresh.

Philip
0
 

Author Comment

by:jrsitman
ID: 39203151
ok
0
 

Author Closing Comment

by:jrsitman
ID: 39206560
After I took the advice of starting fresh, I deleted the original VHD, created a new one, then followed the steps provided by subhashishlaha.

Thanks to all for helping.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Will try to explain how to use the VMware feature TAGs in the VMs and create Veeam Backup Jobs using TAGs. Since this article is too long, I will create second article for the Veeam tasks.
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.
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 the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

707 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now