Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: resize vhd

08 Feb 2014   #1

Windows 7 Ultimate 64bit
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 Windows 7 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 System SpecsSystem Spec

08 Feb 2014   #2

Windows 7 Ultimate 64bit

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?

My System SpecsSystem Spec

 resize vhd

Thread Tools

Similar help and support threads for2: resize vhd
Thread Forum
Can't resize my partition General Discussion
Resize calculator Software
Resize Partitions General Discussion
resize wallpaper in 7 Customization
Resize Partition? General Discussion

Our Sites

Site Links

About Us

Find 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 07:24 AM.
Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33