VirtualBox

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

Last change on this file since 55153 was 55153, checked in by vboxsync, 10 years ago

Manual: Document USB mass storage device support

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