VirtualBox Snapshot - How to stop them to grow and take more and more space?

5,822

Solution 1

Virtual disks

When you create a VM, you create a virtual disk as well. This disk can be of fixed size or dynamically expanding. In the first case, the file will not grow, in the latter case, the file has a small size at startup and will grow as needed by the VM to the maximum size of the virtual disk. The dinamically expanding disk can be compacted using Lukas's answer steps.

Snapshots

When you take a snapshot, VBox create a new file in which all changes will be writed instead of the original virtual disk file. This new file will grow as needed to the maximum size of the virtual disk. If you take another snapshot at some point, this file will stop growing, VBox will create another file which will grow at its turn.

Deleting snapshots

If you don't need snapshots, then you can delete them, the data will be commited in the original virtual disk file (or original snapshot file in case of consecutive snapshots.) Just stop the VM, select the snapshot you want to delete, use the button with the red cross in the snapshots tab. It can take a long time, depending of the amount of data in the snapshot.

Restoring snapshots

The icon with the up arrow is to restore a snapshot (and forget all data changed since the shapshot date).

Solution 2

You can use my script to backup and restore the snapshot and then compact its HDD with:

  1. Defragment the disk on guest
  2. Run sdelete -c Con guest (download sdelete from http:// technet.microsoft.com/en-us/sysinternals/bb897443.aspx) which zeroes free space. I don't know Linux equivalent (maybe dd?).
  3. Run VBoxManage modifyhd winxp.vdi --compact on host
Share:
5,822

Related videos on Youtube

Natim
Author by

Natim

Work for Ionyse.com My CV here : http://remy.hubscher.crealio.fr/

Updated on September 17, 2022

Comments

  • Natim
    Natim over 1 year

    I am using VirtualBox on Ubuntu with some programs installed in it. And the snapshot file does not stop to grow.

    I don't need this feature. I just want my data to be saved on the virtual windows hard drive.

    How can I remove the snapshot of 20GB without losing my documents and settings and without starting another one keeping growing ?

    Thank you.