• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

Hyper-V and resizing VHD's

Jeff7181

Lifer
Aug 21, 2002
18,368
11
81
A coworker of mine recently pointed out that with Hyper-V and VHD's or VHDX's, expanding them is an offline operation. I have no reason to doubt him, I even looked it up myself and it does indeed appear to be the case, even in Server 2012.

My question is, first, how in the world can Microsoft claim to compete with VMware given this massive shortcoming?

Second, how does one work around that? Just create huge VHD's to begin with and hope you don't outgrow them, or if you do, hope that it's a server you can take offline to grow or wait until a scheduled outage to grow it? Seems like a very basic operation that has been in VMware for years... why isn't it possible in Hyper-V?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Because MS always plays catch-up with features while killing their competition on price and inclusion with their OS.
 

Chiefcrowe

Diamond Member
Sep 15, 2008
5,056
199
116
I've never had to do this yet, what are the steps you have to take?

also, if you only have one partition in the VM, then can you expand that one easily?
 

smakme7757

Golden Member
Nov 20, 2010
1,487
1
81
Expanding a VHD or an VHDX is a real PITA. I've had to do it twice and it was a frustrating ordeal. Your friend is right, it is an offline operation at least at the moment. The fastest way to add more storage would be to add another VHDX to the same Virtual host. Although that might be inconvenient depending on what you're working with.

I do like Hyper-V though. I've used it mainly in smaller scenarios opposed to vSphere, but i feel it's a pretty solid product for what it does. I guess being free isn't such a bad thing either.
 

Jeff7181

Lifer
Aug 21, 2002
18,368
11
81
I've never had to do this yet, what are the steps you have to take?

also, if you only have one partition in the VM, then can you expand that one easily?

The only way to add space to a volume online as far as I can tell is to add a brand new VHD and extend the volume onto it. Otherwise, you just power down the VM, resize the VHD and power it back on.

With VMware it's an online operation to grow a VMDK.
 
Last edited:

Chiefcrowe

Diamond Member
Sep 15, 2008
5,056
199
116
I was messing with this and I was not able to add space to a boot volume, which was kind of what I expected.

Is there any way to do this??
 

stlcardinals

Senior member
Sep 15, 2005
729
0
76
I was messing with this and I was not able to add space to a boot volume, which was kind of what I expected.

Is there any way to do this??

On Hyper-V manager, power off the VM. Go to the settings of the VM and select the virtual hard drive. Click the edit button and you will get 4 options: Compact, Convert, Expand, or Shrink. This is with a VHDX. Not sure if expand is available on VHD or not.
 

Chiefcrowe

Diamond Member
Sep 15, 2008
5,056
199
116
I did that and it worked for a VHD, but when I boot into the actual OS, it doesn't let me extend the C: to use the new added space.

What would be the best way to do this with a 3rd party program?
 

Dahak

Diamond Member
Mar 2, 2000
3,752
25
91
now i have not personally tried, but if it does not allow you to do it with disk management it should allow you to do so with diskpart. here shows the disk part commands
 

Jeff7181

Lifer
Aug 21, 2002
18,368
11
81
I did that and it worked for a VHD, but when I boot into the actual OS, it doesn't let me extend the C: to use the new added space.

What would be the best way to do this with a 3rd party program?

My first attempt would be to spin up another VM, mount the disk to that one and resize it, then disconnect it and boot up the original VM. I have zero hyper-v experience, so that might break something... but that would be my first thought.
 

stlcardinals

Senior member
Sep 15, 2005
729
0
76
I did that and it worked for a VHD, but when I boot into the actual OS, it doesn't let me extend the C: to use the new added space.

What would be the best way to do this with a 3rd party program?

You've extended on the Hyper-V side, now you need to do it on the client OS side. Probably need to use a 3rd party disk utility. Make a backup of your VHD just in case.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I did that and it worked for a VHD, but when I boot into the actual OS, it doesn't let me extend the C: to use the new added space.

What would be the best way to do this with a 3rd party program?

What OS? Windows hasn't allowed that until very recently, either 2008 or 2008 R2. And how big, if you have an MBR partition table you're stuck at 2TB regardless of OS.
 

Chiefcrowe

Diamond Member
Sep 15, 2008
5,056
199
116
2008 R2, and the size isn't that big, around 130 GB.
So is it possible in R2?



What OS? Windows hasn't allowed that until very recently, either 2008 or 2008 R2. And how big, if you have an MBR partition table you're stuck at 2TB regardless of OS.
 

Lifted

Diamond Member
Nov 30, 2004
5,748
2
0
In the Actions pane, go to More Actions and select Rescan Disks.

The new larger size of the disk will then appear and you can extend the volume.

rescan_zpsc3483e95.png
 

Chiefcrowe

Diamond Member
Sep 15, 2008
5,056
199
116
Thank you, that seemed to work. Do you have to convert the Disk to a dynamic disk first? I got a message about that so i wasn't sure.
 
Last edited:

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
What worked? There were a few suggestions made...

I'm guessing he means the rescan disks option in Disk Management which you need to do on the guest so that it will see the new LUN size. Might have to do it on the hypervisor side too if you're using a SAN, I haven't had to touch Hyper-V yet so I'm not sure.
 

Chiefcrowe

Diamond Member
Sep 15, 2008
5,056
199
116
I didn't have a chance to explain in more detail, but this is what I did -


1. If necessary, expand the volume on the SAN (in case the VM is getting very full)

2. In Hyper-V, go to the properties of the VM and go to VHD properties and then expand it to the desired amount.

3. Start VM and then go into disk management console, you should see the extra space there, if not rescan disks.

4. Right click on the existing partition and click on expand and select all the space.

5. Then in my case I was successful in increasing my C: partition.


Thanks everyone, this is great!
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I didn't have a chance to explain in more detail, but this is what I did -


1. If necessary, expand the volume on the SAN (in case the VM is getting very full)

2. In Hyper-V, go to the properties of the VM and go to VHD properties and then expand it to the desired amount.

3. Start VM and then go into disk management console, you should see the extra space there, if not rescan disks.

4. Right click on the existing partition and click on expand and select all the space.

5. Then in my case I was successful in increasing my C: partition.


Thanks everyone, this is great!

By "Start VM" do you mean log into it or boot it up because you have to shut it down to expand?
 

Lifted

Diamond Member
Nov 30, 2004
5,748
2
0
I'm guessing he means the rescan disks option in Disk Management which you need to do on the guest so that it will see the new LUN size. Might have to do it on the hypervisor side too if you're using a SAN, I haven't had to touch Hyper-V yet so I'm not sure.

I only occasionally need to dig around in hyper-v, but I'm pretty sure the LUN is not presented to the vm unless you're using iscsi or some sort of raw device mapping (do they have this in hyper-v?). I don't think he changed the LUN size, but increased the size of the vm disk in the hypervisor with the vm offline. When booting up the vm windows doesn't recognize the new size of the disk without a rescan, after which it will see the new size and you can increase the size of the volume.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I only occasionally need to dig around in hyper-v, but I'm pretty sure the LUN is not presented to the vm unless you're using iscsi or some sort of raw device mapping (do they have this in hyper-v?). I don't think he changed the LUN size, but increased the size of the vm disk in the hypervisor with the vm offline. When booting up the vm windows doesn't recognize the new size of the disk without a rescan, after which it will see the new size and you can increase the size of the volume.

I understand that, it all depends on how the VM is setup. Actually, I'm not sure if Hyper-V supports RDMs the way VMware does. Windows should see the new size of the vhd on bootup without a rescan, if not that seems like pretty big a bug in the drivers for the virtual storage adapter.

His step #1 was resize the SAN volume which implies the data store needed grew before the vhd could be too which is why I mentioned the rescan on the host before the guest. If you're just growing a vhd the host shouldn't need to rescan anything.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You're right. I'm so used to hot extended in vSphere I forgot a reboot "should" reflect the new vhd size.

Me too, so imagine my reaction when I was told the only way to grow a guest disk in XenServer is to shut down the guest, "forget" the disk/SR, grow it, re-add it and then boot up the guest. I was hoping MS wouldn't be stupid enough to release a hypervisor with similarly stupid restrictions.
 

imagoon

Diamond Member
Feb 19, 2003
5,199
0
0
Considering I use this feature on a weekly / daily basis, I can't imagine it either. Taking servers down to boost the end users home directories another 2 gig? </shudder>

In ESXi I have it down to minutes.
Edit VM -> Disk -> press up 2 x (for 2 GB or whatever) -> save
In VM
diskpart
rescan
select disk X
select part Y
extend
exit

All of our file servers are "thin provisioned" (Many are VMWare thin also) as in the disks are rarely more than ~5% disk free.