Page 1 of 1

Reseting differencing VDI files

Posted: 31. Jan 2023, 18:08
by Laurent57
Hi everyone,

I'm looking for a simple way to reset my VDI differencing files to their original size (which is usually about 2MB).

I'm using several VMs to automate our build process. They are all configured to use "immutable" VDIs (we want to be sure to use the exact same OS each time we build something),

This is working great, except that the "differencing" VDI is not reset to its initial size when the VM is stopped. Not a big issue, but we have lots of build machines, and this is starting to take some significant space. Also the process to shrink the VDI using the VirtualBox UI is a bit teddious.

So I'm just looking for either a way to tell VirtualBox to "shrink" the differencing VDIs on close / shutdown, or a simple command line that could shring the differencing VDI for a given machine (I've already tried the usual "vboxmanage modifyhd --compact" command, but it has no effect on differencing VDIs - vboxmanage seems to consider that their content is still useful).

Laurent

Re: Reseting differencing VDI files

Posted: 31. Jan 2023, 19:17
by fth0
Laurent57 wrote:This is working great, except that the "differencing" VDI is not reset to its initial size when the VM is stopped.
As documented in Special Image Write Modes, the differencing image is reset when the VM is powered on the next time. Depending on your automation workflow, the following ideas might help:

a) After stopping the VM, start and stop it again. The differencing image is reset before the BIOS screen is shown, so this could be quick-and-dirty.

b) Use snapshots instead of the immutable property.

Re: Reseting differencing VDI files

Posted: 10. Feb 2023, 15:16
by Laurent57
The start / stop trick worked perfectly for what I wanted.

Thanks a lot for the help :)