Snapshots branching

This is for discussing general topics about how to use VirtualBox.

Snapshots branching

Postby trucbidule » 5. Feb 2010, 21:07

Hello,

First of all : Virtualbox is a great piece of software! Free and really efficient! Thank you guys and keep doing such a good job ! :D
Maybe could the documentation be a little more detailed... and that's why I post today, on snapshots! ;)
I've been looking for a loong time in the posts, but couldn't find an explanation for what can be seen on this picture, found in the official documentation :

Image
http://www.virtualbox.org/manual/images/snapshots-1.png

Question
How were the different snaps "branched"? How was it possible to make some branches with guest additions and some others without guest, all this based (as far as I can see) on a single .vdi?

This feature seems really interesting to me, so if someone knows how to do that, I'll be pleased to read the answer here! ;)
Thanks for your answers!
trucbidule
 
Posts: 13
Joined: 5. Feb 2010, 20:50
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: linux - windows

Re: Snapshots branching

Postby MarkCranness » 5. Feb 2010, 23:57

You create a new branch by selecting one of the existing snapshots, and using 'Restore Snapshot'. That makes the 'Current State' of the VM the same as that snapshot and ALSO creates a new branch rooted at that snapshot.
You then modify the VM and/or take further snapshots to extend that branch.

The Guest Additions is simply another program that can be installed in the guest, or not installed, so to make a branch that does not have GA installed (or any other program or setting), select a snapshot in which it was not installed and 'Restore Snapshot' to create a anew branch.

Remember this:
  • Restore Snapshot throws away your current machine state (setup and hard disk contents) and restores the current machine state to that selected snapshot. If you want to keep the current machine state, take a new snapshot BEFORE using Restore Snapshot.
  • Delete Snapshot never affects the Current State; it is always kept as it is.
  • The first, top-most snapshot (usually the first) protects the base virtual hard disk files from change. Delete Snapshot of the first, top-most snapshot will merge changes into the base virtual hard disk.
For example, to create the Snapshot 2-1 branch shown in the manual, likely this is what would have been done:
  • Take snapshots as normal until Snapshot 4
  • Shutdown the VM, select Snapshot 2 and 'Restore Snapshot'
  • Enable nested paging, restart VM
  • Take Snapshot 'Snapshot 2-1 (nested paging enabled)', and continue...
MarkCranness
Volunteer
 
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: Snapshots branching

Postby StuartV » 6. Feb 2010, 00:53

That all makes sense. So, is there a way to then set things up where I have one VM that runs using one snapshot in the tree, and a different VM using a different snapshot in the tree - with both VMs running at the same time?

For example, say Snap 1 is a base OS install. Then I install SQL Server and snapshot that (Snap 2). Then I restore back to Snap 1 and install Visual Studio development tools and snapshot that (Snap 3).

Now I want to run a VM that is using Snap 2 to have a SQL server available, and run a different VM at the same time that is using Snap 3, so I can do programming.

I have the impression from the previous description that what I would have to do is clone Snap 1 BEFORE I install Visual Studio, then create a VM for the clone, if I want to have a Dev VM and a SQL VM that both are based off the same original base OS install. Correct? Or is there a way to conserve my disk space so I can run 2 VMs off different snapshots of the same base, at the same time?

Thanks!
StuartV
 
Posts: 3
Joined: 6. Feb 2010, 00:29
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows 7

Re: Snapshots branching

Postby trucbidule » 6. Feb 2010, 01:19

OK great thanks MarkCranness!

I took the example from the manual as it was easy to "show" what i was talking about.
My question was about the procedure to create a new branch, you answer is clear! :)

What I am still not sure about is : what happens to branches if I decide to delete one or some of them? There are many posts about this subject, but the behaviour - if I understood correctly - has changed with the 3.x+ versions?

Let's say I delete the "2-5 (windows restarting)" snap of the picture, are some infos merged with nomething else?
What if I delete the 2-1 "root" branch?

I'm also interested in StuartV questions. But I have to read some more docs on how to create a new machine based on a snap I guess. ;)

Thanks for your support!
trucbidule
 
Posts: 13
Joined: 5. Feb 2010, 20:50
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: linux - windows

Re: Snapshots branching

Postby MarkCranness » 6. Feb 2010, 08:27

StuartV wrote:Now I want to run a VM that is using Snap 2 to have a SQL server available, and run a different VM at the same time that is using Snap 3, so I can do programming.

You can do this. I would instead leave out the last two snapshots, and do this:
  • Base OS install, to the point where you want to share it between VMs, power-down the VM.
  • Take Snapshot 'base OS install'.
  • Create another VM, and attach the base virtual hard disk to it.
    (As you attach, you should see a blue multi-pointed star to the left, and a message "will attach using a differencing disk" or similar. MAKE SURE you see the blue star and the message, to avoid any problems.)
  • At this point, both VMs should be bootable, and both can run at the same time.
  • Install SQL Server in VM1, and install Visual Studio in VM2.
(Be aware that using snapshots can complicate backup and recovery in the case that things go wrong.)

You can also do it exactly as you want (but I wouldn't bother):
  • Base OS install, to the point where you want to share it between VMs, power-down the VM.
  • Take Snapshot 'base OS install'.
  • boot, install SQL Server [shutdown] Take Snapshot 'SQL Server'
  • Restore Snapshot 'base OS install', boot, install Visual Studio, shutdown, Take Snapshot 'VS'.
  • Find the {hexUUID}.vdi attached to the 'VS' snapshot: File>Virtual Media Manager...>expand the tree under the base virtual had disk and find the {hexUUID}.vdi file that has 'Attached to:' = 'YourVM1Name (VS)', i.e. it has the snapshot name in brackets after it. Note this hex number.
  • Create another VM, and attach the {hexUUID}.vdi to it, like so:
    • As you create the VM, uncheck the 'Boot Hard Disk (Primary Master)' checkbox so that no hard disk is created or attached, and click 'Continue' when asked.
    • Settings>Storage>Add Attachment (+ icon)>Add Hard Disk>select the disk added>choose 'Slot:' = IDE Primary Master>click 'Differencing Disks' checkbox>select the UUID number from above from the 'Hard Disk' dropdown listbox.
      (As you attach, you should see a blue multi-pointed star to the left, and a message "will attach using a differencing disk" or similar. MAKE SURE you see the blue star and the message, to avoid any problems.)
  • At this point, both VMs should be bootable, and both can run at the same time.
MarkCranness
Volunteer
 
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: Snapshots branching

Postby MarkCranness » 6. Feb 2010, 08:48

trucbidule wrote:What I am still not sure about is : what happens to branches if I decide to delete one or some of them? There are many posts about this subject, but the behaviour - if I understood correctly - has changed with the 3.x+ versions?

Delete Snapshot is the same as the old Discard Snapshot.

The old 'Delete Current Snapshot and State' was different and brain dead and is now gone (yay!)

If a snapshot has 2 or more branches under it (the Current State counts as a branch), then you can't delete that snapshot until you also delete some of the branches.

Things to remember:
  • Delete Snapshot never affects the 'Current State': that is always kept the same (same VM setup, same virtual hard disk contents).
  • If you delete the first, topmost snapshot, changes made to the base virtual hard disks after that snapshot was taken (but before the immediate child snaphot was taken) are merged back into the base virtual hard disk.
    (This is not quite correct, see below.)
  • When you delete other snapshots, merging happens as well, but between various differencing hard disks, and WHO CARES, just let VirtualBox get on with it... (If you care for the exactly correct gory detail, see below.)

trucbidule wrote:Let's say I delete the "2-5 (windows restarting)" snap of the picture, are some infos merged with nomething else?

In the example, VirtualBox won't let you delete 'Snapshot 2-5 (windows restarted)', because it has two immediate children in the tree: 'Snapshot 2-8' and 'Current State'.
If you were to restore the Current State elsewhere, then the differencing hard disk(s) attached to 'Snapshot 2-5 (windows restarted)' are merged with the differencing hard disk(s) attached to 'Snapshot 2-8', but WHO CARES? :P

trucbidule wrote:What if I delete the 2-1 "root" branch?

Some merging happens (see above: WHO CARES) and 'Snapshot 2-2 (MSN open again)' is moved up by one to take the place of the 2-1 parent.

* When you delete a snapshot, what is merged into what depends upon what virtual disk files are attached to the snapshot and its immediate child snapshot.

virtual hard disk files attached to a snapshot can be one of 4 types: Normal, Differencing, Immutable, Write-through.
Normal hard disks are usually in the .VirtualBox/HardDisks/ folder.
Differencing hard disks are usually in the .VirtualBox/(machinename)/SnapShots/ folder.
You can see what file is attached to a snapshot using File>Virtual Media Manager...

Suppose Snapshot AAA has an immediate child snapshot BBB.
AAA
|
+--BBB

If snapshot AAA has a Normal hard disk file 'HardDisk.VDI' attached, and snapshot BBB has a differencing hard disk '{99-9-99}.VDI' attached, then deleting AAA will merge '{99–9–99}.VDI' into 'HardDisk.VDI', then delete the '{99–9–99}.VDI' file, then attach 'HardDisk.VDI' to snapshot BBB.

If snapshot AAA has a differencing hard disk file '{11–1–11}.VDI' attached, and snapshot BBB has a differencing hard disk '{99–9–99}.VDI' attached, then deleting AAA will merge '{11–1–11}.VDI' into '{99–9–99}.VDI'.

Differencing hard disks are described further here: Tutorial: All about VDIs
MarkCranness
Volunteer
 
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: Snapshots branching

Postby StuartV » 7. Feb 2010, 18:56

Thanks for taking the time to be so helpful!

I am now cloning snapshots and making up new VMs like I know what I'm doing!
StuartV
 
Posts: 3
Joined: 6. Feb 2010, 00:29
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows 7

Re: Snapshots branching

Postby trucbidule » 8. Feb 2010, 00:36

Yes! Understood! Thanks a lot MarkCranness for your time and the clear answers you post!
trucbidule
 
Posts: 13
Joined: 5. Feb 2010, 20:50
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: linux - windows

Re: Snapshots branching

Postby trucbidule » 10. Feb 2010, 17:32

I have tried deleting a snapshot of a windows machine.

There were 3 snaps like this :
snap1
-snap2
--snap3
---current state

Machine was OK.

I deleted snap2 to free HD space

Now I got :
snap1
-snap3
--current state

Machine doesn't boot.
There's a message saying the hal.dll file is missing or corrupted...

For sure isn't the expected result... Any idea?
trucbidule
 
Posts: 13
Joined: 5. Feb 2010, 20:50
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: linux - windows

Re: Snapshots branching

Postby MarkCranness » 11. Feb 2010, 00:04

trucbidule wrote:Machine doesn't boot.
There's a message saying the hal.dll file is missing or corrupted...
For sure isn't the expected result... Any idea?

That for sure is not the expected result.
Is there (and was there) free space on the host disk that contains the snapshot differencing hard disks?
Is this a VDI file or a VHD file? I have had a VHD VM damaged with registry damage and BSODs when I deleted a snapshot.
MarkCranness
Volunteer
 
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: Snapshots branching

Postby KasperTA » 16. Feb 2010, 17:51

I just had the exact same experience, deleting a snapshot in the middle of the branch with 3 snapshots, left my latest snapshot useless with some missing file(s) on boot.

My guest OS was Windows XP Pro UK, running in a .VMDK disc container.
KasperTA
 
Posts: 2
Joined: 16. Feb 2010, 15:19
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Windows 95,98, 2000, XP, 7, Ubuntu 9.10 desktop, Ubuntu 9.10 JeOS Server

Re: Snapshots branching

Postby MarkCranness » 17. Feb 2010, 05:38

If you can construct a reproducable test case, please create a problem ticket for it at this link:
http://www.virtualbox.org/wiki/Bugtracker
(Requires an account be created: use the Register link at the top right of the above page.)

Edit: This ticket seems directly related: VMDK disk corrupt after discarding snapshots
Or add this existing ticket if you think the symptoms/problem are related: http://www.virtualbox.org/ticket/6023
MarkCranness
Volunteer
 
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: Snapshots branching

Postby trucbidule » 4. Mar 2010, 16:17

Hi,
MarkCranness wrote:Is this a VDI file or a VHD file? I have had a VHD VM damaged with registry damage and BSODs when I deleted a snapshot.

I use "out of the virtualbox" standard vdi. Virtual machine created with virtualbox from scratch.

Starting position :
snap1
-snap2
--snap3
---current state

Deleting snap 3, then snap 2 produces a non bootable current state. It was possible to revert to snap 1 and machine did boot. But changes are lost as a result of the restore of an old snap. Logical. But this seems to show that even the current state can be compromized by a snap deletion.

Bug #6023 part 2) is what I experienced today, yes. But as far as I can see, the ticket hasn't been taken into account. How to know if and when the dev. team investigates a ticket?
trucbidule
 
Posts: 13
Joined: 5. Feb 2010, 20:50
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: linux - windows


Return to Using VirtualBox

Who is online

Users browsing this forum: No registered users and 23 guests