Hyper-V Program Manager
Today if you want to compact a virtual hard disk – you can use Virtual PC / Virtual Server / Hyper-V or Windows 7. But not all methods are the same. Under the covers there are two different approaches that are taken to compacting virtual hard disks:
Virtual PC / Virtual Server:
Perform a blind “block level” compaction. Here the virtual hard disk is inspected at a block level, and when a block is found which is full of zeroes, the block is removed from the virtual hard disk.
More accurately, zeroed blocks are not copied. Because when you compact a virtual hard disk with Virtual PC / Virtual Server – they do so by creating a new blank virtual hard disk and copying the data across – and then deleting the original virtual hard disk at the end.
Hyper-V / Windows 7:
Hyper-V and Windows 7 use a different approach to compacting virtual hard disks. What they do is look for an NTFS file system on the virtual hard disk. If they find one, they read this data directly and use it to identify zeroed blocks that can be removed from the virtual hard disk.
This operation is done “in place” which means that no second virtual hard disk is created.
When you talk about Windows 7, I assume you mean Windows Virtual PC as opposed to the native support for VHD that the OS has baked in?
Yawn: When is Windows Virtual PC 7 arriving without the ludicrous processor virtualization requirement?
And how exactly do I compact a VHD? How do I tell WVPC to compact it? Or how do I tell 7 to compact it? Do I have to NTFS-compress the VHD file?
Will the .VHD file become fragmented after "in place" compacting?
Maybe I'm missing something. I am running Windows 7 with Windows Virtual PC. I go into the Settings of the Virtual Machine. Say I want to "Modify..." the hard disk, then click "Compact virtual hard disk". The next screen says:
"Before your compact the virtual hard disk, use the precompact tool to prepare the disk."
I assumed by your article that "No preparation needed", I wouldn't need to do this precompaction any more.
Am I missing something?
According to the article, "they read this data directly and use it to identify zeroed blocks that can be removed from the virtual hard disk.". Thus you need to purge these blocks using the precompact tool. This step is required by both approaches, and the only difference is the way your VHDs are compacted.
you're using WinVPC to compact, not Win7 alone, so per the article you need to precompact.
To compact with Win7 use diskpart.exe from the console or disk manager.
No, I mean using the native VHD support in Windows 7 / Windows Server 2008 R2 (like when you use diskpart.exe)
To compact a virtual hard disk with Windows Virtual PC - select to edit the disk from the virtual machine settings. To do it with Windows 7 - use diskpart.exe.
Compacting a VHD is unrelated to NTFS-compression.
Yes, but as VHD blocks are removed in 2MB chunks this will not have any visible performance impact.
Rick Arthur -
Per the list above, Virtual PC does require precompaction. To avoid this use diskpart.exe (or another tool that uses the native Windows 7 support).
>> Yawn: When is Windows Virtual PC 7 arriving without the ludicrous processor virtualization requirement?
I really don't get this, it keeps popping up surely you're not suggesting that people should use emulation instead of hardware virtualization?
That's sort of like saying: "Oh I hate Microsoft they won't let me install Windows 7 on my 486!" For performance, and general product perception reasons Microsoft were completely right to require hardware virtualization, like they were right to drop x86 support in Server 08 R2.
@The Man, I agree, and it's not like there aren't ANY other "free" VM products you could use if you're so distraught.
If I run Windows 7 inside the Windows Virtual PC. So can I use it to compact other vhd in the Windows XP host machine?
@The Man, none of the products *require* HW virtualization to run. They use it if it's available. VPC 2007 did. What "emulation" are you talking about? It's software virtualization. Not all current generation computers have processor virtualization and they are all missing out of Windows VPC. It's not like they can't take advantage of it if it's available. And XP Mode is a compatibility solution. It should maximize its own compatibility with computers.
Each time I try to compact my vhd in hyper-v on server 2008 r2, i get a failed message stating that "the server encountered an error tring to edit the virtual disk.....could not be completed due ti a file system limitation. It's an offline 49GB ntfs using only 25gb (running server 2008r2 inside vhd as well with 2 partitions, 1 reserved 100mb & 1 127gb.
Hyper-V Image-Management-Service event log show event id 15054:The system failed to compact......Error Code 2424869.