VirtualBox Clone Snapshots

VirtualBox Attacking Clone Snapshots This is mainly a reference post for later. I’ve found myself digging through history or stale bookmarks for steps to clone a snapshot within VirtualBox. This is a pain, be much easier to just search my blog for it. You will thank me later.

The main premises, one of my VMs crapped out after receiving a MS update, unable to boot. Imagine that!? I tried rolling back to a previous snapshot with no luck. My goal is to save the work I’ve done between my last snapshot and the VM not booting. In my case, there are many snapshots, I want to clone the VHD to snapshot I know works, boot it , update it, boot again ensuring all works before trying anything drastic to recover my data on current VM.

Important to note, should be able to boot new VM, reference the old VM as a mountable drive to pull off the data.

The commands below cloned snapshots fine for me in the past. I will say, using clonehd to clone a specific snapshot of a disk is much faster than any other option listed below. However, as of VirtualBox 4.1 Cloning has been added to the GUI menu.

Using the GUI to Clone

The GUI clone does not allow you to clone a specific snapshot from a disk. Instead, clone the entire VM with all snapshots, then rollback the clone to snapshot desired

  1. Right click VM to clone
  2. Select Clone
  3. Set the name of the new virtual machine. Default is original vm namd Clone.
  4. Decide if you want to Reinitialize the MAC address of all network cards Set Virtual Machine Name for Clone
  5. Click Next
  6. Cloning Configuration, tick Full Clone
  7. Click Next Set Full Clone
  8. Cloning Configuration, tick All states
  9. Click Next Set All States
  10. Click Clone Clone Complete
  11. Open new VM and roll back to snapshot desired
  12. Boot the new clone

To clonehd the Current State of a disk:

  1. Open the Virtual Media Manager (Menu: File>Virtual Media Manager).
  2. Navigate to the hard disk you want to clone and fully expand the tree (use * key on numeric keypad).
  3. Find the {hexUUID}.vdi file that is attached to the VM you want to clone the Current State of. It will be (one of) the leaf files at the end of a branch. When you select it, the ‘Attached to:’ text at the bottom of the window will say: 'Attached to: <VMName>', without any (snapshot name) in brackets after it.
  4. Click the filename to the right of the 'Location:' displayed at the bottom of the window.
  5. Ctrl+C / Copy to copy the text to the clipboard, which will be something like: (path){b6441469-5ccb-418c-8fdd-73c5e1a17314}.vdi
  6. Ctrl+V / Paste and extract the hexUUID value (removing the {} brackets) and run clonehd to clone it!
lang=bat
1
C:> VBoxManage clonehd b6441469-5ccb-418c-8fdd-73c5e1a17314 CloneDisk.vdi

To clonehd a snapshot of a disk:

  1. Open the Virtual Media Manager (Menu: File>Virtual Media Manager).
  2. Navigate to the hard disk you want to clone and fully expand the tree (use * key on numeric keypad).
  3. Find the {hexUUID}.vdi file that is attached to the VM (and Snapshot) you want to clone. It will be one of the files along a branch. When you select it, the 'Attached to:' text at the bottom of the window will say: 'Attached to: <VMName> (<SnapshotName>)', with (snaphot name) in brackets after it.
  4. Click the filename to the right of the 'Location:' displayed at the bottom of the window. 5.Ctrl+C/ Copy to copy the text to the clipboard, which will be something like: (path){75bd6ab1-ce25-4b56-aa39-7826c9ebcc93}.vdi
  5. Ctrl+V / Paste and extract the hexUUID value (removing the {} brackets) and run clonehd to clone it!
lang=bat
1
C:> VBoxManage clonehd 75bd6ab1-ce25-4b56-aa39-7826c9ebcc93 CloneDisk.vdi

To clonevm using a snapshot of a disk:

  1. Open the Virtual Media Manager (Menu: File>Virtual Media Manager).
  2. Navigate to the hard disk you want to clone and fully expand the tree (use * key on numeric keypad).
  3. Find the {hexUUID}.vdi file that is attached to the VM (and Snapshot) you want to clone. It will be one of the files along a branch. When you select it, the 'Attached to:' text at the bottom of the window will say: 'Attached to: <VMName> (<SnapshotName>)', with (snaphot name) in brackets after it.
  4. Click the filename to the right of the 'Location:' displayed at the bottom of the window.
  5. Ctrl+C/ Copy to copy the text to the clipboard, which will be something like: (path){75bd6ab1-ce25-4b56-aa39-7826c9ebcc93}.vdi
  6. Ctrl+V / Paste and extract the hexUUID value (removing the {} brackets) and run clonevm to clone it!

    • Set ‘uuid|name’ of the vm to clone
    • Set ‘snapshot uuid’ to snapshot you want to clone
    • Set mode to be machineandchildren, the snapshot provided by --snapshot and all child snapshots are cloned
    • Let clonevm set the default name "Original Name Clone" by leading off --name
    • Set the basefolder the new VM should be stored in
    • Let clonevm set a NEW uuid by leaving off --uuid
    • Auto register new VM in VirtualBox installation by sending --register
lang=bat
1
C:> VBoxManage clonevm myNameToBeCloned --snapshot 75bd6ab1-ce25-4b56-aa39-7826c9ebcc93 --mode machineandchildren --basefolder "myPath" --register

References

Comments