Compacting a VM that thinks its running on an SSD.

Discussions about using Windows guests in VirtualBox.
Post Reply
Tronmch2
Posts: 33
Joined: 15. Aug 2018, 18:11

Compacting a VM that thinks its running on an SSD.

Post by Tronmch2 »

I'm trying to recover some disk space used by a vdi image, but I created it using a Windows host that was SSD only. So, the "normal" mechanism of "Defrag, sdelete -z, poweroff, run vboxmanage modifyhd --compact" doesn't appear to do anything because you can't defrag an ssd (because you'd destroy it). I moved the VM to a spinning-metal disk and the guest still thinks it's running on an SSD...

Windows 10 host & guest.
Current (7.0.10) VB.
Guest additions just updated.

Is there a different mechanism to optimize (meaning SHRINK) these disks. There is about 29GB actually used in the 48GB vdi file, and I'm trying to get that other 19GB back... (Because the other 10 VM's want more room.)
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Compacting a VM that thinks its running on an SSD.

Post by scottgus1 »

Tronmch2 wrote: 13. Sep 2023, 21:54 Is there a different mechanism to optimize (meaning SHRINK) these disks.
You can try Mpack's CloneVDI. It can compact without zero-filling or defragging. It also does not write to the source file, which is much safer.
Tronmch2 wrote: 13. Sep 2023, 21:54 I moved the VM to a spinning-metal disk and the guest still thinks it's running on an SSD...
There is a "solid state drive" checkbox on the VM's disk settings, when the disk is selected in Storage. When this box is checked, Virtualbox reports the VM's disk as an SSD to the VM OS. There is no correlation to the actual host disk the VM's disk file is stored on.
Tronmch2 wrote: 13. Sep 2023, 21:54 you can't defrag an ssd (because you'd destroy it)
Defragging, in and of itself, won't destroy an SSD. It will unnecessarily use up some of the erase & write cycles of the SSD, however. Defragging is helpful to bring together fragments of files on a spinning platter disk, because of the varying seek times to get the head to different places on the disk surface. However, every memory cell on the SSD has the same seek time, so defragging an SSD is not necessary. Defragging is essentially reads, erases, and writes, though, just like any other disk usage, and won't kill off an SSD in a single defrag cycle, as if defragging were a logic bomb or virus only to SSDs. If you ran a defrag on the SSD every night, though, it would use up the SSD's life faster.
Tronmch2 wrote: 13. Sep 2023, 21:54 and I'm trying to get that other 19GB back... (Because the other 10 VM's want more room.)
You're getting really low on disk space if 19GB will help. Time to get a different disk. That 19GB will get used quickly, and the shrunk disk will be one of the OS's doing so.
Tronmch2
Posts: 33
Joined: 15. Aug 2018, 18:11

Re: Compacting a VM that thinks its running on an SSD.

Post by Tronmch2 »

Interesting... When I posted this, my VM's would refuse to "defragement" because they were created hosted on an SSD. Now I don't have the checkbox checked (which I never did) and now -- on VB 7.0.14 -- can defrag so I can compact. Weird...

And that 19GB is pretty important when it's a work computer where:
  • The company skimps on hard disk space (512GB is the "standard")
  • You cannot request additional internal storage, and...
  • They use "security" software that actively -- and accidentally -- breaks writing to external storage,
Apparently Websense Forcepoint DLP -- with whatever policies that out IT security folks dreamed up -- does "interesting" things to vdi files stored on USB disks. (As in corrupts the **&%&^%& out of them.) So... I'm playing "defrag and compact" games all the time...
Post Reply