Page 1 of 1

How to "get rid of" individual snapshots?

Posted: 29. Dec 2010, 16:24
by appyface
Good Morning,

I would like to remove snapshot data so it can neither be restored to nor merged with other data for a VM. To erase it as if it never happened and can't be recovered?

For an example:

1. (base vdi)
--snapshot 1
--snapshot 2
--snapshot 3
--snapshot 4
current state

2. I restore to the state of snapshot 2 for the VM's current state.

3. Now I want to remove all traces of snapshot 3 and snapshot 4 as if they never happened, as if the last thing ever done was to take snapshot 2.

Is there a way to do this? If so would someone please point me to the info? I have been searching here and in the Help file, but my search terms of 'delete', 'discard', and 'get rid of' have been inadequate and I've not found the answer.

Thank you for help. Kind regards,
--appyface

P.S. Am using version 4.0 but also had this question with earlier versions.

Re: How to "get rid of" individual snapshots?

Posted: 29. Dec 2010, 19:24
by abcuser
Before you do any change:
1. make a backup! (copy all the files to save location)
2. make sure your virtual machine is shutdown (it is not required, but I have experience some problems, that I can't reproduce, with VM running).

Instructions:
1. Click on Snapshot 2 and click on "Restore Snapshot" button. Question will be asked: "Are you sure you want to restore snapshot Snapshot 2? This will cause you to lose your current machine state, which cannot be recovered."

This question means you will lost the work under "current state" (all of the changes you have done after snapshot 4 was taken) - which you said you don't need - you want to revert to snapshot 2. So click on "Restore" button.

2. The above step will produce "Current State" that will be child of Snapshot 2 (on Snapshot tab in VirtualBox GUI).
Now you are ready to delete snapshots 3 and 4. Mark snapshot 4 and press "Delete Snapshot", confirm delete operation.

3. Mark snapshot 3 and press "Delete Snapshot", confirm delete operation.

Notes:
What you have to know is that deleting snapshot can take some time, several minutes (even 20 minutes or more), depending how many changes you have made between snapshots and how fast you hardware is. But don't kill the process of restoring snapshot or deleting snapshots!!! Just wait until operation is finished. If you do kill the process, you will get broken virtual machine disks. (Please believe it, I have tried it.) If you don't have time to wait, then do the restoring/deleting when you have a time wait to until operation is finished.

Also don't forget that snapshots also revert all the changes on virtual machine configuration. For example if you have changed RAM setting that is allocated to the virtual machine from 1 GB to 1.5 GB in snapshot 3 or snapshot 4, then this settings will be lost and you have to manually change this settings again. Why? Because snapshots saves "disk data" + "virtual machine configuration data" at the time snapshot is taken. For details read more in VirtualBox UserManual.

Above instructions are valid for VirtualBox v3.1 and up. I don't quite remember what was for version v3.0 and before, but I am 100% sure that it was not the same thing, snapshots have changed in v3.1 - so if you have VirtualBox version prior to v3.1 read the user manual. I haven't tested the v4.0 yet, but I have read the v4.0 user manual and it looks like snapshots haven't changed from v3.2.

Re: How to "get rid of" individual snapshots?

Posted: 29. Dec 2010, 23:55
by appyface
Hello abcuser,

I use many snapshots and regularly delete them. Each time I have done this, the snapshot identity is discarded (in the sense that there is no more record of the separate snapshot state), BUT the changes that the snapshot represents are retained by being "merged" (for lack of better term) back into another snapshot or base image.

In this example, I do not wish to retain the changes represented by these snapshots. When I delete them, how does VBox know it is different this time, and to discard their changes rather than retain them?

Thank you in advance for clarification of what you propose.

Kind regards,
--appyface

Re: How to "get rid of" individual snapshots?

Posted: 30. Dec 2010, 09:51
by abcuser
When you create virtaul machine the data are saved into main vdi file (let us call it main-vdi). When snapshot is done for the first time nothing really big happens, just new snapshot file (empty one) is created and any changes from now on are stored into new snapshot vdi file (let us call it snapshot1-vdi). When another snapshot is taken new snapshot vdi file is created (let us call it snapshot2-vdi) and all changes from this point on are stored into this new snapshot file. You also created snapshot3 and snapshot4 (let us call them snapshot3-vdi and snapshot4-vdi).

If you decide to delete snapshot1 then what will happen: snapshot1-vdi file will be deleted and all the delta from main-vdi and snapshot1-vdi are merged into main-vdi file.

But when you delete snapshot4 the file snapshot4-vdi file will be deleted and no merge will be done (because snapshot4 is the last in the snapshot tree - does not have any child snapshot). Then delete snapshot3 the file snapshot3-vdi file will be deleted and no merge will be done, because it is now the last snapshot in the snapshot tree.

So when you delete snapshot files from the bottom of the snapshots tree, snapshot files are deleted. But if you delete snapshot from inside of the snapshot tree (snapshot that has a child snapshot) then merge is done and actually some little disk space is also freed.

Hope this helps clearing up. If yo have some additional question don't hesitate to ask. Merging is also in detail described in VirtualBox UserManual if you need details.

Re: How to "get rid of" individual snapshots?

Posted: 30. Dec 2010, 10:21
by abcuser
One more notice, if you are asking yourself if "merging" is freeing some disk space or not, then we should look into simple sample. Lets say you created virtual machine with some operating system and you have created only one file, let us call it file.txt. Also let us take out of the picture all of the system files and log files that are constantly changing, just let us look into this single text file you have created and get out of the picture all other changes (for simplicity).

You open the file.txt and save the following text:
"This is my first line".
Now you decide do create a first snapshot. All of the changes made to file.txt file are stored into main-vdi file. New snapshot file (snapshot-vdi) is also created but it is empty at the moment.
Then you open the file.txt file and start adding new text to file.txt like:
"This is my second line".
All of the changes are now stored into snapshot1-vdi file and main-vdi stays at the time of first line was added. How is this stored on disk now? VirtualBox does NOT create two instances of text file like:
"This is my first line" for main-vdi file
and
"This is my first line"
"This is my second line"
for snapshot-vdi file, but it stores like:
"This is my first line" for main-vdi file
and
"#add new line#" (I am just trying to logical point it out that some kind of diff is done)
"This is my second line"

So snapshot1-vdi does not contain the sum of sizes of main-vdi plus whole new file with added text in snapshot1-vdi file, but in snapshot1-vdi it only includes differences that was made after snapshot1 was taken.

OK, now you decide to delete snapshot1. What happens it depends if snapshot is the last in the tree of snapshots (no child snapshot is available) or it has some "child" snapshot.

Scenario 1: (Snapshot is the last snapshot in the snapshot tree).
In this case all of the changes stored in snapshot1-vdi file are no longer needed, so snapshot1-vdi file has to be deleted (this will happen when you will delete snapshot4 and then snapshot3). No merge is needed.

Scenario 2: (Snapshot is NOT the last snapshot in the snapshot tree).
In this case you have some child snapshot (snapshot that is not in the bottom of the tree) and so the snapshot-vdi file must not be deleted, but instead can be merged into main-vdi file.
So the main-vdi file now changes (merges) from:
"This is my first line"
to:
"This is my first line"
"This is my second line"
and snapshot1-vdi file is deleted.

So deleting snapshot DOES release some disk space.

This is simplified sample, just to point out how it is done from the logical point of view. Don't forget that files can change in several ways - not just adding text, some text can be also removed and some updated, some files deleted etc. So all CHANGES are stored into snapshot.

Hope this helps clearing up how snapshot are working from logical point of view.

Re: How to "get rid of" individual snapshots?

Posted: 30. Dec 2010, 10:32
by abcuser
appyface wrote:In this example, I do not wish to retain the changes represented by these snapshots. When I delete them, how does VBox know it is different this time, and to discard their changes rather than retain them?
The short answer is, when you delete snapshot4 it is the last in the snapshot tree and so can delete it without merging. Then delete snaphost3 which will also be the last in the snapshot tree (snapshot4 will already be deleted).

So merging: when you delete the snapshot which is not the last in the snapshot tree.
Deleting without merging: when you delete snapshot which is the last snapshot in the snapshot tree.

Re: How to "get rid of" individual snapshots?

Posted: 30. Dec 2010, 14:44
by appyface
Thank you again for all your help and detailed explanations, abcuser, I just did some tests and I believe I have what I need.

Mark Cranness had given me these instructions some time back http://forums.virtualbox.org/viewtopic. ... 05&start=0 which are similar to but not exactly what you have described. These are the instructions I have been following. But as I nearly always wish to retain all the changes, I delete all snapshots from the last (newest) working backward, and I always end up with a single base vdi that has all the changes in it.

Recently I wanted to 'get rid of' the snapshots and their data, rather than remove the snapshots and retain their data, so I followed Mark's instructions (or so I thought) but I still ended up with the snapshot data retained. (Thank goodness for backups!) I made some tests just now, again using Mark's instructions (which in this scenario are same as yours) and all worked as you both have described.

It seems the 'restore snapshot' function is the deciding factor, perhaps I only thought I did that in my prior attempt, hence the incorrect result. In any event, after the restore snapshot function, I notice in the GUI the branch changes to showing the (restored to) snapshot leading right to current state, "jumping around" the later snapshots visually. Deleting these later snapshots when they are shown in this way, does not produce the 'merging differencing image' message and the delete is very fast for obvious reasons :-) Though it does not help that VBox shows first this warning pop-up whether merging, or not :-(
"Deleting the snapshot will cause the state of information saved in it to be lost, and the disk data spread over several image files that VirtualBox has created together with the snapshot will be merged into one file." This message put me off from continuing what ended up being a successful snapshot delete without merging the snapshot data.

One more mention. Above you wrote (paraphrased) "when a new snapshot vdi file is created all changes from this point on are stored into this new snapshot file". This has not been my observation. I believe the snapshot vdi = current state right at the moment in time when snapshot vdi is created, and the snapshot vdi is static, it does not change. All further changes continue to accumulate into the 'current state' of the VM and not into the snapshot vdi file. Or do I not understand this part correctly?

Kind regards,
--appyface

Re: How to "get rid of" individual snapshots?

Posted: 31. Dec 2010, 09:27
by abcuser
appyface wrote:This message put me off from continuing what ended up being a successful snapshot delete without merging the snapshot data.
appyface, I think you are way too much worrying how the data are stored into vdi files. Stop that! Forget anything you know about storing data to VDI. Stop worrying about merging vdi files, stop worrying about "differencing image" etc this are all internal VirtualBox processes you don't need to know about. More you investigate into how vdi files are working/merging etc more you are getting confused, because physical and logical behavior of snapshots can be different. If VirtualBox merges some vdi files this does NOT mean that snapshots data are merged in logical way. Snapshot data are NEVER merged in logical way! All this information about "merging" etc are very misleading from logical point of view and are just NOT important to you at all.

So, let us stop thinking about how physically VirtualBox operates. What ever it does on physical (disk vdi files level) it does to speed up process of storing and to minimize the disk size used. That means you don't need to know nothing about how vdi files are stored - this is just like at car, you don't need to know how car engine (vdi files in VirtualBox world) is working to drive a car.

Back to basics. Now lets compare virtual machines with computer which has only operating system installed. You are working on a computer, saving files, deleting files etc. If you mess something up, your whole system can become useless. To avoid lost of data you create backups. Let say we will do a whole full disk backups. Backup of disk1 to disk2. When you finish backup you unplug disk1 and plug disk2 into your system. In virtual world to create a backup you create a snapshot-1. Now you do something with your files (changing them), so this data are not backuped, but lets call them "current state", if you would like to preserve the changes you can decide to create another backup. You plug in disk3, copy data from disk2 to disk3 and remove disk2 from your machine. In virtual world you created another snapshot-2. Let say we create a backup of full disk every day and unplug the old disk. In virtual world we create a snapshot every day. Now you have figured out that you don't need disk3 and disk4 backups, but you would like to move back to disk2 backup and just trow away disk3 and disk4. You plug in disk2. In Virtual world you just create a RESTORE of snapshot to "disk2" in VirtualBox GUI you will see that "current state" is child of your snapshot2. "Current state" just shows you from which backup you are using data.

What I think you are getting confused are words like: "merging", "differencing image" etc. This are internal VirtualBox "engine" talking. You see, just like in cars when you start a car, you get all kind of "magic" lights, that are telling engine oil, braking liquid etc - what you say, my brakes are losing some liquid. No, stop worrying about all this messages, there are internal "engine" language, that are just notifying you about internal process, that has nothing to do with your driving. What you have to know is that data from two snapshots are NEVER merged!!! Just like two disks, disk1 and disk2 are never merged, you can only use one single disk, one single snapshot. What are merged are physical vdi files that are just speeding up creating a logical backup (snapshot) and you don't need to know how the physical process is working.

Hope I have removed some confusion.

Re: How to "get rid of" individual snapshots?

Posted: 31. Dec 2010, 10:51
by abcuser
I have created a ticket and asked VirtualBox developers if they can simplify Virtualbox snapshot GUI messages to become less geeky, confusing: http://www.virtualbox.org/ticket/7965

Re: How to "get rid of" individual snapshots?

Posted: 31. Dec 2010, 18:47
by appyface
Great documentation that will help a lot of people who may be searching here, so again thank you for putting a lot of details into writing :-)

For me I am already comfortable with what you have written. My hesitation was not 'worry' as you have assumed, it was simply my response to the VBox message, that it was about to merge my data, which I did not expect to get and did not want. And I did not want to go through a restore because I disregarded the message and tried it anyway. My VM's are 250+gigs and I use upwards of 50-100 snapshots in a week, so a restore is neither trivial nor fast.

In the absence of further information, I will generally believe what a program says will happen next. In this case the message was incorrect. What I should have done originally, and did do after posting this thread, was to create a small VM for testing. This proved to me the message was incorrect and I could safely proceed with restore being unlikely outcome.

Thanks for opening a ticket on the wording. I had already done that? http://www.virtualbox.org/ticket/7954

Kind regards,
--appyface

Re: How to "get rid of" individual snapshots?

Posted: 31. Dec 2010, 19:24
by abcuser
appyface wrote:...it was simply my response to the VBox message, that it was about to merge my data, which I did not expect to get and did not want... In this case the message was incorrect.
No, the point is: the message is correct!!!!! But it is confusing, because it talks about merging vdi files, which does NOT have anything to do with merging snapshot data in logical way. The data from two snapshots in logical are NEVER merged, what happens is just merge in low files level - like engine level that is not important to us. That is way I have written: forget about low level files merging it is just not important to understand snapshots. Low lever merging is only to speed up process of using multiple snapshots and freeing some disk space, because there is no need of having duplication of disk space for every snapshot.

If you create a text file with contents: "hello first file" and then create snapshot. Delete first file. Create new file and write: "hello second file" and create snapshot. This two snapshots are completely separated like having data in two separate computers. When deleting a snapshot there will NEVER happen a merge of this two systems and in this case you will never end up having both files. So merging of your data is not gonna happen. All what happens is merging is done on low level that is absolutely not important to you (except for knowing that each snapshot will not duplicate the size of disk space).

Re: How to "get rid of" individual snapshots?

Posted: 8. Mar 2011, 00:35
by Bowser
I think that instead of "Restore" and "Delete" options that there should be "Restore [to Snapshot]", "Merge into previous [Snapshot]" and "Discard [Snapshot]". (The parts in square brackets are optional as the subject is implied from what was clicked on.)
  • "Restore to Snapshot" means that changes made since the selected snapshot will be lost. Obviously, this would not apply to the current state.
  • "Merge into previous Snapshot" means that changes from the selected snapshot (or the current state) will be merged into the previous snapshot. If the parent snapshot of the selected snapshot has other child snapshots, choosing this option should give the user (a) an error indicating that the other snapshot(s) under the parent snapshot must be discarded or (b) a dialog allowing them to discard those other snapshots. This option would never apply to the root node of the snapshot tree.
  • "Discard Snapshot" means that changes from the selected snapshot (or current state) will be discarded. This option would never apply to the root node of the snapshot tree.
What happens with the vdi files is beside the point, from a user perspective.

That's my £.02, if you are interested.

Re: How to "get rid of" individual snapshots?

Posted: 8. Mar 2011, 13:42
by mpack
Bowser wrote:That's my £.02, if you are interested.
You may want to search the old threads before making a suggestion like that - that debate was had and settled quite some time ago. The current wording is the result. Your wording, particularly your use of the irrelevant word "merge", was specifically rejected. And you might like to consider your understanding of "discard" applied to a middle node. How are the children affected?

Re: How to "get rid of" individual snapshots?

Posted: 8. Mar 2011, 14:29
by appyface
@Bowser "What happens with the vdi files is beside the point, from a user perspective."

That's exactly my point, thank you.

I'm happy to leave the wording of the functions to the developers of Virtualbox. Whatever the wording, it should clearly and unambiguously communicate the end result of the selected snapshot operation -- from a user's functional/usability standpoint. As a user, I find the current wording difficult to translate into the end functional effect on my VM.

I'm sure there are ways to examine what is happening 'behind the scenes' if technical debug of underlying design is required, so it should not be necessary to communicate only this information to the user of Virtualbox.

If you can help me communicate my desire to word the functions from the end functional effect point of view, please add your voice to my enhancement request. I'm sure my wording and communication there could be improved upon to make this point clearer to the developers.

Kind regards,
--appyface