FREE: VHD Resizer - Shrink or Expand a Hyper-V VHD

VHDResizer As its name indicates, VHD Resizer is a tool that allows you to resize a VHD (Virtual Hard Disk). VHD is Microsoft's format for virtual disks, and is used by Virtual PC, Virtual Server, and Hyper-V. VHD Resizer can be used to enlarge or shrink virtual disks of all three virtualization solutions. Windows Vista and Windows 7’s system backup tools also use this format. However, it doesn't make much sense to enlarge a backup image. There are also third party virtualization tools, such as VirtualBox, that support the VHD format.

The most common problem with VHDs occurs when the disk of a virtual server is full. The nice thing about virtual disks is that they are quite easy to expand. I can’t help but wonder why Microsoft's virtualization solutions haven’t integrated this option. In theory, this should be possible even while the server is running. After all, it is no problem to defragment the disk of a running server, so why shouldn't it be possible to resize an online VHD?

In any case, VHD Resizer is free and easy to use. One thing to remember is that you have to shut down your virtual server first. All you have to do is to tell VHD Resizer the new size, and the name of the new virtual disk. VHD Resizer supports fixed disks (disks with an unchanging physical size) and dynamic disks (disks that grow dynamically). It seems as if the tool also supports conversion from dynamic to fixed disk types and vice-versa, but this didn't work in my tests. Enlarging a VHD, however, worked fine.

diskpart-extend VHD Resizer changes the size of the VHD, but not the size of the NTFS partition. Thus, if you access the VHD through a virtual machine, you just see a larger disk with additional unpartioned space. You have to use a partition management tool, like diskpart, to extend the partition. Only then can you make use of the full capacity of the virtual disk. Diskpart is a Windows command line tool.

Extending a partition with diskpart is very simple:

  1. Launch diskpart on a command prompt.
  2. Type "list volume." This gives you the number of the volume that you want to extend.
  3. Type "select volume volume-number."
  4. Type "extend."

Note that Microsoft's documentation for diskpart states that only the extension of data volumes is supported. System or boot volumes may be blocked from extension. Even so, during my test, I was able to extend a Windows 7 system volume without problems. Still, it might be safer to add the VHD to another virtual machine as a data volume and extend it there.

By the way, if you only want to enlarge a data volume, you don't need VHD Resizer. Just create another virtual disk with the appropriate size for your virtual machine, and then copy all files to the new disk.

VHD Resizer ^

Want to write for 4sysops? We are looking for new authors.

Read 4sysops without ads by becoming a member!

0
Share
12 Comments
  1. [...] … and in turn reaping the rewards of better graphics on Linux, UNIX, Macs, and even Windows FREE: VHD Resizer - Shrink or Expand a Hyper-V VHD - 4sysops.com 03/03/2009 As its name indicates, VHD Resizer is a tool that allows you to resize a [...]

    0

  2. vmware capacity 11 years ago

    Thanks for the great article. Unfortunately I tried following your advice and have run into a big problem. I downloaded VHD resizer and resized my VHD to 45g drive. When I started the server back up, it gave me this error: error4402: this disc cannot be read properly, please reinstall and try again.

    I'm not sure how to fix this. Or if it is even fixable. Have I lost all my data on this drive? I hope not.

    0

  3. Hmm, this doesn't sound good. Did you already delete the source file? What virtualization program are you using? You could try another tool that supports VHDs (Hyper-V, Virtual PC, Virtual Server, VirtualBox). You could also try to to access the data.

    0

  4. Paul 11 years ago

    You said

    Still, it might be safer to add the VHD to another virtual machine as a data volume and extend it there

    Have you tried this? and does it work? I would like to shrink the system volume to a smaller size. I never thought about adding it to another system and using shrink. Does this work?

    0

  5. Tom Bennett 11 years ago

    Hi,

    thanks a lot, I was just able to extend my System VHD with Vista installed.

    Thanks a lot

    Tom

    0

  6. tommy 11 years ago

    For those of you having vhd resize issues, I would take a look at the vhd resize feature from the product Portlock Leap Frog. This thing was a breeze. Not only resized the VHD but automatically resized the file system as well. Deffinately worth a look.

    0

  7. Paul Evans 10 years ago

    Michael,

    Thanks for your crisp post on the VHD Resizer. In my experience, extending a virtual disk can be a complex operations for several reasons, e.g.,:

    •The virtual disk that is full happens to contain the boot/primary partition for Windows
    •There are snapshots
    •There is insufficient disk space available on the physical drive to permit growth
    •It is a multi step process and involves use of different tools and commands in a specific sequence.

    I always advise people to create a backup copy of the virtual disk before you begin, so that you can restore it in case of failures. In case you are intesrested, I have compiled a survey of techniqeus to extend a VHD at

    http://blog.sharevm.com/2010/01/21/survey-extend-expand-microsoft-hyper-v-vhd/

    Regards,
    Paul

    0

  8. Lucero Martinez 10 years ago

    Hello, VHD Resizer can be used to compress a vhd file?
    I have used the compact option in hyper v and it doesn’t work well, my vhd is of 121 gb and inside of the virtual machine the used space is of 95.9 GB.

    I’m very worried because this machine is the production portal of my enterprise.

    Thank you so much in advance for your responeses,

    Regards,
    Lucero

    0

  9. Richard Bos 10 years ago

    Thanks man, helped me out 🙂

    0

  10. praveen 10 years ago

    VHD Resizer did not work for me.. but portlock leap frog works great... Thanks tommy

    Regards,
    Praveen

    0

  11. Ulrich 9 years ago

    Hi,

    adding the VHD to another virtual machine was what I was looking for.

    I added it to a Win7 64bit Hyper-V machine.
    There it was real easy to resize the VHD with the included Win7-Tools. 🙂

    Thanks a lot!

    Ulrich

    0

  12. Noah Vail 9 years ago

    The "Portlock Leap Frog" posts are payware SPAM.

    I've seen them in a lot VHD resizing blog posts. Sometimes they claim to be free - they are not.

    Note to Admin: Consider deleting Portlock Spams.

    NV

    1+

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2020

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account