Search This Blog

Loading...

Monday, July 5, 2010

Shrink VHD size

Well, we all know that Hyper V Manager snap in provide us a tool to expand VHD size when require.

Now, How about shrink a VHD size? You may come to a situation when your existing VHD is Fixed Disk which you accidentally create to large size which not even 10% utilize. In order to shrink the size of the VHD, you need to

* Backup original VHD first *
a) Perform defragmention of the guest VM (optional)
b) First, shrink partition size
c) Then ,shrink VHD size by using VHDResizer.

You can use VHDResizer tool . To get this tool, go to http://vmtoolkit.com/files/folders/converters/entry87.aspx but on Windows Server 2003, there is no option to shrink volume. The VHDResizer cannot shrink the VHD if the partition is still intact with original size.

Without wasting any more time. let me show you how i shrink a Windows Server 2003 -Fixed Disk.

1. Attach Win2k3 VHD by using Parent host (Hyper V), go to Start > Administrative Tool > Computer Management > Storage > Disk Management > Right click Attach VHD

2. Right click the partition (Disk 4) and select Shrink Volume.











3. Enter the amount of space to shrink.
















4. Once you have shrink the partition, right click the VHD Disk and select Detach VHD.










5. Open VHDResizer, enter destination VHD and specify the new size.
Original size is 50GB
Resize to : 31 GB





















6. Wait until the process complete. Below is the snapshot of result.
















7. Use Hyper V manager snap in to use the new disk (TestExpand2.vhd).

Cool right !...
p/s:- No guarantee provided. Use it at your own risk.
If working on your side, just leave a comment so other can review it.

Thank you , Stay Tuned.

9 comments:

  1. permissions are different on the new .vhd file. VMM can't start it. IDE/ATAPI account does not have access to open.... I am going to look into it, any help would be appreciated.

    Found this in a forum and it worked

    "I just ran into this after running a year's worth of windows updates. What finally worked was to simply change the Hardware configuration Channel to Primary Channel (1) AND THEN Change it back to Primary Channel (0) (in use)."

    ReplyDelete
  2. Program works good and quick. Just what I was looking for.

    ReplyDelete
  3. I make this process and work very good

    ReplyDelete
  4. It works with help of CJA333's solution. Thanks a lot!

    ReplyDelete
  5. It's just manage to help me shrink my vhd file from 2TB to 50GB. thanks.
    However, when i use the vhdresizer to select the vhd file, it throw error "Invalid VHD file. Please select another".
    What is the problem of this? And how to get this solve?

    ReplyDelete
    Replies
    1. Haha, you fucked up! Take a copy of the vhd (just to make sure it won't go wrong). Follow the steps on the following site. It should work.

      http://jagbarcelo.blogspot.com/2011/11/how-to-shrink-vhd-virtual-hard-disk.html

      Delete
    2. You need to un-attach the vhd from Disk Management before you can select it from VHDResizer. That's all.

      Delete
  6. Worked a treat for me, resized a Windows XP Pro VHD running in Hyper-V on Windows Server 2008R2.
    I did need to do the additional step noted by CJA333

    ReplyDelete
  7. This worked like a chnarm for me! Great way to resize Server 2003 VHDs.

    ReplyDelete