0

I've recently started using virtualisation software more often, specifically VirtualBox, and the idea of snapshots confuses me.

I understand that they give the user the ability to revert a VM to a previously-captured state, but as far as I can tell, this can also be done by simply saving the machine state when closing a virtual machine. Are snapshots then only intended to be useful in server environments where a restart is non-trivial, or do they actually add something for the desktop user?

enter image description here

6
  • Restarting a VM doesn't restore it to a previous state, just as restarting a physical machine doesn't. Snapshots restore the VM to a previous state, similar to making a full backup of your computer and then restoring it later.
    – essjae
    Commented Oct 15, 2018 at 23:31
  • @essjae I see. Why the option to Save State while shutting down in VirtualBox then? There being an option to save state while shutting down tends to imply that all the other options don't save the state, this is what made me think all the other options don't save anything. Commented Oct 15, 2018 at 23:36
  • 2
    Saved states are not snapshots, period. Do not confuse them. Saved state is similar to hibernation. When you stop the VM you can return to the place you left off. A snapshot would allow you to make changes to the VM and then undo those changes at a later time. Example: create a snapshot, format your hard drive, breaking your VM. Restoring that snapshot brings back the computer. A saved state cannot do that.
    – essjae
    Commented Oct 15, 2018 at 23:59
  • You both seem to be saying opposite things. Commented Oct 16, 2018 at 0:00
  • @essjae You appear to be right: virtualbox.org/manual/ch01.html#idm485. If you'd like to add your own answer, I'd be happy to accept it. Commented Oct 16, 2018 at 0:06

3 Answers 3

1

Saving machine state = Hiberation option available in OS like Windows where full OS state (RAM contents) are copied to a file and stored somewhere. In next restart it reads this file and goes to that state again.

Snapshot = Similar to a Time machine where you can save your machine state at multiple point of time. If you are trying out some stuff and mess up , you can always go back to any of the saved snapshots or machine states.

1
  • Selected this as best answer purely because it's the only one which explains what a "save state" is and how it's different to a snapshot. Commented Oct 20, 2018 at 23:00
3

As you know the snapshots give the ability to revert the VM to a previous snapshot.

Restarting a VM, does not revert it to an old snapshot. (it does not uninstall software that you installed, it does not delete files that you created etc.)

The screenshot that you posted in is related to "Saving state", which is different from Snapshot. You can create multiple snapshots, but are able save only the current state of the machine.

The use-cases of snapshots are numerous.

Here's one example: Test a two scripts that have to be executed one after another for setting up an environment (installing several software packages, set up configuration files, etc.)

  • Before the first script is ran, you snapshot the VM
  • Run the first script
  • Take another snapshot
  • Run the second script
  • Inspect if everything is OK and if it's not, then you can make modifications to the script, revert the VM to the previous snapshot and run the script again.
  • After you verify that both scripts work as expected, then you can execute them on a real machine.

Having multiple snapshots will allow you to test just the first script or just the second script.

4
  • As I just noted in my comments on the question, VirtualBox has a specific option for shutting down and saving state, which implies that all normal tasks don't save state. I also just tested, and clicking one of the normal shutdown options brings up a dialogue, one of whose options is saving the machine, implying that the other options don't save state. If this is how it works, it seems pretty trivial to revert a VM to its old state by restarting it. Commented Oct 15, 2018 at 23:48
  • "Save state" is different from snapshot. Edited my answer, so it's precise in the terminology. Commented Oct 16, 2018 at 0:21
  • 1
    Your answer could be improved by noting that after your step 3, you could take another snapshot, perform more test actions, take yet another snapshot, etc., then revert back to any one of those snapshots. This would help the OP appreciate the fact saving the machine's state is limited to saving a single state while snapshots can be used to capture a series of states. Commented Oct 16, 2018 at 2:41
  • Thanks, Twisty Impersonator, good idea! Hashim, check the answer, please, and tell me if it's more clear now. Commented Oct 16, 2018 at 4:13
0

Although the two current answers are both informative, neither fully addresses what exactly a save state is and how it differs from a snapshot in practical terms, so I've decided to fill in this information from VirtualBox's documentation here:

Save the machine state: With this option, VirtualBox "freezes" the virtual machine by completely saving its state to your local disk.

When you start the VM again later, you will find that the VM continues exactly where it was left off. All your programs will still be open, and your computer resumes operation. Saving the state of a virtual machine is thus in some ways similar to suspending a laptop computer (e.g. by closing its lid).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .