Note
Whereas taking and restoring snapshots are fairly quick operations, deleting a snapshot can take a considerable amount of time since large amounts of data may need to be copied between several disk image files. Temporary disk files may also need large amounts of disk space while the operation is in progress.
Think of a snapshot as a point in time that you have preserved.
More formally, a snapshot consists of three things:
- It contains a complete copy of the VM settings, including
the hardware configuration, so that when you restore a snapshot,
the VM settings are restored as well. (For example, if you changed
the hard disk configuration or the VM's system settings, that
change is undone when you restore the snapshot.)
The copy of the settings is stored in the machine configuration, an XML text file, and thus occupies very little space. - The complete state of all the virtual disks attached to the
machine is preserved. Going back to a snapshot means that all
changes that had been made to the machine's disks -- file by file,
bit by bit -- will be undone as well. Files that were since
created will disappear, files that were deleted will be restored,
changes to files will be reverted.
(Strictly speaking, this is only true for virtual hard disks in "normal" mode. As mentioned above, you can configure disks to behave differently with snapshots; see the section called “Special image write modes”. Even more formally and technically correct, it is not the virtual disk itself that is restored when a snapshot is restored. Instead, when a snapshot is taken, VirtualBox creates differencing images which contain only the changes since the snapshot were taken, and when the snapshot is restored, VirtualBox throws away that differencing image, thus going back to the previous state. This is both faster and uses less disk space. For the details, which can be complex, please see the section called “Differencing images”.)
Creating the differencing image as such does not occupy much space on the host disk initially, since the differencing image will initially be empty (and grow dynamically later with each write operation to the disk). The longer you use the machine after having created the snapshot, however, the more the differencing image will grow in size. - Finally, if you took a snapshot while the machine was
running, the memory state of the machine is also saved in the
snapshot (the same way the memory can be saved when you close the
VM window). When you restore such a snapshot, execution resumes at
exactly the point when the snapshot was taken.
The memory state file can be as large as the memory size of the virtual machine and will therefore occupy quite some disk space as well.