How do I shrink a VHD file?


  1. ygl
    Posts : 1
    Windows 7
       #1

    How do I shrink a VHD file?


    How should i shrink the size of vdisk file? I installed Win7 into a vhd file and can boot from it. I tried to shrink it and by going thru computer->manage, i can shrink the partition inside the vhd file and got some empty space at the tail of vhd file. However the vhd file is the same size as before. How can i squeeze the vhd file to the size of its new (smaller) partition and get a small vhd file?
    thanks in advance
      My Computer


  2. Posts : 3,141
    Vista Ult 64 bit Seven Ult RTM x64
       #2

    Hello ygl,

    Welcome to the Seven Forums.

    Sorry, but I don't know of any way to make the file size smaller. Your only recourse may be to delete the vhd and recreate a smaller vhd and reinstalling 7.

    Maybe someone else has a better idea???

    Gary
      My Computer


  3. Posts : 1,009
    Windows 7 RC 7100 32bit/64bit
       #3
      My Computer


  4. Posts : 1
    Windows 7 Enterprise
       #4

    Windows 7 and Disk2VHD


    limneos... the VHD Resizer was what I needed as the final piece to a bigger puzzle. Slightly different situation than the post above. Maybe this will help others as a key to upgrading to Windows 7 while still holding onto your current Windows XP PC as a Virtual PC during the transition:

    On your XP desktop run Disk2VHD to create a virtual hard drive of your current PC. Disk2vhd.
    Microsoft notes one caveat that the VHD cannot be sourced from a disk larger than 127GB. We found that you can use it with a larger disk with a bit of tweaking and with one further caveat. You cannot have more than 100GB used of a larger disk. In my case, the disk was 232GB but was only using 55GB. So I ran the Disk2VHD process on my disk and shuttled it off my PC to an external drive.

    I then formatted my PC and installed Windows 7 64bit.
    I then followed the process here to install XP Mode for Windows 7. Please note prerequisites and versions of Windows 7 that support XP Mode.
    Download Windows XP Mode
    One thing that Disk2VHD doesn't tell you... if you want to launch this VHD as a Virtual PC, you have to manually replace the hal.dll and halacpi.dll from your source Windows XP installation. Please use the ones from the correct service pack.
    To do this, go to Disk Management and attach VHD.
    You can then modify the contents of the VHD by placing these files in the system root (c:\Windows\System32 by default). Before you Dettach, you should use Disk Manager to Shrink the partition as much as possible. Remember to Dettach and resave the VHD file before attempting to mount the Virtual PC.
    I then ran VHDResizer on this shrunken partition to create a smaller VHD from my bigger disk. I was then able to create a Virtual PC with this VHD of my old Windows XP image.

    One last Caveat: To get your device drivers fixed, you will need to run the Integration Services.

    If only Virtual PC had a tool as easy as P2V from VMWare to work through this...
      My Computer


  5. Posts : 4
    Windows 7
       #5

    I followed all the steps suggested by biggamejames. And succeeded in shrinking my 320GB HD to a size that Virtual PC 7 accepted. But when I try to boot a VM with it attached, it stops about 5 seconds into it. I did replace the hal.dll and the other file from the original drive service pack files in the VHD as suggested. Is there anything else I might need to do to make it boot?
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 13:18.
Find Us