Defrag needed when compact VDI?

This is for discussing general topics about how to use VirtualBox.
Post Reply
J.L.
Posts: 78
Joined: 17. Jan 2013, 07:38
Primary OS: MS Windows 8
VBox Version: PUEL
Guest OSses: LMDE, Ubuntu, Windows XP, Windows 7
Contact:

Defrag needed when compact VDI?

Post by J.L. »

For Windows guests, many recommend you to clean unneeded files, defrag, then zero out free space before compacting.

But most other OS don't recommend defragging at all, so I skip that step. Compact still seems to work fine, even on something like Linux which spreads out files across the drive.

Basically, does VirtualBox dynamic allocation care about how files are organized on a drive?
Windows 10 is the actual host, not 8 (no option).
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Defrag needed when compact VDI?

Post by mpack »

No, VirtualBox dynamic allocation doesn't care about the filesystem, but then it doesn't know much about compaction either.

VDI files are organised into 1MB blocks. A block can be discarded during compaction or cloning if it contains nothing but zeros. There is a greater chance that entire blocks are filled with zeros if you defrag first. However, in many cases this will only make a few percent difference and probably isn't worth the effort.

Incidentally, the best way to compact is just to run CloneVDI with the compact option: in which case you can skip the zero fill step.
J.L.
Posts: 78
Joined: 17. Jan 2013, 07:38
Primary OS: MS Windows 8
VBox Version: PUEL
Guest OSses: LMDE, Ubuntu, Windows XP, Windows 7
Contact:

Re: Defrag needed when compact VDI?

Post by J.L. »

Thank you for the explanation. Guess I'll defrag only Windows for better performance on HDD if nothing else.

Nice tool, I've used it before. But doesn't it need to create a clone, which uses up more space at first? Is there another advantage to it other than skipping zero fill?
Windows 10 is the actual host, not 8 (no option).
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Defrag needed when compact VDI?

Post by mpack »

Swings and roundabouts. If you zero fill a dynamic drive then it will expand to its maximum size. So either way, working disk space is required. In fact if the disk is less than half full then the zerofill method requires more space than CloneVDI. And, with CloneVDI you can use a second drive for intermediate copies if that is a concern.
Post Reply