Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, September 27, 2011 7:08 AM
I'm planning to compact a 262GB .vhd file and I'd like to know how long will take. Also, If I stop the process before it's finished, next time I try to compact the same .vhd file, will it take less time?
Thanks for any answer
All replies (4)
Tuesday, September 27, 2011 2:41 PM âś…Answered
compacting simply recovers the free space in the VHD (on the disk of the VM) - it should be relatively quick.
How long this takes depends on how fragmented your VM is (the os in the vm). Generally the conpact work for dynamic disks that have grown do to operations int he VM such as backups and whatnot that cause the dynamic disk to grow and then items are deleted, resulting in empty space within the dynamic disk.
Merging on the other hand can take a long time and there is no way to predict how long it might take. There are many variables that contribute to the time to merge a snapshot or differencing disk.
Brian Ehlert (hopefully you have found this useful) http://ITProctology.blogspot.com
Learn. Apply. Repeat.
Wednesday, September 28, 2011 1:02 AM
Well,
Not so relatively quickly. When you're compacting, you're talking about a dynamic VHD. The first order of business is to shrink the partition inside the VHD. That actually happens fairly quickly though imperfectly through a VDS call. Once that's done, you have to update the file map in the dynamic VHD, then free all the bitmap and data segments beyond the end of the new size of the partition. Short answer: it can take a while. How log; it's an ugly "it depends".
I actually did quite a bit of work with VHDs and formats and so on when I developed a set of powershell cmdlets to manipulate them. My focus was on fixed VHDs. The reasoning for that is that I work for a SAN vendor and presumably they would sit on SAN storage. I used SCSI3 T10 UNMAP to play games with what is and isn't allocated in the eyes of the NTFS file system and the eyes of the storage array. Even though NTFS considers the file completely allocated and zeroed (the data area anyway), as far as the storage is concerned zero blocks are unmapped and don't consume space. A read of an unmapped block returns a zero block; a write to an unmapped block allocates a block under the covers. That worked out pretty well in new-NaVirtualDisk. I can create a 1TB fixed VHD in 17 seconds.
Resizing a fixed VHD is a simple extention of that with a few VDS calls. If you want to grow, you punch out some space, append it to the file, calculate & write a new footer, then grow the partition inside the VHD. If you want to shrink, you shrink the partition, calculate the new size, truncate the file, addthe new footer, then unmap all the unneeded blocks. It's pretty simple when dealing with fixed VHDs. I can both grow and shrink in Set-NaVirtualDiskSize. The cmdlets I'm talking about are in the Data ONTAP PowerShell ToolKit that will release next month http://communities.netapp.com/community/netapp-blogs/msenviro/blog/2011/09/22/getting-ready-for-windows-server-8-part-i . Dynamic VHDs are a bit more challenging, but I can say with some certainty that you'll see some cmdlets around conversions in the next cycle; they're difficult, but not impossible. :-)
J
Wednesday, September 28, 2011 3:01 PM
John gives an incredibly detailed answer.
But in the end the real answer is still - it depends. There is no quick answer.
I guess that another question to ask is: What exactly do you mean by "compact"?
Do you want to shrink a dynamic disk, thus recovering storage space? Do you want to shrink a VHD - making the VHD itself smaller (a common ask after doing a P2V)?
But, if you have an answer, please let us know.
Brian Ehlert (hopefully you have found this useful) http://ITProctology.blogspot.com
Learn. Apply. Repeat.
Friday, July 13, 2012 5:57 AM
If you think your compact is taking to long in Hyper-V check the Hyper V event logs to make sure you compact has not crached in the backround. This happend to me. The editing disk wizard progress stayed on 100% percent for hours, little did i know it had crashed in the backround even though the task looked to be runing fine in the task manager. I was able to end task and my VHD was unharmed. Remember always back up your VHD's before trying and kind of maintenance!