Trimming VDIs, sdelete still necessary?

Discussions about using Windows guests in VirtualBox.
Post Reply
mekkapekka
Posts: 1
Joined: 17. Feb 2014, 18:09

Trimming VDIs, sdelete still necessary?

Post by mekkapekka »

Hi there,

I'm running Vbox 4.2.16 on a Linux Mint Host running Win7 Pro as guest. I'm installing stuff frequently and would like to compact the VDIs since they really get quite large (although almost no space is used on the virtual hard disk). Reading some things all tutorials write that you need to perform sdelete in the guest. This overwrites all unused file system space with zeros and then you can compact the virutalbox image on the host.

Is this still true today? If the virtualbox guest extension HDD driver would support TRIM this would be unnecessary. Maybe it does and the tutorials are all old (all from about 2009-2011)?

So my question is: Is sdelete (which is pretty damn inefficient) still necessary today or does Virtualbox use TRIM for this?

Thanks,
Zach
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: Trimming VDIs, sdelete still necessary?

Post by mpack »

Sdelete is still needed if you use VBoxManage to compact the VMs, because VBoxManage still knows nothing about the guest filesystem. VirtualBox is a hardware simulator, and the difference between used and unused sectors is pretty much irrelevant at a hardware level, at least prior to SSDs.

There is however a third party VDI optimization tool that can compact without requiring a prior sdelete step: see CloneVDI tool. This is a Win32 app, but it runs well under Wine on Linux and Mac hosts.
ctrl
Posts: 4
Joined: 14. Jul 2012, 10:21

Re: Trimming VDIs, sdelete still necessary?

Post by ctrl »

I usually just boot the vm with a clonezilla live iso and clone the hdd to a new one, then I disconnect the old one, check if everything is ok and delete it. I'm not sure if this also sort of defragment the vdi, sure as hell it shrinks to the "real" size. Of course you have to take care the source-target selection :D (I create the new vdi a couple of megabytes larger, just to be sure... but it's always the second one listed).
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: Trimming VDIs, sdelete still necessary?

Post by mpack »

Even if that was correct it would be a pretty long winded way of performing a simple task, and also run into problems because the disk UUID changed. Unless things have changed, CloneZilla is a wrapper for dd, which is a dumb imager - it does not eliminate deleted sectors. Hence those sectors would end up on the cloned drive too.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Trimming VDIs, sdelete still necessary?

Post by socratis »

Actually, according to Clonezilla's site (after a list of almost every file system that I've heard of)
For these file systems, only used blocks in partition are saved and restored. For unsupported file system, sector-to-sector copy is done by dd in Clonezilla.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
ctrl
Posts: 4
Joined: 14. Jul 2012, 10:21

Re: Trimming VDIs, sdelete still necessary?

Post by ctrl »

Yes of course in this case I'm talking about supported filesystems, where clonezilla does not use dd. As of today I had no issues with UUIDs, since everything is handled by virtualbox in the proper way and I'm just adding a new hd and removing another one. Anyway it's just an idea, I tried years ago with the sdelete procedure and I ended up with a gigantic file and had to trash everything... it's probably working better now, or I just did it wrong.
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: Trimming VDIs, sdelete still necessary?

Post by mpack »

Ah! They must have changed it then - it used to be a dd wrapper only ISTR. I wonder if they took the mechanism from CloneVDI...
Post Reply