Russ' Do It Yourself Home Workshop

Finding Fixes to Just About Anything and Everything

Posts Tagged ‘VHD’

Expanding a VHD on Hyper-V and the Infamous ‘The volume you have selected may not be extended’ Message

Posted by Russell Wright on March 30, 2009

This topic has been discussed by a number of people, but I was finding things weren’t working as easily for me as those who wrote about it suggested.  So, here’s my take on the process.

The day always comes when you have a VHD that is too small because of all the "junk" you’ve installed.  Then you are left with this problem:

Running out of space!

The process seems simple enough.  In Hyper-V you can easily edit the disk to resize it.  Make sure the VM is off before you begin!

Edit Disk in Hyper-V Manager

Select the disk you want to expand.

Select the disk

Choose the action (expand).

Choose Action

Set the new size.

Set the size

Review your selections and go!

Review your selections

Poof!  It’s done!  Now, if you were to boot up the machine and take a look at Disk Management (diskmgmt.msc) you’d see you have some unallocated space.

diskmgmtunallocatedspace

If you start up diskpart from a command prompt, you can list the volumes, select the appropriate volume, and attempt to extend it.  But, you may see a message like this.

The volume you have selected may not be extended

So here’s what I think I’ve found after several trials (and errors)!  From a Hyper-V perspective you need to remove the DVD drive so it doesn’t show up multiple times in the diskpart volume listing.

NoDVD

Now what you want to do is set up your VM to boot off the original, smaller disk and add the expanded VHD as the second hard drive.  Here’s what the VHD settings look like after the DVD has been removed and the expanded drive set as the second hard drive.

VHD Settings with DVD Removed

Now we’ll fire up the original VHD again with our expanded hard drive as the secondary drive.  Open a command part, type diskpart and then do a list volume command.  Select the volume (Select Volume X) that represents your 2nd drive…in this case it is the F: drive or volume 2.  Then type Extend.  Diskpart should find the continguous space and instantly extend the drive.

Select Volume and Extend with Diskpart
Here’s what the successful extension looks like with diskmgmt.msc.
 
Sucessfully Extended
Successful Extension as Shown with Diskmgmt.msc

Shut down your VM and set up a VM with the newly extended drive.  Add your DVD drive back if you need to.  Boot up the VM.  You should now have an expanded drive!  Yeah!

New, Big Disk Drive!
 
You should also be able to use VHDMOUNT from Virtual Server 2005 R2 SP1, but this method doesn’t require any additional s/w installation.
 
UPDATE 2010-12-27:
 
If you should find yourself with a dynamic disk and wish to non-destructively convert it to a basic disk prior to using the process, check out:
 

Posted in Computer Repair | Tagged: , | Leave a Comment »