Hyper-V and resizing VHD's

Discussion in 'Software for Windows' started by Jeff7181, Mar 8, 2013.

  1. Jeff7181

    Jeff7181 Lifer

    Joined:
    Aug 21, 2002
    Messages:
    18,323
    Likes Received:
    0
    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?
     
  2. Nothinman

    Nothinman Elite Member

    Joined:
    Sep 14, 2001
    Messages:
    30,672
    Likes Received:
    0
    Because MS always plays catch-up with features while killing their competition on price and inclusion with their OS.
     
  3. Chiefcrowe

    Chiefcrowe Diamond Member

    Joined:
    Sep 15, 2008
    Messages:
    4,324
    Likes Received:
    4
    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?
     
  4. smakme7757

    smakme7757 Golden Member

    Joined:
    Nov 20, 2010
    Messages:
    1,481
    Likes Received:
    0
    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.
     
  5. Jeff7181

    Jeff7181 Lifer

    Joined:
    Aug 21, 2002
    Messages:
    18,323
    Likes Received:
    0
    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.
     
    #5 Jeff7181, Mar 11, 2013
    Last edited: Mar 11, 2013
  6. Chiefcrowe

    Chiefcrowe Diamond Member

    Joined:
    Sep 15, 2008
    Messages:
    4,324
    Likes Received:
    4
    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??
     
  7. stlcardinals

    stlcardinals Senior member

    Joined:
    Sep 15, 2005
    Messages:
    729
    Likes Received:
    0
    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.
     
  8. Chiefcrowe

    Chiefcrowe Diamond Member

    Joined:
    Sep 15, 2008
    Messages:
    4,324
    Likes Received:
    4
    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?
     
  9. Dahak

    Dahak Diamond Member

    Joined:
    Mar 2, 2000
    Messages:
    3,531
    Likes Received:
    4
    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
     
  10. Jeff7181

    Jeff7181 Lifer

    Joined:
    Aug 21, 2002
    Messages:
    18,323
    Likes Received:
    0
    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.
     
  11. stlcardinals

    stlcardinals Senior member

    Joined:
    Sep 15, 2005
    Messages:
    729
    Likes Received:
    0
    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.
     
  12. Nothinman

    Nothinman Elite Member

    Joined:
    Sep 14, 2001
    Messages:
    30,672
    Likes Received:
    0
    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.
     
  13. Chiefcrowe

    Chiefcrowe Diamond Member

    Joined:
    Sep 15, 2008
    Messages:
    4,324
    Likes Received:
    4
    2008 R2, and the size isn't that big, around 130 GB.
    So is it possible in R2?



     
  14. Lifted

    Lifted Diamond Member

    Joined:
    Nov 30, 2004
    Messages:
    5,756
    Likes Received:
    1
    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.

    [​IMG]
     
  15. Chiefcrowe

    Chiefcrowe Diamond Member

    Joined:
    Sep 15, 2008
    Messages:
    4,324
    Likes Received:
    4
    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.
     
    #15 Chiefcrowe, May 16, 2013
    Last edited: May 16, 2013
  16. Jeff7181

    Jeff7181 Lifer

    Joined:
    Aug 21, 2002
    Messages:
    18,323
    Likes Received:
    0
    What worked? There were a few suggestions made...
     
  17. Nothinman

    Nothinman Elite Member

    Joined:
    Sep 14, 2001
    Messages:
    30,672
    Likes Received:
    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.
     
  18. Chiefcrowe

    Chiefcrowe Diamond Member

    Joined:
    Sep 15, 2008
    Messages:
    4,324
    Likes Received:
    4
    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!
     
  19. Nothinman

    Nothinman Elite Member

    Joined:
    Sep 14, 2001
    Messages:
    30,672
    Likes Received:
    0
    By "Start VM" do you mean log into it or boot it up because you have to shut it down to expand?
     
  20. Lifted

    Lifted Diamond Member

    Joined:
    Nov 30, 2004
    Messages:
    5,756
    Likes Received:
    1
    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.
     
  21. Nothinman

    Nothinman Elite Member

    Joined:
    Sep 14, 2001
    Messages:
    30,672
    Likes Received:
    0
    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.
     
  22. Lifted

    Lifted Diamond Member

    Joined:
    Nov 30, 2004
    Messages:
    5,756
    Likes Received:
    1
    You're right. I'm so used to hot extended in vSphere I forgot a reboot "should" reflect the new vhd size.

    Ah, missed that.
     
  23. Nothinman

    Nothinman Elite Member

    Joined:
    Sep 14, 2001
    Messages:
    30,672
    Likes Received:
    0
    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.
     
  24. imagoon

    imagoon Diamond Member

    Joined:
    Feb 19, 2003
    Messages:
    5,199
    Likes Received:
    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.
     
  25. Chiefcrowe

    Chiefcrowe Diamond Member

    Joined:
    Sep 15, 2008
    Messages:
    4,324
    Likes Received:
    4
    I meant boot it up. You have do have to shut down to do any changes to the VHD.