VirtualBox

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

Last change on this file since 42753 was 42753, checked in by vboxsync, 12 years ago

docs: wording fix

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