Reseting differencing VDI files

This is for discussing general topics about how to use VirtualBox.
Post Reply
Laurent57
Posts: 2
Joined: 31. Jan 2023, 17:58

Reseting differencing VDI files

Post 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
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Reseting differencing VDI files

Post 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.
Laurent57
Posts: 2
Joined: 31. Jan 2023, 17:58

Re: Reseting differencing VDI files

Post by Laurent57 »

The start / stop trick worked perfectly for what I wanted.

Thanks a lot for the help :)
Post Reply