5 Virtual storage In the above screenshot, you see that the original disk image is now attached to a snapshot, representing the state of the disk when the snapshot was taken. If you now restore a snapshot that is, if you want to go back to the exact machine state that was stored in the snapshot –, the following happens: a) VirtualBox copies the virtual machine settings that were copied into the snapshot back to the virtual machine. As a result, if you have made changes to the machine configuration since taking the snapshot, they are undone. b) If the snapshot was taken while the machine was running, it contains a saved machine state, and that state is restored as well after restoring the snapshot, the machine will then be in “Saved” state and resume execution from there when it is next started. Otherwise the machine will be in “Powered Off” state and do a full boot. c) For each disk image attached to the machine, the differencing image holding all the write operations since the current snapshot was taken is thrown away, and the original parent image is made active again. (If you restored the “root” snapshot, then this will be the root disk image for each attachment otherwise, some other differencing image descended from it.) This effectively restores the old machine state. If you later delete a snapshot in order to free disk space, for each disk attachment, one of the differencing images becomes obsolete. In this case, the differencing image of the disk attachment cannot simply be deleted. Instead, VirtualBox needs to look at each sector of the differencing image and needs to copy it back into its parent this is called “merging” images and can be a potentially lengthy process, depending on how large the differencing image is. It can also temporarily need a considerable amount of extra disk space, before the differencing image obsoleted by the merge operation is deleted. 2. Immutable images. When an image is switched to “immutable” mode, a differencing im- age is created as well. As with snapshots, the parent image then becomes read-only, and the differencing image receives all the write operations. Every time the virtual machine is started, all the immutable images which are attached to it have their respective differenc- ing image thrown away, effectively resetting the virtual machine’s virtual disk with every restart. 5.6 Cloning disk images You can duplicate hard disk image files on the same host to quickly produce a second virtual machine with the same operating system setup. However, you should only make copies of virtual disk images using the utility supplied with VirtualBox see chapter 8.22, VBoxManage clonehd, page 124. This is because VirtualBox assigns a unique identity number (UUID) to each disk image, which is also stored inside the image, and VirtualBox will refuse to work with two images that use the same number. If you do accidentally try to reimport a disk image which you copied normally, you can make a second copy using VirtualBox’s utility and import that instead. Note that newer Linux distributions identify the boot hard disk from the ID of the drive. The ID VirtualBox reports for a drive is determined from the UUID of the virtual disk image. So if you clone a disk image and try to boot the copied image the guest might not be able to determine its own boot disk as the UUID changed. In this case you have to adapt the disk ID in your boot loader script (for example /boot/grub/menu.lst). The disk ID looks like this: scsi-SATA_VBOX_HARDDISK_VB5cfdb1e2-c251e503 The ID for the copied image can be determined with hdparm -i /dev/sda 79
Previous Page Next Page