Sun Microsystems VERSION 3.1.0_BETA2 User Manual

Page of 283
5 Virtual storage
taken a snapshot. Imagine you have accidentally infected your VM with a virus and
would like to go back to the snapshot. With a normal hard disk image, you simply
revert the state of the VM, and the earlier state of your hard disk image will be restored
as well (and your virus infection will be undone). With an immutable hard disk,
irrespective of the snapshot, all it takes is to shut down and restart your VM, and the
virus infection will be discarded. With a write-through image however, you cannot
easily undo the virus infection by means of virtualization, but will have to disinfect
your virtual machine like a real computer.
Still, you might find write-though images useful if you want to preserve critical data
irrespective of snapshots, and since you can attach more than one image to a VM, you
may want to have one immutable for the operating system and one write-through for
your data files.
5.5 Differencing images
The previous section hinted at differencing images and how they are used with snap-
shots, immutable images and multiple disk attachments. For the inquisitive VirtualBox
user, this section describes in more detail how they work.
A differencing image is a special disk image that only holds the differences to an-
other image. A differencing image by itself is useless, it must always refer to another
image. The differencing image is then typically referred to as a “child”, which holds
the differences to its “parent”.
When a differencing image is active, it receives all write operations from the virtual
machine instead of its parent. The differencing image only contains the sectors of the
virtual hard disk that have changed since the differencing image was created. When
the machine reads a sector from such a virtual hard disk, it looks into the differencing
image first. If the sector is present, it is returned from there; if not, VirtualBox looks
into the parent. In other words, the parent becomes “read-only”; it is never written to
again, but it is read from if a sector has not changed.
Differencing images can be chained. If another differencing image is created for a
virtual disk that already has a differencing image, then it becomes a “grandchild” of
the original parent. The first differencing image then becomes read-only as well, and
write operations only go to the second-level differencing image. When reading from
the virtual disk, VirtualBox needs to look into the second differencing image first, then
into the first if the sector was not found, and then into the original image.
There can be an unlimited number of differencing images, and each image can
have more than one child. As a result, the differencing images can form a complex
tree with parents, “siblings” and children, depending on how complex your machine
configuration is. Write operations always go to the one active differencing image, and
for read operations, VirtualBox may need to look up all the parents in the chain until
the sector in question is found. You can look at such a tree in the Virtual Disk Manager.
In all of these situations, to the virtual machine, the virtual hard disk behaves like
any other disk. While the virtual machine is running, there is a slight run-time I/O
overhead because VirtualBox might need to look up sectors several times. This is not
83