VirtualBox

source: vbox/trunk/doc/manual/en_US/user_Storage.xml@ 35519

Last change on this file since 35519 was 35232, checked in by vboxsync, 14 years ago

some corrections

File size: 47.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
4<chapter id="storage">
5 <title>Virtual storage</title>
6
7 <para>As the virtual machine will most probably expect to see a hard disk
8 built into its virtual computer, VirtualBox must be able to present "real"
9 storage to the guest as a virtual hard disk. There are presently three
10 methods in which to achieve this:</para>
11
12 <orderedlist>
13 <listitem>
14 <para>Most commonly, VirtualBox will use large image files on a real
15 hard disk and present them to a guest as a virtual hard disk. This is
16 described in <xref linkend="vdidetails" />.</para>
17 </listitem>
18
19 <listitem>
20 <para>Alternatively, if you have iSCSI storage servers, you can attach
21 such a server to VirtualBox as well; this is described in <xref
22 linkend="storage-iscsi" />.</para>
23 </listitem>
24
25 <listitem>
26 <para>Finally, as an experimental feature, you can allow a virtual
27 machine to access one of your host disks directly; this advanced feature
28 is described in <xref linkend="rawdisk" />.</para>
29 </listitem>
30 </orderedlist>
31
32 <para>Each such virtual storage device (image file, iSCSI target or physical
33 hard disk) will need to be connected to the virtual hard disk controller
34 that VirtualBox presents to a virtual machine. This is explained in the next
35 section.</para>
36
37 <sect1 id="harddiskcontrollers">
38 <title>Hard disk controllers: IDE, SATA (AHCI), SCSI, SAS</title>
39
40 <para>In a real PC, hard disks and CD/DVD drives are connected to a device
41 called hard disk controller which drives hard disk operation and data
42 transfers. VirtualBox can emulate the four most common types of hard disk
43 controllers typically found in today's PCs: IDE, SATA (AHCI), SCSI and
44 SAS.<footnote>
45 <para>SATA support was added with VirtualBox 1.6; experimental SCSI
46 support was added with 2.1 and fully implemented with 2.2. Generally,
47 storage attachments were made much more flexible with VirtualBox 3.1;
48 see below. Support for the LSI Logic SAS controller was added with
49 VirtualBox 3.2.</para>
50 </footnote><itemizedlist>
51 <listitem>
52 <para><emphasis role="bold">IDE (ATA)</emphasis> controllers have
53 been in use since the 1980s. Initially, this type of interface
54 worked only with hard disks, but was later extended to also support
55 CD-ROM drives and other types of removable media. In physical PCs,
56 this standard uses flat ribbon parallel cables with 40 or 80 wires.
57 Each such cable can connect two devices to a controller, which have
58 traditionally been called "master" and "slave". Typical hard disk
59 controllers have two connectors for such cables; as a result, most
60 PCs support up to four devices.</para>
61
62 <para>In VirtualBox, each virtual machine has one IDE controller
63 enabled by default, which gives you up to four virtual storage
64 devices that you can attach to the machine. (By default, one of
65 these four -- the secondary master -- is preconfigured to be the
66 machine's virtual CD/DVD drive, but this can be changed.<footnote>
67 <para>The assignment of the machine's CD/DVD drive to the
68 secondary master was fixed before VirtualBox 3.1; it is now
69 changeable, and the drive can be at other slots of the IDE
70 controller, and there can be more than one such drive.</para>
71 </footnote>)</para>
72
73 <para>So even if your guest operating system has no support for SCSI
74 or SATA devices, it should always be able to see the default IDE
75 controller that is enabled by default.</para>
76
77 <para>You can also select which exact type of IDE controller
78 hardware VirtualBox should present to the virtual machine (PIIX3,
79 PIIX4 or ICH6). This makes no difference in terms of performance,
80 but if you import a virtual machine from another virtualization
81 product, the operating system in that machine may expect a
82 particular controller and crash if it isn't found.</para>
83
84 <para>After you have created a new virtual machine with the "New
85 Virtual Machine" wizard of the graphical user interface, you will
86 typically see one IDE controller in the machine's "Storage" settings
87 where the virtual CD/DVD drive will be attached to one of the four
88 ports of this controller.</para>
89 </listitem>
90
91 <listitem>
92 <para><emphasis role="bold">Serial ATA (SATA)</emphasis> is a newer
93 standard introduced in 2003. Compared to IDE, it supports both much
94 higher speeds and more devices per hard disk controller. Also, with
95 physical hardware, devices can be added and removed while the system
96 is running. The standard interface for SATA controllers is called
97 Advanced Host Controller Interface (<emphasis
98 role="bold">AHCI</emphasis>).</para>
99
100 <para>For compatibility reasons, AHCI controllers by default operate
101 the disks attached to it in a so-called "IDE compatibility mode",
102 unless SATA support is explicitly requested. "IDE compatibility
103 mode" only means that the drives can be seen and operated by the
104 computer's BIOS. Still, disks assigned to those slots will operate
105 in full-speed AHCI mode once the guest operating system has loaded
106 its AHCI device driver.</para>
107
108 <para>Like a real SATA controller, VirtualBox's virtual SATA
109 controller operates faster and also consumes less CPU resources than
110 the virtual IDE controller. Also, this allows you to connect up to
111 30 virtual hard disks to one machine instead of just three, as with
112 the VirtualBox IDE controller (with the DVD drive already attached).
113 Of these, the first four (numbered 0-3 in the graphical user
114 interface) are operated in IDE compatibility mode by default.</para>
115
116 <para>For this reason, starting with version 3.2 and depending on
117 the selected guest operating system, VirtualBox uses SATA as the
118 default for newly created virtual machines. One virtual SATA
119 controller is created by default, and the default disk that is
120 created with a new VM is attached to this controller.<warning>
121 <para>The entire SATA controller and the virtual disks attached
122 to it (including those in IDE compatibility mode) will not be
123 seen by operating systems that do not have device support for
124 AHCI. In particular, <emphasis role="bold">there is no support
125 for AHCI in Windows before Windows Vista</emphasis>, so Windows
126 XP (even SP2) will not see such disks unless you install
127 additional drivers. It is possible to switch from IDE to SATA
128 after installation by installing the SATA drivers and changing
129 the controller type in the VM settings dialog.<footnote>
130 <para>VirtualBox recommends the Intel Matrix Storage drivers
131 which can be downloaded from <ulink
132 url="http://downloadcenter.intel.com/Product_Filter.aspx?ProductID=2101">http://downloadcenter.intel.com/Product_Filter.aspx?ProductID=2101</ulink>.</para>
133 </footnote></para>
134 </warning></para>
135
136 <para>To add a SATA controller to a machine for which it has not
137 been enabled by default (either because it was created by an earlier
138 version of VirtualBox, or because SATA is not supported by default
139 by the selected guest operating system), go to the "Storage" page of
140 the machine's settings dialog, click on the "Add Controller" button
141 under the "Storage Tree" box and then select "Add SATA Controller".
142 After this, the additional controller will appear as a separate PCI
143 device in the virtual machine, and you can add virtual disks to
144 it.</para>
145
146 <para>To change the IDE compatibility mode settings for the SATA
147 controller, please see <xref
148 linkend="vboxmanage-storagectl" />.</para>
149 </listitem>
150
151 <listitem>
152 <para><emphasis role="bold">SCSI</emphasis> is another established
153 industry standard, standing for "Small Computer System Interface".
154 SCSI was standardized as early as 1986 as a generic interface for
155 data transfer between all kinds of devices, including storage
156 devices. Today SCSI is still used for connecting hard disks and tape
157 devices, but it has mostly been displaced in commodity hardware. It
158 is still in common use in high-performance workstations and
159 servers.</para>
160
161 <para>Primarily for compatibility with other virtualization
162 software, VirtualBox optionally supports LSI Logic and BusLogic SCSI
163 controllers, to each of which up to 15 virtual hard disks can be
164 attached.</para>
165
166 <para>To enable a SCSI controller, on the "Storage" page of a
167 virtual machine's settings dialog, click on the "Add Controller"
168 button under the "Storage Tree" box and then select "Add SCSI
169 Controller". After this, the additional controller will appear as a
170 separate PCI device in the virtual machine.<warning>
171 <para>As with the other controller types, a SCSI controller will
172 only be seen by operating systems with device support for it.
173 Windows 2003 and later ships with drivers for the LSI Logic
174 controller, while Windows NT 4.0 and Windows 2000 ships with
175 drivers for the BusLogic controller. Windows XP ships with
176 drivers for neither.</para>
177 </warning></para>
178 </listitem>
179
180 <listitem>
181 <para><emphasis role="bold">Serial Attached SCSI (SAS)</emphasis> is
182 another bus standard which uses the SCSI command set. As opposed to
183 SCSI, however, with physical devices, serial cables are used instead
184 of parallel ones, which simplifies physical device connections. In
185 some ways, therefore, SAS is to SCSI what SATA is to IDE: it allows
186 for more reliable and faster connections.</para>
187
188 <para>To support high-end guests which require SAS controllers,
189 VirtualBox emulates a LSI Logic SAS controller, which can be enabled
190 much the same way as a SCSI controller. At this time, up to eight
191 devices can be connected to the SAS controller.</para>
192
193 <warning>
194 <para>As with SATA, the SAS controller will only be seen by
195 operating systems with device support for it. In particular,
196 <emphasis role="bold">there is no support for SAS in Windows
197 before Windows Vista</emphasis>, so Windows XP (even SP2) will not
198 see such disks unless you install additional drivers.</para>
199 </warning>
200 </listitem>
201 </itemizedlist></para>
202
203 <para>In summary, VirtualBox gives you the following categories of virtual
204 storage slots:<orderedlist>
205 <listitem>
206 <para>four slots attached to the traditional IDE controller, which
207 are always present (one of which typically is a virtual CD/DVD
208 drive);</para>
209 </listitem>
210
211 <listitem>
212 <para>30 slots attached to the SATA controller, if enabled and
213 provided that your guest operating system can see it; these slots
214 can either be<orderedlist>
215 <listitem>
216 <para>in IDE compatibility mode (by default, slots 0-3)
217 or</para>
218 </listitem>
219
220 <listitem>
221 <para>in SATA mode;</para>
222 </listitem>
223 </orderedlist></para>
224 </listitem>
225
226 <listitem>
227 <para>15 slots attached to the SCSI controller, if enabled and
228 supported by the guest operating system;</para>
229 </listitem>
230
231 <listitem>
232 <para>eight slots attached to the SAS controller, if enabled and
233 supported by the guest operating system.</para>
234 </listitem>
235 </orderedlist></para>
236
237 <para>Given this large choice of storage controllers, you may ask yourself
238 which one to choose. In general, you should avoid IDE unless it is the
239 only controller supported by your guest. Whether you use SATA, SCSI or SAS
240 does not make any real difference. The variety of controllers is only
241 supplied for VirtualBox for compatibility with existing hardware and other
242 hypervisors.</para>
243 </sect1>
244
245 <sect1 id="vdidetails">
246 <title>Disk image files (VDI, VMDK, VHD, HDD)</title>
247
248 <para>Disk image files reside on the host system and are seen by the guest
249 systems as hard disks of a certain geometry. When a guest operating system
250 reads from or writes to a hard disk, VirtualBox redirects the request to
251 the image file.</para>
252
253 <para>Like a physical disk, a virtual disk has a size (capacity), which
254 must be specified when the image file is created. As opposed to a physical
255 disk however, VirtualBox allows you to expand an image file after
256 creation, even if it has data already; see <xref
257 linkend="vboxmanage-modifyvdi" /> for details.<footnote>
258 <para>Image resizing was added with VirtualBox 4.0.</para>
259 </footnote></para>
260
261 <para>VirtualBox supports four variants of disk image files:<itemizedlist>
262 <listitem>
263 <para>Normally, VirtualBox uses its own container format for guest
264 hard disks -- Virtual Disk Image (VDI) files. In particular, this
265 format will be used when you create a new virtual machine with a new
266 disk.</para>
267 </listitem>
268
269 <listitem>
270 <para>VirtualBox also fully supports the popular and open VMDK
271 container format that is used by many other virtualization products,
272 in particular, by VMware.<footnote>
273 <para>Initial support for VMDK was added with VirtualBox 1.4;
274 since version 2.1, VirtualBox supports VMDK fully, meaning that
275 you can create snapshots and use all the other advanced features
276 described above for VDI images with VMDK also.</para>
277 </footnote></para>
278 </listitem>
279
280 <listitem>
281 <para>VirtualBox also fully supports the VHD format used by
282 Microsoft.</para>
283 </listitem>
284
285 <listitem>
286 <para>Image files of Parallels version 2 (HDD format) are also
287 supported.<footnote>
288 <para>Support was added with VirtualBox 3.1.</para>
289 </footnote> For lack of documentation of the format, newer formats
290 (3 and 4) are not supported. You can however convert such image
291 files to version 2 format using tools provided by Parallels.</para>
292 </listitem>
293 </itemizedlist></para>
294
295 <para>Irrespective of the disk capacity and format, as briefly mentioned
296 in <xref linkend="gui-createvm" />, there are two options of how to create
297 a disk image: fixed-size or dynamically expanding.</para>
298
299 <itemizedlist>
300 <listitem>
301 <para>If you create a <emphasis role="bold">fixed-size
302 image</emphasis>, an image file will be created on your host system
303 which has roughly the same size as the virtual disk's capacity. So,
304 for a 10G disk, you will have a 10G file. Note that the creation of a
305 fixed-size image can take a long time depending on the size of the
306 image and the write performance of your hard disk.</para>
307 </listitem>
308
309 <listitem>
310 <para>For more flexible storage management, use a <emphasis
311 role="bold">dynamically expanding image</emphasis>. This will
312 initially be very small and not occupy any space for unused virtual
313 disk sectors, but the image file will grow every time a disk sector is
314 written to for the first time. While this format takes less space
315 initially, the fact that VirtualBox needs to constantly expand the
316 image file consumes additional computing resources, so until the disk
317 has fully expanded, write operations are slower than with fixed size
318 disks. However, after a dynamic disk has fully expanded, the
319 performance penalty for read and write operations is
320 negligible.</para>
321 </listitem>
322 </itemizedlist>
323 </sect1>
324
325 <sect1 id="vdis">
326 <title>The Virtual Media Manager</title>
327
328 <para>VirtualBox keeps track of all the hard disk, CD/DVD-ROM and floppy
329 disk images which are in use by virtual machines. These are often referred
330 to as "known media" and come from two sources:<itemizedlist>
331 <listitem>
332 <para>all media currently attached to virtual machines;</para>
333 </listitem>
334
335 <listitem>
336 <para>"registered" media for compatibility with VirtualBox versions
337 older than version 4.0. For details about how media registration has
338 changed with version 4.0, please refer to <xref
339 linkend="vboxconfigdata" />.</para>
340 </listitem>
341 </itemizedlist></para>
342
343 <para>The known media can be viewed and changed in the <emphasis
344 role="bold">Virtual Media Manager</emphasis>, which you can access from
345 the "File" menu in the VirtualBox main window:</para>
346
347 <para><mediaobject>
348 <imageobject>
349 <imagedata align="center" fileref="images/virtual-disk-manager.png"
350 width="12cm" />
351 </imageobject>
352 </mediaobject>The known media are conveniently grouped in three tabs for
353 the three possible formats. These formats are:</para>
354
355 <itemizedlist>
356 <listitem>
357 <para>Hard disk images, either in VirtualBox's own Virtual Disk Image
358 (VDI) format or in the third-party formats listed in the previous
359 chapter;</para>
360 </listitem>
361
362 <listitem>
363 <para>CD/DVD images in standard ISO format;</para>
364 </listitem>
365
366 <listitem>
367 <para>floppy images in standard RAW format.</para>
368 </listitem>
369 </itemizedlist>
370
371 <para>As you can see in the screenshot above, for each image, the Virtual
372 Media Manager shows you the full path of the image file and other
373 information, such as the virtual machine the image is currently attached
374 to, if any.</para>
375
376 <para>The Virtual Media Manager allows you to</para>
377
378 <itemizedlist>
379 <listitem>
380 <para><emphasis role="bold">remove</emphasis> an image from the
381 registry (and optionally delete the image file when doing so);</para>
382 </listitem>
383
384 <listitem>
385 <para><emphasis role="bold">"release"</emphasis> an image, that is,
386 detach it from a virtual machine if it is currently attached to one as
387 a virtual hard disk.</para>
388 </listitem>
389 </itemizedlist>
390
391 <para>Starting with version 4.0, to <emphasis role="bold">create new disk
392 images,</emphasis> please use the "Storage" page in a virtual machine's
393 settings dialog because disk images are now by default stored in each
394 machine's own folder.</para>
395
396 <para>Hard disk image files can be copied onto other host systems and
397 imported into virtual machines there, although certain guest systems
398 (notably Windows 2000 and XP) will require that the new virtual machine be
399 set up in a similar way to the old one.<note>
400 <para>Do not simply make copies of virtual disk images. If you import
401 such a second copy into a virtual machine, VirtualBox will complain
402 with an error, since VirtualBox assigns a unique identifier (UUID) to
403 each disk image to make sure it is only used once. See <xref
404 linkend="cloningvdis" /> for instructions on this matter. Also, if you
405 want to copy a virtual machine to another system, VirtualBox has an
406 import/export facility that might be better suited for your needs; see
407 <xref linkend="ovf" />.</para>
408 </note></para>
409 </sect1>
410
411 <sect1 id="hdimagewrites">
412 <title>Special image write modes</title>
413
414 <para>For each virtual disk image supported by VirtualBox, you can
415 determine separately how it should be affected by write operations from a
416 virtual machine and snapshot operations. This applies to all of the
417 aforementioned image formats (VDI, VMDK, VHD or HDD) and irrespective of
418 whether an image is fixed-size or dynamically expanding.</para>
419
420 <para>By default, images are in "normal" mode. To mark an existing image
421 with one of the non-standard modes listed below, use
422 <computeroutput>VBoxManage modifyhd</computeroutput>; see <xref
423 linkend="vboxmanage-modifyvdi" />. Alternatively, use VBoxManage to attach
424 the image to a VM and use the <computeroutput>--mtype</computeroutput>
425 argument; see <xref linkend="vboxmanage-storageattach" />.</para>
426
427 <orderedlist>
428 <listitem>
429 <para>With <emphasis role="bold">normal images</emphasis> (the default
430 setting), there are no restrictions on how guests can read from and
431 write to the disk.</para>
432
433 <para>When you take a snapshot of your virtual machine as described in
434 <xref linkend="snapshots" />, the state of such a "normal hard disk"
435 will be recorded together with the snapshot, and when reverting to the
436 snapshot, its state will be fully reset.</para>
437
438 <para>(Technically, strictly speaking, the image file itself is not
439 "reset". Instead, when a snapshot is taken, VirtualBox "freezes" the
440 image file and no longer writes to it. For the write operations from
441 the VM, a second, "differencing" image file is created which receives
442 only the changes to the original image; see the next section for
443 details.)</para>
444
445 <para>While you can attach the same "normal" image to more than one
446 virtual machine, only one of these virtual machines attached to the
447 same image file can be executed simultaneously, as otherwise there
448 would be conflicts if several machines write to the same image
449 file.<footnote>
450 <para>This restriction is more lenient now than it was before
451 VirtualBox 2.2. Previously, each "normal" disk image could only be
452 <emphasis>attached</emphasis> to one single machine. Now it can be
453 attached to more than one machine so long as only one of these
454 machines is running.</para>
455 </footnote></para>
456 </listitem>
457
458 <listitem>
459 <para>By contrast, <emphasis role="bold">write-through hard
460 disks</emphasis> are completely unaffected by snapshots: their state
461 is <emphasis>not</emphasis> saved when a snapshot is taken, and not
462 restored when a snapshot is restored.</para>
463 </listitem>
464
465 <listitem>
466 <para><emphasis role="bold">Shareable hard disks</emphasis> are a
467 variant of write-through hard disks. In principle they behave exactly
468 the same, i.e. their state is <emphasis>not</emphasis> saved when a
469 snapshot is taken, and not restored when a snapshot is restored. The
470 difference only shows if you attach such disks to several VMs.
471 Shareable VMs may be attached to several VMs which may run
472 concurrently. This makes them suitable for use by cluster filesystems
473 between VMs and similar applications which are explicitly prepared to
474 access a disk concurrently. Only fixed size images can be used in this
475 way, and dynamically growing images are rejected.<warning>
476 <para>This is an expert feature, and misuse can lead to data loss
477 -- regular filesystems are not prepared to handle simultaneous
478 changes by several parties.</para>
479 </warning></para>
480 </listitem>
481
482 <listitem>
483 <para>Next, <emphasis role="bold">immutable images</emphasis> only
484 remember write accesses temporarily while the virtual machine is
485 running; all changes are lost when the virtual machine is powered on
486 the next time. As a result, as opposed to "normal" images, the same
487 immutable image can be used with several virtual machines without
488 restrictions.</para>
489
490 <para><emphasis>Creating</emphasis> an immutable image makes little
491 sense since it would be initially empty and lose its contents with
492 every machine restart (unless you really want to have a disk that is
493 always unformatted when the machine starts up). As a result, normally,
494 you would first create a "normal" image and then, when you deem its
495 contents useful, later mark it immutable.</para>
496
497 <para>If you take a snapshot of a machine with immutable images, then
498 on every machine power-up, those images are reset to the state of the
499 last (current) snapshot (instead of the state of the original
500 immutable image).</para>
501
502 <note>
503 <para>As a special exception, immutable images are
504 <emphasis>not</emphasis> reset if they are attached to a machine
505 whose last snapshot was taken while the machine was running (a
506 so-called "online" snapshot). As a result, if the machine's current
507 snapshot is such an "online" snapshot, its immutable images behave
508 exactly like the "normal" images described previously. To re-enable
509 the automatic resetting of such images, delete the current snapshot
510 of the machine.</para>
511 </note>
512
513 <para>Again, technically, VirtualBox never writes to an immutable
514 image directly at all. All write operations from the machine will be
515 directed to a differencing image; the next time the VM is powered on,
516 the differencing image is reset so that every time the VM starts, its
517 immutable images have exactly the same content.<footnote>
518 <para>This behavior also changed with VirtualBox 2.2. Previously,
519 the differencing images were discarded when the machine session
520 <emphasis>ended</emphasis>; now they are discarded every time the
521 machine is powered on.</para>
522 </footnote> The differencing image is only reset when the machine is
523 powered on from within VirtualBox, not when you reboot by requesting a
524 reboot from within the machine. This is also why immutable images
525 behave as described above when snapshots are also present, which use
526 differencing images as well.</para>
527
528 <para>If the automatic discarding of the differencing image on VM
529 startup does not fit your needs, you can turn it off using the
530 <computeroutput>autoreset</computeroutput> parameter of
531 <computeroutput>VBoxManage modifyhd</computeroutput>; see <xref
532 linkend="vboxmanage-modifyvdi" /> for details.</para>
533 </listitem>
534
535 <listitem>
536 <para>An image in <emphasis role="bold">multiattach mode</emphasis>
537 can be attached to more than one virtual machine at the same time,
538 even if these machines are running simultaneously. For each virtual
539 machine to which such an image is attached, a differencing image is
540 created. As a result, data that is written to such a virtual disk by
541 one machine is not seen by the other machines to which the image is
542 attached; each machine creates its own write history of the
543 multiattach image.</para>
544
545 <para>Technically, a "multiattach" image behaves identically to an
546 "immutable" image except the differencing image is not reset every
547 time the machine starts.</para>
548 </listitem>
549
550 <listitem>
551 <para>Finally, the <emphasis role="bold">read-only image</emphasis> is
552 used automatically for CD/DVD images, since CDs/DVDs can never be
553 written to.</para>
554 </listitem>
555 </orderedlist>
556
557 <para>To illustrate the differences between the various types with respect
558 to snapshots: Assume you have installed your guest operating system in
559 your VM, and you have taken a snapshot. Imagine you have accidentally
560 infected your VM with a virus and would like to go back to the snapshot.
561 With a normal hard disk image, you simply restore the snapshot, and the
562 earlier state of your hard disk image will be restored as well (and your
563 virus infection will be undone). With an immutable hard disk, all it takes
564 is to shut down and power on your VM, and the virus infection will be
565 discarded. With a write-through image however, you cannot easily undo the
566 virus infection by means of virtualization, but will have to disinfect
567 your virtual machine like a real computer.</para>
568
569 <para>Still, you might find write-through images useful if you want to
570 preserve critical data irrespective of snapshots, and since you can attach
571 more than one image to a VM, you may want to have one immutable for the
572 operating system and one write-through for your data files.</para>
573 </sect1>
574
575 <sect1 id="diffimages">
576 <title>Differencing images</title>
577
578 <para>The previous section hinted at differencing images and how they are
579 used with snapshots, immutable images and multiple disk attachments. For
580 the inquisitive VirtualBox user, this section describes in more detail how
581 they work.</para>
582
583 <para>A differencing image is a special disk image that only holds the
584 differences to another image. A differencing image by itself is useless,
585 it must always refer to another image. The differencing image is then
586 typically referred to as a "child", which holds the differences to its
587 "parent".</para>
588
589 <para>When a differencing image is active, it receives all write
590 operations from the virtual machine instead of its parent. The
591 differencing image only contains the sectors of the virtual hard disk that
592 have changed since the differencing image was created. When the machine
593 reads a sector from such a virtual hard disk, it looks into the
594 differencing image first. If the sector is present, it is returned from
595 there; if not, VirtualBox looks into the parent. In other words, the
596 parent becomes "read-only"; it is never written to again, but it is read
597 from if a sector has not changed.</para>
598
599 <para>Differencing images can be chained. If another differencing image is
600 created for a virtual disk that already has a differencing image, then it
601 becomes a "grandchild" of the original parent. The first differencing
602 image then becomes read-only as well, and write operations only go to the
603 second-level differencing image. When reading from the virtual disk,
604 VirtualBox needs to look into the second differencing image first, then
605 into the first if the sector was not found, and then into the original
606 image.</para>
607
608 <para>There can be an unlimited number of differencing images, and each
609 image can have more than one child. As a result, the differencing images
610 can form a complex tree with parents, "siblings" and children, depending
611 on how complex your machine configuration is. Write operations always go
612 to the one "active" differencing image that is attached to the machine,
613 and for read operations, VirtualBox may need to look up all the parents in
614 the chain until the sector in question is found. You can look at such a
615 tree in the Virtual Media Manager:<mediaobject>
616 <imageobject>
617 <imagedata align="center" fileref="images/virtual-disk-manager2.png"
618 width="12cm" />
619 </imageobject>
620 </mediaobject></para>
621
622 <para>In all of these situations, from the point of view of the virtual
623 machine, the virtual hard disk behaves like any other disk. While the
624 virtual machine is running, there is a slight run-time I/O overhead
625 because VirtualBox might need to look up sectors several times. This is
626 not noticeable however since the tables with sector information are always
627 kept in memory and can be looked up quickly.</para>
628
629 <para>Differencing images are used in the following
630 situations:<orderedlist>
631 <listitem>
632 <para><emphasis role="bold">Snapshots.</emphasis> When you create a
633 snapshot, as explained in the previous section, VirtualBox "freezes"
634 the images attached to the virtual machine and creates differencing
635 images for each of them (to be precise: one for each image that is
636 not in "write-through" mode). From the point of view of the virtual
637 machine, the virtual disks continue to operate before, but all write
638 operations go into the differencing images. Each time you create
639 another snapshot, for each hard disk attachment, another
640 differencing image is created and attached, forming a chain or
641 tree.</para>
642
643 <para>In the above screenshot, you see that the original disk image
644 is now attached to a snapshot, representing the state of the disk
645 when the snapshot was taken.</para>
646
647 <para>If you now <emphasis role="bold">restore</emphasis> a snapshot
648 -- that is, if you want to go back to the exact machine state that
649 was stored in the snapshot --, the following happens:<orderedlist>
650 <listitem>
651 <para>VirtualBox copies the virtual machine settings that were
652 copied into the snapshot back to the virtual machine. As a
653 result, if you have made changes to the machine configuration
654 since taking the snapshot, they are undone.</para>
655 </listitem>
656
657 <listitem>
658 <para>If the snapshot was taken while the machine was running,
659 it contains a saved machine state, and that state is restored
660 as well; after restoring the snapshot, the machine will then
661 be in "Saved" state and resume execution from there when it is
662 next started. Otherwise the machine will be in "Powered Off"
663 state and do a full boot.</para>
664 </listitem>
665
666 <listitem>
667 <para>For each disk image attached to the machine, the
668 differencing image holding all the write operations since the
669 current snapshot was taken is thrown away, and the original
670 parent image is made active again. (If you restored the "root"
671 snapshot, then this will be the root disk image for each
672 attachment; otherwise, some other differencing image descended
673 from it.) This effectively restores the old machine
674 state.</para>
675 </listitem>
676 </orderedlist></para>
677
678 <para>If you later <emphasis role="bold">delete</emphasis> a
679 snapshot in order to free disk space, for each disk attachment, one
680 of the differencing images becomes obsolete. In this case, the
681 differencing image of the disk attachment cannot simply be deleted.
682 Instead, VirtualBox needs to look at each sector of the differencing
683 image and needs to copy it back into its parent; this is called
684 "merging" images and can be a potentially lengthy process, depending
685 on how large the differencing image is. It can also temporarily need
686 a considerable amount of extra disk space, before the differencing
687 image obsoleted by the merge operation is deleted.</para>
688 </listitem>
689
690 <listitem>
691 <para><emphasis role="bold">Immutable images.</emphasis> When an
692 image is switched to "immutable" mode, a differencing image is
693 created as well. As with snapshots, the parent image then becomes
694 read-only, and the differencing image receives all the write
695 operations. Every time the virtual machine is started, all the
696 immutable images which are attached to it have their respective
697 differencing image thrown away, effectively resetting the virtual
698 machine's virtual disk with every restart.</para>
699 </listitem>
700 </orderedlist></para>
701 </sect1>
702
703 <sect1 id="cloningvdis">
704 <title>Cloning disk images</title>
705
706 <para>You can duplicate hard disk image files on the same host to quickly
707 produce a second virtual machine with the same operating system setup.
708 However, you should <emphasis>only</emphasis> make copies of virtual disk
709 images using the utility supplied with VirtualBox; see <xref
710 linkend="vboxmanage-clonevdi" />. This is because VirtualBox assigns a
711 unique identity number (UUID) to each disk image, which is also stored
712 inside the image, and VirtualBox will refuse to work with two images that
713 use the same number. If you do accidentally try to reimport a disk image
714 which you copied normally, you can make a second copy using VirtualBox's
715 utility and import that instead.</para>
716
717 <para>Note that newer Linux distributions identify the boot hard disk from
718 the ID of the drive. The ID VirtualBox reports for a drive is determined
719 from the UUID of the virtual disk image. So if you clone a disk image and
720 try to boot the copied image the guest might not be able to determine its
721 own boot disk as the UUID changed. In this case you have to adapt the disk
722 ID in your boot loader script (for example
723 <computeroutput>/boot/grub/menu.lst</computeroutput>). The disk ID looks
724 like this:<screen>scsi-SATA_VBOX_HARDDISK_VB5cfdb1e2-c251e503</screen></para>
725
726 <para>The ID for the copied image can be determined with <screen>hdparm -i /dev/sda</screen></para>
727 </sect1>
728
729 <sect1 id="iocaching">
730 <title>Host I/O caching</title>
731
732 <para>Starting with version 3.2, VirtualBox can optionally disable the I/O
733 caching that the host operating system would otherwise perform on disk
734 image files.</para>
735
736 <para>Traditionally, VirtualBox has opened disk image files as normal
737 files, which results in them being cached by the host operating system
738 like any other file. The main advantage of this is speed: when the guest
739 OS writes to disk and the host OS cache uses delayed writing, the write
740 operation can be reported as completed to the guest OS quickly while the
741 host OS can perform the operation asynchronously. Also, when you start a
742 VM a second time and have enough memory available for the OS to use for
743 caching, large parts of the virtual disk may be in system memory, and the
744 VM can access the data much faster.</para>
745
746 <para>Note that this applies only to image files; buffering never occurred
747 virtual disks residing on remote iSCSI storage, which is the more common
748 scenario in enterprise-class setups (see <xref
749 linkend="storage-iscsi" />).</para>
750
751 <para>While buffering is a useful default setting for virtualizating a few
752 machines on a desktop computer, there are some disadvantages to this
753 approach:<orderedlist>
754 <listitem>
755 <para>Delayed writing through the host OS cache is less secure. When
756 the guest OS writes data, it considers the data written even though
757 it has not yet arrived on a physical disk. If for some reason the
758 write does not happen (power failure, host crash), the likelihood of
759 data loss increases.</para>
760 </listitem>
761
762 <listitem>
763 <para>Disk image files tend to be very large. Caching them can
764 therefore quickly use up the entire host OS cache. Depending on the
765 efficiency of the host OS caching, this may slow down the host
766 immensely, especially if several VMs run at the same time. For
767 example, on Linux hosts, host caching may result in Linux delaying
768 all writes until the host cache is nearly full and then writing out
769 all these changes at once, possibly stalling VM execution for
770 minutes. This can result in I/O errors in the guest as I/O requests
771 time out there.</para>
772 </listitem>
773
774 <listitem>
775 <para>Physical memory is often wasted as guest operating systems
776 typically have their own I/O caches, which may result in the data
777 being cached twice (in both the guest and the host caches) for
778 little effect.</para>
779 </listitem>
780 </orderedlist></para>
781
782 <para>If you decide to disable host I/O caching for the above reasons,
783 VirtualBox uses its own small cache to buffer writes, but no read caching
784 since this is typically already performed by the guest OS. In addition,
785 VirtualBox fully supports asynchronous I/O for its virtual SATA, SCSI and
786 SAS controllers through multiple I/O threads.</para>
787
788 <para>Since asynchronous I/O is not supported by IDE controllers, for
789 performance reasons, you may want to leave host caching enabled for your
790 VM's virtual IDE controllers.</para>
791
792 <para>For this reason, VirtualBox allows you to configure whether the host
793 I/O cache is used for each I/O controller separately. Either uncheck the
794 "Use host I/O cache" box in the "Storage" settings for a given virtual
795 storage controller, or use the following VBoxManage command to disable the
796 host I/O cache for a virtual storage controller:<screen>VBoxManage storagectl &lt;vm&gt; --name &lt;controllername&gt; --hostiocache off</screen></para>
797
798 <para>See <xref linkend="vboxmanage-storagectl" /> for details.</para>
799
800 <para>For the above reasons also, VirtualBox now uses SATA controllers by
801 default for new virtual machines.</para>
802 </sect1>
803
804 <sect1 id="storage-bandwidth-limit">
805 <title>Limiting bandwidth for disk images</title>
806
807 <para>Starting with version 4.0, VirtualBox allows for limiting the
808 maximum bandwidth used for asynchronous I/O. Additionally it supports
809 sharing limits through bandwidth groups for several images. It is possible
810 to have more than one such limit.</para>
811
812 <para>Limits are configured through
813 <computeroutput>VBoxManage</computeroutput>. The example below creates a
814 bandwidth group named "Limit", sets the limit to 20 MB/s and assigns the
815 group to the attached disks of the VM:<screen>VBoxManage bandwidthctl "VM name" --name Limit --add disk --limit 20
816VBoxManage storageattach "VM name" --controller "SATA" --port 0 --device 0 --type hdd
817 --medium disk1.vdi --bandwidthgroup Limit
818VBoxManage storageattach "VM name" --controller "SATA" --port 1 --device 0 --type hdd
819 --medium disk2.vdi --bandwidthgroup Limit</screen></para>
820
821 <para>All disks in a group share the bandwidth limit, meaning that in the
822 example above the bandwidth of both images combined can never exceed 20
823 MB/s. However if one disk doesn't require bandwidth the other can use the
824 remaining bandwidth of its group.</para>
825
826 <para>The limits for each group can be changed while the VM is running,
827 with changes being picked up immediately. The example below changes the
828 limit for the group created in the example above to 10 MB/s:<screen>VBoxManage bandwidthctl "VM name" --name Limit --limit 10</screen></para>
829 </sect1>
830
831 <sect1 id="storage-cds">
832 <title>CD/DVD support</title>
833
834 <para>The virtual CD/DVD drive(s) by default support only reading. The
835 medium configuration is changeable at runtime. You can select between
836 three options to provide the medium data:<itemizedlist>
837 <listitem>
838 <para><emphasis role="bold">Host Drive</emphasis> defines that the
839 guest can read from the medium in the host drive.</para>
840 </listitem>
841
842 <listitem>
843 <para><emphasis role="bold">Image file</emphasis> (typically an ISO
844 file) gives the guest read-only access to the data in the
845 image.</para>
846 </listitem>
847
848 <listitem>
849 <para><emphasis role="bold">Empty</emphasis> stands for a drive
850 without an inserted medium.</para>
851 </listitem>
852 </itemizedlist></para>
853
854 <para>Changing between the above, or changing a medium in the host drive
855 that is accessed by a machine, or changing an image file will signal a
856 medium change to the guest operating system, which can then react to the
857 change (e.g. by starting an installation program).</para>
858
859 <para>Medium changes can be prevented by the guest, and VirtualBox
860 reflects that by locking the host drive if appropriate. You can force a
861 medium removal in such situations via the VirtualBox GUI or the VBoxManage
862 command line tool. Effectively this is the equivalent of the emergency
863 eject which many CD/DVD drives provide, with all associated side effects:
864 the guest OS can issue error messages, just like on real hardware, and
865 guest applications may misbehave. Use this with caution.<note>
866 <para>The identification string of the drive provided to the guest
867 (which, in the guest, would be displayed by configuration tools such
868 as the Windows Device Manager) is always "VBOX CD-ROM", irrespective
869 of the current configuration of the virtual drive. This is to prevent
870 hardware detection from being triggered in the guest operating system
871 every time the configuration is changed.</para>
872 </note></para>
873
874 <para>The standard CD/DVD emulation allows for reading standard data CD
875 and DVD formats only. As an experimental feature, for additional
876 capabilities, it is possible to give the guest direct access to the CD/DVD
877 host drive by enabling "passthrough" mode. Depending on the host hardware,
878 this may enable three things to work, potentially:<itemizedlist>
879 <listitem>
880 <para>CD/DVD writing from within the guest, if the host DVD drive is
881 a CD/DVD writer;</para>
882 </listitem>
883
884 <listitem>
885 <para>playing audio CDs;</para>
886 </listitem>
887
888 <listitem>
889 <para>playing encrypted DVDs.</para>
890 </listitem>
891 </itemizedlist></para>
892
893 <para>There is a "Passthrough" checkbox in the GUI dialog for configuring
894 the media attached to a storage controller, or you can use the
895 <computeroutput>--passthrough</computeroutput> option with
896 <computeroutput>VBoxManage storageattach</computeroutput>; see <xref
897 linkend="vboxmanage-storageattach" /> for details.</para>
898
899 <para>Even if pass-through is enabled, unsafe commands, such as updating
900 the drive firmware, will be blocked. Video CD formats are never supported,
901 not even in passthrough mode, and cannot be played from a virtual
902 machine.</para>
903
904 <para>On Solaris hosts, pass-through requires running VirtualBox with real
905 root permissions due to security measures enforced by the host.</para>
906 </sect1>
907
908 <sect1>
909 <title id="storage-iscsi">iSCSI servers</title>
910
911 <para>iSCSI stands for "Internet SCSI" and is a standard that allows for
912 using the SCSI protocol over Internet (TCP/IP) connections. Especially
913 with the advent of Gigabit Ethernet, it has become affordable to attach
914 iSCSI storage servers simply as remote hard disks to a computer network.
915 In iSCSI terminology, the server providing storage resources is called an
916 "iSCSI target", while the client connecting to the server and accessing
917 its resources is called "iSCSI initiator".</para>
918
919 <para>VirtualBox can transparently present iSCSI remote storage to a
920 virtual machine as a virtual hard disk. The guest operating system will
921 not see any difference between a virtual disk image (VDI file) and an
922 iSCSI target. To achieve this, VirtualBox has an integrated iSCSI
923 initiator.</para>
924
925 <para>VirtualBox's iSCSI support has been developed according to the iSCSI
926 standard and should work with all standard-conforming iSCSI targets. To
927 use an iSCSI target with VirtualBox, you must use the command line; see
928 <xref linkend="vboxmanage-storageattach" />.</para>
929 </sect1>
930</chapter>
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette