Shrinking Windows VM

Discussions about using Windows guests in VirtualBox.
Post Reply
Sagypt
Posts: 51
Joined: 16. Apr 2012, 15:46

Shrinking Windows VM

Post by Sagypt »

Hi, these are steps I follow to shrink a Windows XP VM(*)

1) Defrag the hard disk (of VM) with Piriform Defraggler
2) Fill with 0 the free space of the hard disk (of VM) with the command SysInternals sdelete
3) Shrink the VM with the command VBoxManage modifyhd --compact "/PATH/VMNAME/VMNAME.vdi"

Is this a correct way? There's a better way?

Thanks



(*) the VM is a template for others VMs which I use for testing software
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Shrinking Windows VM

Post by mpack »

If you compacted with CloneVDI then you could skip the zero-fill and VBoxManage steps. This would make it much, much faster. CloneVDI will also reorder the image blocks into linear order.

Defragging the disk probably isn't worthwhile either. It probably gets you an additional few percent the first time you did it, and even less thereafter. Occasional defragging is a good thing, but I wouldn't do it for this purpose. Perhaps you should do a comparison next time, my suggestion vs your current method.
Sagypt
Posts: 51
Joined: 16. Apr 2012, 15:46

Re: Shrinking Windows VM

Post by Sagypt »

Thank you for your suggestion
mpack wrote: ... Perhaps you should do a comparison next time, my suggestion vs your current method ...
I'm not interested to benchmarking. I shrink the template VM occasionally.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Shrinking Windows VM

Post by mpack »

Benchmarking was not mentioned. The suggestion was about how you might go about testing whether your additional steps bring sufficient rewards in terms of compaction, in case you doubted my hypothesis that they don't.

Are you saying that you perform this task so rarely that you don't care about efficiency? If so then why ask the question?
Sagypt
Posts: 51
Joined: 16. Apr 2012, 15:46

Re: Shrinking Windows VM

Post by Sagypt »

mpack wrote: Benchmarking was not mentioned
It's true, I have not been precise
mpack wrote: Are you saying that you perform this task so rarely that you don't care about efficiency? If so then why ask the question?
Only curiosity!

Thank you again
Post Reply