How do I shrink a VHD file?

ygl

New member
Local time
10:19 AM
Messages
1
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

OS
Windows 7
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

Computer Manufacturer/Model Number
Dell XPS420
OS
Vista Ult 64 bit Seven Ult RTM x64
CPU
Intel Core2 Quad Q6600 2.40 gigahertz
Memory
Crucial Ballistix 4x2GB PC2 6400
Graphics Card(s)
NVIDIA GeForce 8600 GTS 256 MB
Sound Card
Creative SB X-Fi audio
Monitor(s) Displays
HP w2207 + HPvs15
Screen Resolution
1680x1050 + 1024x768
Hard Drives
2-WD5000AAKS-500 GB
WD5000AAV-500 GB external
Keyboard
Microsoft Comfort Curve
Mouse
MX Revolution
Other Info
Wacom Intuos 2 Graphics Tablet
Experience Index=5.5

My Computer

Computer Manufacturer/Model Number
ENIAC
OS
Windows 7 RC 7100 32bit/64bit
CPU
Intel Core2Duo E4500 2.20 GHz
Motherboard
ASUS P5LD2-X/1333
Memory
2x1GB Kinsgston DDR2 800MHz
Graphics Card(s)
Nvidia 8500GT
Sound Card
Onboard High Definition Audio Device
Monitor(s) Displays
Sony Bravia 42"
Case
LINKW 2222
Cooling
Standard Intel
Keyboard
Some cheap one
Mouse
Microsoft Intellimouse something
Internet Speed
24MBps ADSL
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

OS
Windows 7 Enterprise
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?
HTML:
 

My Computer

OS
Windows 7
Back
Top