1 | <?xml version='1.0' encoding='UTF-8'?>
|
---|
2 | <!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
|
---|
3 | <topic xml:lang="en-us" id="hdimagewrites">
|
---|
4 | <title>Special Image Write Modes</title>
|
---|
5 |
|
---|
6 | <body>
|
---|
7 | <p>For each virtual disk image supported by <ph conkeyref="vbox-conkeyref-phrases/product-name"/>, you can determine
|
---|
8 | separately how it should be affected by write operations from a virtual machine and snapshot operations. This
|
---|
9 | applies to all of the aforementioned image formats (VDI, VMDK, VHD, or HDD) and irrespective of whether an image
|
---|
10 | is fixed-size or dynamically allocated. </p>
|
---|
11 | <p>By default, images are in <i>normal</i> mode. To mark an existing image with one of the nonstandard modes listed below, use <userinput>VBoxManage modifymedium</userinput>. See <xref href="../cli_topics/vboxmanage-modifymedium.dita"/>. Alternatively, use <userinput>VBoxManage storageattach</userinput> to attach the image to a VM and specify the <codeph>--mtype</codeph> argument. See <xref href="../cli_topics/vboxmanage-storageattach.dita"/>.</p>
|
---|
12 | <p>The available virtual disk image modes are as follows: </p>
|
---|
13 | <ul>
|
---|
14 | <li>
|
---|
15 | <p><b outputclass="bold">Normal images</b> have no
|
---|
16 | restrictions on how guests can read from and write to the
|
---|
17 | disk. This is the default image mode.
|
---|
18 | </p>
|
---|
19 | <p>When you take a snapshot of your virtual machine as described in <xref href="snapshots.dita#snapshots"/>, the
|
---|
20 | state of a normal hard disk is recorded together with the snapshot, and when reverting to the snapshot, its
|
---|
21 | state will be fully reset. </p>
|
---|
22 | <p>The image file itself is not reset. Instead, when a snapshot is taken, <ph
|
---|
23 | conkeyref="vbox-conkeyref-phrases/product-name"/>
|
---|
24 | <i>freezes</i> the image file and no longer writes to it. For the write operations from the VM, a second,
|
---|
25 | <i>differencing</i> image file is created which receives only the changes to the original image. See <xref
|
---|
26 | href="diffimages.dita#diffimages"/>. </p>
|
---|
27 | <p>While you can attach the same normal image to more than one virtual machine, only one of these virtual
|
---|
28 | machines attached to the same image file can be executed simultaneously, as otherwise there would be conflicts
|
---|
29 | if several machines write to the same image file. </p>
|
---|
30 | </li>
|
---|
31 | <li>
|
---|
32 | <p><b outputclass="bold">Write-through hard disks</b> are
|
---|
33 | completely unaffected by snapshots. Their state is
|
---|
34 | <i>not</i> saved when a snapshot is taken, and
|
---|
35 | not restored when a snapshot is restored.
|
---|
36 | </p>
|
---|
37 | </li>
|
---|
38 | <li>
|
---|
39 | <p><b outputclass="bold">Shareable hard disks</b> are a
|
---|
40 | variant of write-through hard disks. In principle they behave
|
---|
41 | exactly the same. Their state is <i>not</i>
|
---|
42 | saved when a snapshot is taken, and not restored when a
|
---|
43 | snapshot is restored. The difference only shows if you attach
|
---|
44 | such disks to several VMs. Shareable disks may be attached to
|
---|
45 | several VMs which may run concurrently. This makes them
|
---|
46 | suitable for use by cluster filesystems between VMs and
|
---|
47 | similar applications which are explicitly prepared to access a
|
---|
48 | disk concurrently. Only fixed size images can be used in this
|
---|
49 | way, and dynamically allocated images are rejected.
|
---|
50 | </p>
|
---|
51 | <note type="caution">
|
---|
52 | <p>This is an expert feature, and misuse can lead to data loss, as regular filesystems are not prepared to
|
---|
53 | handle simultaneous changes by several parties. </p>
|
---|
54 | </note>
|
---|
55 | </li>
|
---|
56 | <li>
|
---|
57 | <p><b outputclass="bold">Immutable images</b> only
|
---|
58 | remember write accesses temporarily while the virtual machine
|
---|
59 | is running. All changes are lost when the virtual machine is
|
---|
60 | powered on the next time. As a result, as opposed to Normal
|
---|
61 | images, the same immutable image can be used with several
|
---|
62 | virtual machines without restrictions.
|
---|
63 | </p>
|
---|
64 | <p>Creating an immutable image makes little sense since it would be initially empty and lose its contents with
|
---|
65 | every machine restart. You would have a disk that is always unformatted when the machine starts up. Instead,
|
---|
66 | you can first create a normal image and then later mark it as immutable when you decide that the contents are
|
---|
67 | useful. </p>
|
---|
68 | <p>If you take a snapshot of a machine with immutable images, then on every machine power-up, those images are
|
---|
69 | reset to the state of the last (current) snapshot, instead of the state of the original immutable image. </p>
|
---|
70 | <note>
|
---|
71 | <p>As a special exception, immutable images are <i>not</i> reset if they are attached to a machine in a saved
|
---|
72 | state or whose last snapshot was taken while the machine was running. This is called an <i>online
|
---|
73 | snapshot</i>. As a result, if the machine's current snapshot is an online snapshot, its immutable images
|
---|
74 | behave exactly like the a normal image. To reenable the automatic resetting of such images, delete the
|
---|
75 | current snapshot of the machine. </p>
|
---|
76 | </note>
|
---|
77 | <p><ph conkeyref="vbox-conkeyref-phrases/product-name"/> never writes to an immutable image directly at all. All
|
---|
78 | write operations from the machine are directed to a differencing image. The next time the VM is powered on,
|
---|
79 | the differencing image is reset so that every time the VM starts, its immutable images have exactly the same
|
---|
80 | content. </p>
|
---|
81 | <p>The differencing image is only reset when the machine is powered on from within <ph
|
---|
82 | conkeyref="vbox-conkeyref-phrases/product-name"/>, not when you reboot by requesting a reboot from within
|
---|
83 | the machine. This is also why immutable images behave as described above when snapshots are also present,
|
---|
84 | which use differencing images as well. </p>
|
---|
85 | <p>If the automatic discarding of the differencing image on VM startup does not fit your needs, you can turn it off using the <codeph>autoreset</codeph> parameter of <userinput>VBoxManage modifymedium</userinput>. See <xref href="../cli_topics/vboxmanage-modifymedium.dita"/>.</p>
|
---|
86 | </li>
|
---|
87 | <li>
|
---|
88 | <p><b outputclass="bold">Multiattach mode images</b> can
|
---|
89 | be attached to more than one virtual machine at the same time,
|
---|
90 | even if these machines are running simultaneously. For each
|
---|
91 | virtual machine to which such an image is attached, a
|
---|
92 | differencing image is created. As a result, data that is
|
---|
93 | written to such a virtual disk by one machine is not seen by
|
---|
94 | the other machines to which the image is attached. Each
|
---|
95 | machine creates its own write history of the multiattach
|
---|
96 | image.
|
---|
97 | </p>
|
---|
98 | <p>Technically, a multiattach image behaves identically to an immutable image except the differencing image is
|
---|
99 | not reset every time the machine starts. </p>
|
---|
100 | <p>This mode is useful for sharing files which are almost never written, for instance picture galleries, where
|
---|
101 | every guest changes only a small amount of data and the majority of the disk content remains unchanged. The
|
---|
102 | modified blocks are stored in differencing images which remain relatively small and the shared content is
|
---|
103 | stored only once at the host. </p>
|
---|
104 | </li>
|
---|
105 | <li>
|
---|
106 | <p><b outputclass="bold">Read-only images</b> are used
|
---|
107 | automatically for CD/DVD images, since CDs/DVDs can never be
|
---|
108 | written to.
|
---|
109 | </p>
|
---|
110 | </li>
|
---|
111 | </ul>
|
---|
112 | <p>The following scenario illustrates the differences between the various image modes, with respect to snapshots. </p>
|
---|
113 | <p>Assume you have installed your guest OS in your VM, and you have taken a snapshot. Later, your VM is infected
|
---|
114 | with a virus and you would like to go back to the snapshot. With a normal hard disk image, you simply restore the
|
---|
115 | snapshot, and the earlier state of your hard disk image will be restored as well and your virus infection will be
|
---|
116 | undone. With an immutable hard disk, all it takes is to shut down and power on your VM, and the virus infection
|
---|
117 | will be discarded. With a write-through image however, you cannot easily undo the virus infection by means of
|
---|
118 | virtualization, but will have to disinfect your virtual machine like a real computer. </p>
|
---|
119 | <p>You might find write-through images useful if you want to preserve critical data irrespective of snapshots. As
|
---|
120 | you can attach more than one image to a VM, you may want to have one immutable image for the OS and one
|
---|
121 | write-through image for your data files. </p>
|
---|
122 | </body>
|
---|
123 |
|
---|
124 | </topic>
|
---|