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 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 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
Thread Forum
ICON Resize!!
Never had this issue before. I have a folder of shortcuts of many apps which are of medium icons. Of late whenever I open the folder the icon size is small and arranged one above the other.This has happened many times , where I set the icon size in the folder , and when reopening it has changed....
Can't resize my partition
I'm trying to resize my C: partition so that I can create a separate 160 GB partition, but all of the options on MiniTool Partition Wizard are greyed out. And Disk manager is reporting 40 GB of possible space to shrink even though there's 259 GB free. I've reinstalled Wizard, defragged, and nothing...
General Discussion
Resize calculator
Is this possible? I see that the window edges cannot be dragged to enlarge them. It would sure help my aging eyesight to make the standard calculator about twice its size.
resize pictures
how do i resize pictures in win 7,seems you have to go into paint and save which i do but it keeps saying you have to save file in order to use as desktop background
Music, Pictures & Video
resize wallpaper in 7
Hi,I am fairly new with windows 7, can someone tell me how to stretch,or resize or make smaller backgrounds in win 7? I made a photo as wallpaper but its too large and cuts off all the heads! cannot seem to find how to alter it , I have win 7 ultimate..appreciate all your help . oops !!! should...
Resize Partition?
My core hard drive has 3 partitions.. 1 for hidden 7 at 100mb, 1 for core windows C: at 120gb, and another at 356gb for my profiles// docs etc.. I am starting to run a bit low on the C: partition. Programs, games, etc.. I need to pull some space from the D: to C:. I have tried Disk...
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 09:08.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App