resize vhd


  1. Posts : 260
    Windows 7 Ultimate 64bit
       #1

    resize vhd


    Hi, I'm trying to reclaim space, after shrinking my (native) V-OS Windows 7 VHD (from 90GB to 30GB, still 3.5 free space)

    the (diskpart) shrink worked, leaving me with a nice healthy, active 24g partition... and 75g unallocated.

    The consensus seems to be vhdresize, but I (currently) have to complete the 'final step' of the resize vhd (file) operation outside the V-OS (it seems... VHDresizer won't ... I'm guessing vhdresizer 's GUIs gonna crashNburn from a pureDOSesque startup/recovery console {currently win7 boot disc is my method, looking for a lightweight boot entry to add to bootmenu, for 'vhd mgmt', ie vhd resizer..}

    read all on diskpart, still no clue on 'direct method' on handling unallocated space, ie to enable vhdresize to "finish it's task" (25g VHD "volume" is still actually a 99g VHD file on a 200 gig partition)

    Closest I've got is ref to compact command in PowerShell-context, re 'dual-command' to shrink then compact...
      My Computer


  2. Posts : 260
    Windows 7 Ultimate 64bit
    Thread Starter
       #2

    found this

    Steps to Shrinking VHD File
    There are a number of steps to shrinking the VHD. The script performs these steps, but for clarity I will list them here as well. You could perform these steps manually as well, if you choose to do so.
    Mount the VHD file (Windows Disk Management Console)
    Defrag the mounted drive
    Optimize / Consolidate the mounted drive – This part is key. Defraging will group file bytes together, which is very helpful. What’s important to note is that consolidation / optimization features will actually move files toward the center of the disk, or in our case to the beginning of the VHD file. Furthermore, some optimizers will zero out bytes on the disk that are not used. This is a necessary component for us to be able to shrink the file.
    Detach the VHD
    Re-mount the VHD in read only mode – not exactly sure of the reasoning behind this part, but through my testing I’ve found that it makes a difference
    Shrink the VHD using DISKPART or Hyper-V Management Console
    Detach VHD
    Voila, size of file is reduced

    PowerShell Script
    The following PowerShell script can be used to perform the steps mentioned above. The command is run like so:
    PS C:\Users\myers_000\Desktop> .\Shrink_VHD.ps1 -filePath "E:\Hyper-V\Base\Windows7_Ultimate_64\BizTalk 2010.vhd"
    ...
    I have almost zero PS experience: does it work from "windows install boot media's command prompt" (startup console?!)

    I've seen diskpart /s enables scriptology - is it a different language of script?

    THANKS!
      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 15:21.
Find Us