VirtualBox

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

Last change on this file since 74981 was 73276, checked in by vboxsync, 6 years ago

doc/manual: Big build system overhaul, because the use of entities and catalogs eliminates the need to have placeholders in XML which previously needed separate preprocessing. Many cleanups, including replacing almost all pattern rules (since their dependencies had to be too generous) and using defines instead. Also integrated many cleanups for the user manual text (which needs careful review, couldn't check yet if it uses any additional tags which some of our XSLT would ignore).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 54.1 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"[
4<!ENTITY % all.entities SYSTEM "all-entities.ent">
5%all.entities;
6]>
7<chapter id="storage">
8
9 <title>Virtual Storage</title>
10
11 <para>
12 As the virtual machine will most probably expect to see a hard disk
13 built into its virtual computer, VirtualBox must be able to present
14 real storage to the guest as a virtual hard disk. There are
15 presently three methods by which to achieve this:
16 </para>
17
18 <itemizedlist>
19
20 <listitem>
21 <para>
22 VirtualBox can use large image files on a real hard disk and
23 present them to a guest as a virtual hard disk. This is the most
24 common method, described in <xref linkend="vdidetails" />.
25 </para>
26 </listitem>
27
28 <listitem>
29 <para>
30 iSCSI storage servers can be attached to VirtualBox. This is
31 described in <xref
32 linkend="storage-iscsi" />.
33 </para>
34 </listitem>
35
36 <listitem>
37 <para>
38 You can allow a virtual machine to access one of your host disks
39 directly. This is an advanced feature, described in
40 <xref linkend="rawdisk" />.
41 </para>
42 </listitem>
43
44 </itemizedlist>
45
46 <para>
47 Each such virtual storage device, such as an image file, iSCSI
48 target, or physical hard disk, needs to be connected to the virtual
49 hard disk controller that VirtualBox presents to a virtual machine.
50 This is explained in the next section.
51 </para>
52
53 <sect1 id="harddiskcontrollers">
54
55 <title>Hard Disk Controllers: IDE, SATA (AHCI), SCSI, SAS, USB MSD, NVMe</title>
56
57 <para>
58 In a real PC, hard disks and CD/DVD drives are connected to a
59 device called hard disk controller which drives hard disk
60 operation and data transfers. VirtualBox can emulate the five most
61 common types of hard disk controllers typically found in today's
62 PCs: IDE, SATA (AHCI), SCSI, SAS, USB-based, and NVMe mass storage
63 devices.
64
65 <footnote>
66
67 <para>
68 SATA support was added with VirtualBox 1.6; experimental SCSI
69 support was added with 2.1 and fully implemented with 2.2.
70 Generally, storage attachments were made much more flexible
71 with VirtualBox 3.1. Support for the LSI Logic SAS controller
72 was added with VirtualBox 3.2. USB mass storage devices are
73 supported since VirtualBox 5.0. NVMe controller support was
74 added with VirtualBox 5.1.
75 </para>
76
77 </footnote>
78 </para>
79
80 <itemizedlist>
81
82 <listitem>
83 <para>
84 <emphasis role="bold">IDE (ATA)</emphasis> controllers are a
85 backwards compatible yet very advanced extension of the disk
86 controller in the IBM PC/AT (1984). Initially, this interface
87 worked only with hard disks, but was later extended to also
88 support CD-ROM drives and other types of removable media. In
89 physical PCs, this standard uses flat ribbon parallel cables
90 with 40 or 80 wires. Each such cable can connect two devices
91 to a controller, which have traditionally been called
92 <emphasis>master</emphasis> and <emphasis>slave</emphasis>.
93 Typical PCs had two connectors for such cables. As a result,
94 support for up to four IDE devices was most common.
95 </para>
96
97 <para>
98 In VirtualBox, each virtual machine may have one IDE
99 controller enabled, which gives you up to four virtual storage
100 devices that you can attach to the machine. By default, one of
101 these four, the secondary master, is preconfigured to be the
102 machine's virtual CD/DVD drive, but this can be changed.
103
104 <footnote>
105
106 <para>
107 The assignment of the machine's CD/DVD drive to the
108 secondary master was fixed before VirtualBox 3.1. It is
109 now changeable, and the drive can be at other slots of the
110 IDE controller, and there can be more than one such drive.
111 </para>
112
113 </footnote>
114
115 )
116 </para>
117
118 <para>
119 Even if your guest operating system has no support for SCSI or
120 SATA devices, it should always be able to see an IDE
121 controller.
122 </para>
123
124 <para>
125 You can also select which exact type of IDE controller
126 hardware VirtualBox should present to the virtual machine:
127 PIIX3, PIIX4, or ICH6. This makes no difference in terms of
128 performance, but if you import a virtual machine from another
129 virtualization product, the operating system in that machine
130 may expect a particular controller type and crash if it is not
131 found.
132 </para>
133
134 <para>
135 After you have created a new virtual machine with the New
136 Virtual Machine wizard of the graphical user interface, you
137 will typically see one IDE controller in the machine's Storage
138 settings. The virtual CD/DVD drive will be attached to one of
139 the four ports of this controller.
140 </para>
141 </listitem>
142
143 <listitem>
144 <para>
145 <emphasis role="bold">Serial ATA (SATA)</emphasis> is a newer
146 standard introduced in 2003. Compared to IDE, it supports both
147 much higher speeds and more devices per controller. Also, with
148 physical hardware, devices can be added and removed while the
149 system is running. The standard interface for SATA controllers
150 is called Advanced Host Controller Interface (AHCI).
151 </para>
152
153 <para>
154 Like a real SATA controller, VirtualBox's virtual SATA
155 controller operates faster and also consumes fewer CPU
156 resources than the virtual IDE controller. Also, this allows
157 you to connect up to 30 virtual hard disks to one machine
158 instead of just three, when compared to the VirtualBox IDE
159 controller with a DVD drive attached.
160 </para>
161
162 <para>
163 For this reason, starting with version 3.2 and depending on
164 the selected guest operating system, VirtualBox uses SATA as
165 the default for newly created virtual machines. One virtual
166 SATA controller is created by default, and the default disk
167 that is created with a new VM is attached to this controller.
168 </para>
169
170 <warning>
171 <para>
172 The entire SATA controller and the virtual disks attached to
173 it, including those in IDE compatibility mode, will not be
174 seen by operating systems that do not have device support
175 for AHCI. In particular, <emphasis>there is no support for
176 AHCI in Windows before Windows Vista</emphasis>, so Windows
177 XP (even SP3) will not see such disks unless you install
178 additional drivers. It is possible to switch from IDE to
179 SATA after installation by installing the SATA drivers and
180 changing the controller type in the VM settings dialog.
181
182 <footnote>
183
184 <para>
185 VirtualBox recommends the Intel Matrix Storage drivers,
186 which can be downloaded from
187 <ulink
188 url="http://downloadcenter.intel.com/Product_Filter.aspx?ProductID=2101">http://downloadcenter.intel.com/Product_Filter.aspx?ProductID=2101</ulink>.
189 </para>
190
191 </footnote>
192 </para>
193 </warning>
194
195 <para>
196 To add a SATA controller to a machine for which it has not
197 been enabled by default, either because it was created by an
198 earlier version of VirtualBox, or because SATA is not
199 supported by default by the selected guest operating system,
200 do the following. Go to the Storage page of the machine's
201 settings dialog, click <emphasis role="bold">Add
202 Controller</emphasis> under the Storage Tree box and then
203 select <emphasis role="bold">Add SATA Controller</emphasis>.
204 The new controller appears as a separate PCI device in the
205 virtual machine, and you can add virtual disks to it.
206 </para>
207
208 <para>
209 To change the IDE compatibility mode settings for the SATA
210 controller, see
211 <xref
212 linkend="vboxmanage-storagectl" />.
213 </para>
214 </listitem>
215
216 <listitem>
217 <para>
218 <emphasis role="bold">SCSI</emphasis> is another established
219 industry standard, standing for Small Computer System
220 Interface. SCSI was standardized as early as 1986 as a generic
221 interface for data transfer between all kinds of devices,
222 including storage devices. Today SCSI is still used for
223 connecting hard disks and tape devices, but it has mostly been
224 displaced in commodity hardware. It is still in common use in
225 high-performance workstations and servers.
226 </para>
227
228 <para>
229 Primarily for compatibility with other virtualization
230 software, VirtualBox optionally supports LSI Logic and
231 BusLogic SCSI controllers, to each of which up to 15 virtual
232 hard disks can be attached.
233 </para>
234
235 <para>
236 To enable a SCSI controller, on the Storage page of a virtual
237 machine's settings dialog, click <emphasis role="bold">Add
238 Controller</emphasis> under the Storage Tree box and then
239 select <emphasis role="bold">Add SCSI Controller</emphasis>.
240 The new controller appears as a separate PCI device in the
241 virtual machine.
242 </para>
243
244 <warning>
245 <para>
246 As with the other controller types, a SCSI controller will
247 only be seen by operating systems with device support for
248 it. Windows 2003 and later ships with drivers for the LSI
249 Logic controller, while Windows NT 4.0 and Windows 2000
250 ships with drivers for the BusLogic controller. Windows XP
251 ships with drivers for neither.
252 </para>
253 </warning>
254 </listitem>
255
256 <listitem>
257 <para>
258 <emphasis role="bold">Serial Attached SCSI (SAS)</emphasis> is
259 another bus standard which uses the SCSI command set. As
260 opposed to SCSI, however, with physical devices, serial cables
261 are used instead of parallel ones, which simplifies physical
262 device connections. In some ways, therefore, SAS is to SCSI
263 what SATA is to IDE: it allows for more reliable and faster
264 connections.
265 </para>
266
267 <para>
268 To support high-end guests which require SAS controllers,
269 VirtualBox emulates a LSI Logic SAS controller, which can be
270 enabled much the same way as a SCSI controller. At this time,
271 up to eight devices can be connected to the SAS controller.
272 </para>
273
274 <warning>
275 <para>
276 As with SATA, the SAS controller will only be seen by
277 operating systems with device support for it. In particular,
278 <emphasis>there is no support for SAS in Windows before
279 Windows Vista</emphasis>, so Windows XP (even SP3) will not
280 see such disks unless you install additional drivers.
281 </para>
282 </warning>
283 </listitem>
284
285 <listitem>
286 <para>
287 The <emphasis role="bold">USB mass storage device
288 class</emphasis> is a standard to connect external storage
289 devices like hard disks or flash drives to a host through USB.
290 All major operating systems support these devices for a long
291 time and ship generic drivers making third-party drivers
292 superfluous. In particular, legacy operating systems without
293 support for SATA controllers may benefit from USB mass storage
294 devices.
295 </para>
296
297 <para>
298 The virtual USB storage controller offered by VirtualBox works
299 differently to the other storage controller types. While most
300 storage controllers appear as a single PCI device to the guest
301 with multiple disks attached to it, the USB-based storage
302 controller does not appear as virtual storage controller. Each
303 disk attached to the controller appears as a dedicated USB
304 device to the guest.
305 </para>
306
307 <warning>
308 <para>
309 Booting from drives attached via USB is when EFI is used as
310 the BIOS lacks USB support.
311 </para>
312 </warning>
313 </listitem>
314
315 <listitem>
316 <para>
317 <emphasis role="bold">Non volatile memory express
318 (NVMe)</emphasis> is a very recent standard which emerged in
319 2011 connecting non volatile memory (NVM) directly over PCI
320 express to lift the bandwidth limitation of the previously
321 used SATA protocol for SSDs. Unlike other standards the
322 command set is very simple to achieve maximum throughput and
323 is not compatible with ATA or SCSI. Operating systems need to
324 support NVMe devices to make use of them. For example, Windows
325 8.1 added native NVMe support. For Windows 7, native support
326 was added with an update.
327
328 <footnote>
329
330 <para>
331 The NVMe controller is part of the extension pack.
332 </para>
333
334 </footnote>
335 </para>
336
337 <warning>
338 <para>
339 Booting from drives attached via NVMe is only supported when
340 EFI is used as the BIOS lacks the appropriate driver.
341 </para>
342 </warning>
343 </listitem>
344
345 </itemizedlist>
346
347 <para>
348 In summary, VirtualBox gives you the following categories of
349 virtual storage slots:
350 </para>
351
352 <itemizedlist>
353
354 <listitem>
355 <para>
356 Four slots attached to the traditional IDE controller, which
357 are always present. One of these is typically a virtual CD/DVD
358 drive.
359 </para>
360 </listitem>
361
362 <listitem>
363 <para>
364 30 slots attached to the SATA controller, if enabled and
365 supported by the guest operating system.
366 </para>
367 </listitem>
368
369 <listitem>
370 <para>
371 15 slots attached to the SCSI controller, if enabled and
372 supported by the guest operating system.
373 </para>
374 </listitem>
375
376 <listitem>
377 <para>
378 Eight slots attached to the SAS controller, if enabled and
379 supported by the guest operating system.
380 </para>
381 </listitem>
382
383 <listitem>
384 <para>
385 Eight slots attached to the virtual USB controller, if enabled
386 and supported by the guest operating system.
387 </para>
388 </listitem>
389
390 <listitem>
391 <para>
392 Up to 255 slots attached to the NVMe controller, if enabled
393 and supported by the guest operating system.
394 </para>
395 </listitem>
396
397 </itemizedlist>
398
399 <para>
400 Given this large choice of storage controllers, you may not know
401 which one to choose. In general, you should avoid IDE unless it is
402 the only controller supported by your guest. Whether you use SATA,
403 SCSI, or SAS does not make any real difference. The variety of
404 controllers is only supplied by VirtualBox for compatibility with
405 existing hardware and other hypervisors.
406 </para>
407
408 </sect1>
409
410 <sect1 id="vdidetails">
411
412 <title>Disk Image Files (VDI, VMDK, VHD, HDD)</title>
413
414 <para>
415 Disk image files reside on the host system and are seen by the
416 guest systems as hard disks of a certain geometry. When a guest
417 operating system reads from or writes to a hard disk, VirtualBox
418 redirects the request to the image file.
419 </para>
420
421 <para>
422 Like a physical disk, a virtual disk has a size (capacity), which
423 must be specified when the image file is created. As opposed to a
424 physical disk however, VirtualBox allows you to expand an image
425 file after creation, even if it has data already. See
426 <xref
427 linkend="vboxmanage-modifyvdi" />.
428
429 <footnote>
430
431 <para>
432 Image resizing was added with VirtualBox 4.0.
433 </para>
434
435 </footnote>
436 </para>
437
438 <para>
439 VirtualBox supports the following types of disk image files:
440 </para>
441
442 <itemizedlist>
443
444 <listitem>
445 <para>
446 <emphasis role="bold">VDI.</emphasis> Normally, VirtualBox
447 uses its own container format for guest hard disks. This is
448 called a Virtual Disk Image (VDI) file. This format is used
449 when you create a new virtual machine with a new disk.
450 </para>
451 </listitem>
452
453 <listitem>
454 <para>
455 <emphasis role="bold">VMDK.</emphasis> VirtualBox also fully
456 supports the popular and open VMDK container format that is
457 used by many other virtualization products, in particular, by
458 VMware.
459
460 <footnote>
461
462 <para>
463 Initial support for VMDK was added with VirtualBox 1.4.
464 Since version 2.1, VirtualBox supports VMDK fully, meaning
465 that you can create snapshots and use all the other
466 advanced features described above for VDI images with VMDK
467 also.
468 </para>
469
470 </footnote>
471 </para>
472 </listitem>
473
474 <listitem>
475 <para>
476 <emphasis role="bold">VHD.</emphasis> VirtualBox also fully
477 supports the VHD format used by Microsoft.
478 </para>
479 </listitem>
480
481 <listitem>
482 <para>
483 <emphasis role="bold">HDD.</emphasis> Image files of Parallels
484 version 2 (HDD format) are also supported.
485
486 <footnote>
487
488 <para>
489 Support was added with VirtualBox 3.1.
490 </para>
491
492 </footnote>
493
494 Due to lack of documentation of the format, newer versions
495 such as 3 and 4 are not supported. You can however convert
496 such image files to version 2 format using tools provided by
497 Parallels.
498 </para>
499 </listitem>
500
501 </itemizedlist>
502
503 <para>
504 Irrespective of the disk capacity and format, as mentioned in
505 <xref linkend="gui-createvm" />, there are two options for
506 creating a disk image: fixed-size or dynamically allocated.
507 </para>
508
509 <itemizedlist>
510
511 <listitem>
512 <para>
513 <emphasis role="bold">Fixed-size.</emphasis> If you create a
514 fixed-size image, an image file will be created on your host
515 system which has roughly the same size as the virtual disk's
516 capacity. So, for a 10 GB disk, you will have a 10 GB file.
517 Note that the creation of a fixed-size image can take a long
518 time depending on the size of the image and the write
519 performance of your hard disk.
520 </para>
521 </listitem>
522
523 <listitem>
524 <para>
525 <emphasis role="bold">Dynamically allocated.</emphasis> For
526 more flexible storage management, use a dynamically allocated
527 image. This will initially be very small and not occupy any
528 space for unused virtual disk sectors, but will grow every
529 time a disk sector is written to for the first time, until the
530 drive reaches the maximum capacity chosen when the drive was
531 created. While this format takes less space initially, the
532 fact that VirtualBox needs to expand the image file consumes
533 additional computing resources, so until the disk file size
534 has stabilized, write operations may be slower than with fixed
535 size disks. However, after a time the rate of growth will slow
536 and the average penalty for write operations will be
537 negligible.
538 </para>
539 </listitem>
540
541 </itemizedlist>
542
543 </sect1>
544
545 <sect1 id="vdis">
546
547 <title>The Virtual Media Manager</title>
548
549 <para>
550 VirtualBox keeps track of all the hard disk, CD/DVD-ROM, and
551 floppy disk images which are in use by virtual machines. These are
552 often referred to as <emphasis>known media</emphasis> and come
553 from two sources:
554 </para>
555
556 <itemizedlist>
557
558 <listitem>
559 <para>
560 All media currently attached to virtual machines.
561 </para>
562 </listitem>
563
564 <listitem>
565 <para>
566 Registered media, for compatibility with VirtualBox versions
567 older than version 4.0. For details about how media
568 registration has changed with version 4.0, see
569 <xref
570 linkend="vboxconfigdata" />.
571 </para>
572 </listitem>
573
574 </itemizedlist>
575
576 <para>
577 The known media can be viewed and changed in the
578 <emphasis
579 role="bold">Virtual Media Manager</emphasis>, which
580 you can access from the File menu in the VirtualBox main window.
581 </para>
582
583 <mediaobject>
584 <imageobject>
585 <imagedata align="center" fileref="images/virtual-disk-manager.png"
586 width="12cm" />
587 </imageobject>
588 </mediaobject>
589
590 <para>
591 The known media are conveniently grouped in separate tabs for the
592 three possible formats. These formats are:
593 </para>
594
595 <itemizedlist>
596
597 <listitem>
598 <para>
599 Hard disk images, either in VirtualBox's own Virtual Disk
600 Image (VDI) format, or in the third-party formats listed in
601 <xref linkend="vdidetails"/>.
602 </para>
603 </listitem>
604
605 <listitem>
606 <para>
607 CD/DVD images in standard ISO format.
608 </para>
609 </listitem>
610
611 <listitem>
612 <para>
613 Floppy images in standard RAW format.
614 </para>
615 </listitem>
616
617 </itemizedlist>
618
619 <para>
620 For each image, the Virtual Media Manager shows you the full path
621 of the image file and other information, such as the virtual
622 machine the image is currently attached to, if any.
623 </para>
624
625 <para>
626 The Virtual Media Manager enables you to do the following:
627 </para>
628
629 <itemizedlist>
630
631 <listitem>
632 <para>
633 <emphasis role="bold">Remove</emphasis> an image from the
634 registry. You can optionally delete the image file when doing
635 so.
636 </para>
637 </listitem>
638
639 <listitem>
640 <para>
641 <emphasis role="bold">Release</emphasis> an image. Detach it
642 from a virtual machine, if it is currently attached to one as
643 a virtual hard disk.
644 </para>
645 </listitem>
646
647 <listitem>
648 <para>
649 <emphasis role="bold">Copy</emphasis> a virtual hard disk, to
650 create another one. The target type can be different.
651 Available options are: VDI, VHD, or VMDK.
652 </para>
653 </listitem>
654
655 <listitem>
656 <para>
657 <emphasis role="bold">Modify</emphasis> the attributes of the
658 disk image file. Available options are: Normal, Immutable,
659 Writethrough, Shareable, Multi-attach.
660 </para>
661 </listitem>
662
663 <listitem>
664 <para>
665 <emphasis role="bold">Refresh</emphasis> the values for the
666 displayed attributes of the currently-selected disk image.
667 </para>
668 </listitem>
669
670 </itemizedlist>
671
672 <para>
673 These commands are accessible once a medium has been selected
674 either by selecting from the options shown at the top of the
675 window, or by right-clicking the medium and selecting from the
676 options shown on the drop-down menu.
677 </para>
678
679 <para>
680 Starting with version 4.0, to create a new disk image, you use the
681 Storage page in a virtual machine's settings dialog. This is
682 because disk images are now by default stored in each machine's
683 own folder.
684 </para>
685
686 <para>
687 Hard disk image files can be copied to other host systems and
688 imported into virtual machines there, although certain guest
689 systems, notably Windows 2000 and XP, will require that the new
690 virtual machine be set up in a similar way to the old one.
691 </para>
692
693 <note>
694 <para>
695 Do not simply make copies of virtual disk images. If you import
696 such a second copy into a virtual machine, VirtualBox will
697 complain with an error, since VirtualBox assigns a unique
698 identifier (UUID) to each disk image to make sure it is only
699 used once. See <xref
700 linkend="cloningvdis" />. Also, if
701 you want to copy a virtual machine to another system, VirtualBox
702 has an import/export facility that might be better suited for
703 your needs. See <xref linkend="ovf" />.
704 </para>
705 </note>
706
707 </sect1>
708
709 <sect1 id="hdimagewrites">
710
711 <title>Special Image Write Modes</title>
712
713 <para>
714 For each virtual disk image supported by VirtualBox, you can
715 determine separately how it should be affected by write operations
716 from a virtual machine and snapshot operations. This applies to
717 all of the aforementioned image formats (VDI, VMDK, VHD, or HDD)
718 and irrespective of whether an image is fixed-size or dynamically
719 allocated.
720 </para>
721
722 <para>
723 By default, images are in <emphasis>normal</emphasis> mode. To
724 mark an existing image with one of the non-standard modes listed
725 below, use <computeroutput>VBoxManage modifyhd</computeroutput>.
726 See <xref
727 linkend="vboxmanage-modifyvdi" />. Alternatively,
728 use VBoxManage to attach the image to a VM and use the
729 <computeroutput>--mtype</computeroutput> argument. See
730 <xref linkend="vboxmanage-storageattach" />.
731 </para>
732
733 <para>
734 The available virtual disk image modes are as follows:
735 </para>
736
737 <itemizedlist>
738
739 <listitem>
740 <para>
741 <emphasis role="bold">Normal images</emphasis> have no
742 restrictions on how guests can read from and write to the
743 disk. This is the default image mode.
744 </para>
745
746 <para>
747 When you take a snapshot of your virtual machine as described
748 in <xref linkend="snapshots" />, the state of a normal hard
749 disk is recorded together with the snapshot, and when
750 reverting to the snapshot, its state will be fully reset.
751 </para>
752
753 <para>
754 The image file itself is not reset. Instead, when a snapshot
755 is taken, VirtualBox "freezes" the image file and no longer
756 writes to it. For the write operations from the VM, a second,
757 <emphasis>differencing</emphasis> image file is created which
758 receives only the changes to the original image. See
759 <xref linkend="diffimages"/>.
760 </para>
761
762 <para>
763 While you can attach the same normal image to more than one
764 virtual machine, only one of these virtual machines attached
765 to the same image file can be executed simultaneously, as
766 otherwise there would be conflicts if several machines write
767 to the same image file.
768
769 <footnote>
770
771 <para>
772 This restriction is more lenient now than it was before
773 VirtualBox 2.2. Previously, each normal disk image could
774 only be <emphasis>attached</emphasis> to one single
775 machine. Now it can be attached to more than one machine
776 so long as only one of these machines is running.
777 </para>
778
779 </footnote>
780 </para>
781 </listitem>
782
783 <listitem>
784 <para>
785 <emphasis role="bold">Write-through hard disks</emphasis> are
786 completely unaffected by snapshots. Their state is
787 <emphasis>not</emphasis> saved when a snapshot is taken, and
788 not restored when a snapshot is restored.
789 </para>
790 </listitem>
791
792 <listitem>
793 <para>
794 <emphasis role="bold">Shareable hard disks</emphasis> are a
795 variant of write-through hard disks. In principle they behave
796 exactly the same. Their state is <emphasis>not</emphasis>
797 saved when a snapshot is taken, and not restored when a
798 snapshot is restored. The difference only shows if you attach
799 such disks to several VMs. Shareable disks may be attached to
800 several VMs which may run concurrently. This makes them
801 suitable for use by cluster filesystems between VMs and
802 similar applications which are explicitly prepared to access a
803 disk concurrently. Only fixed size images can be used in this
804 way, and dynamically allocated images are rejected.
805
806 <warning>
807 <para>
808 This is an expert feature, and misuse can lead to data
809 loss, as regular filesystems are not prepared to handle
810 simultaneous changes by several parties.
811 </para>
812 </warning>
813 </para>
814 </listitem>
815
816 <listitem>
817 <para>
818 <emphasis role="bold">Immutable images</emphasis> only
819 remember write accesses temporarily while the virtual machine
820 is running. All changes are lost when the virtual machine is
821 powered on the next time. As a result, as opposed to Normal
822 images, the same immutable image can be used with several
823 virtual machines without restrictions.
824 </para>
825
826 <para>
827 Creating an immutable image makes little sense since it would
828 be initially empty and lose its contents with every machine
829 restart. You would have a disk that is always unformatted when
830 the machine starts up. Instead, you can first create a normal
831 image and then later mark it as immutable when you decide that
832 the contents are useful.
833 </para>
834
835 <para>
836 If you take a snapshot of a machine with immutable images,
837 then on every machine power-up, those images are reset to the
838 state of the last (current) snapshot, instead of the state of
839 the original immutable image.
840 </para>
841
842 <note>
843 <para>
844 As a special exception, immutable images are
845 <emphasis>not</emphasis> reset if they are attached to a
846 machine in a saved state or whose last snapshot was taken
847 while the machine was running. This is called an
848 <emphasis>online snapshot</emphasis>. As a result, if the
849 machine's current snapshot is an online snapshot, its
850 immutable images behave exactly like the a normal image. To
851 reenable the automatic resetting of such images, delete the
852 current snapshot of the machine.
853 </para>
854 </note>
855
856 <para>
857 VirtualBox never writes to an immutable image directly at all.
858 All write operations from the machine are directed to a
859 differencing image. The next time the VM is powered on, the
860 differencing image is reset so that every time the VM starts,
861 its immutable images have exactly the same content.
862
863 <footnote>
864
865 <para>
866 This behavior also changed with VirtualBox 2.2.
867 Previously, the differencing images were discarded when
868 the machine session <emphasis>ended</emphasis>; now they
869 are discarded every time the machine is powered on.
870 </para>
871
872 </footnote>
873
874 The differencing image is only reset when the machine is
875 powered on from within VirtualBox, not when you reboot by
876 requesting a reboot from within the machine. This is also why
877 immutable images behave as described above when snapshots are
878 also present, which use differencing images as well.
879 </para>
880
881 <para>
882 If the automatic discarding of the differencing image on VM
883 startup does not fit your needs, you can turn it off using the
884 <computeroutput>autoreset</computeroutput> parameter of
885 <computeroutput>VBoxManage modifyhd</computeroutput>. See
886 <xref
887 linkend="vboxmanage-modifyvdi"/>.
888 </para>
889 </listitem>
890
891 <listitem>
892 <para>
893 <emphasis role="bold">Multiattach mode images</emphasis> can
894 be attached to more than one virtual machine at the same time,
895 even if these machines are running simultaneously. For each
896 virtual machine to which such an image is attached, a
897 differencing image is created. As a result, data that is
898 written to such a virtual disk by one machine is not seen by
899 the other machines to which the image is attached. Each
900 machine creates its own write history of the multiattach
901 image.
902 </para>
903
904 <para>
905 Technically, a multiattach image behaves identically to an
906 immutable image except the differencing image is not reset
907 every time the machine starts.
908 </para>
909
910 <para>
911 This mode is useful for sharing files which are almost never
912 written, for instance picture galleries, where every guest
913 changes only a small amount of data and the majority of the
914 disk content remains unchanged. The modified blocks are stored
915 in differencing images which remain relatively small and the
916 shared content is stored only once at the host.
917 </para>
918 </listitem>
919
920 <listitem>
921 <para>
922 <emphasis role="bold">Read-only images</emphasis> are used
923 automatically for CD/DVD images, since CDs/DVDs can never be
924 written to.
925 </para>
926 </listitem>
927
928 </itemizedlist>
929
930 <para>
931 The following scenario illustrates the differences between the
932 various image modes, with respect to snapshots.
933 </para>
934
935 <para>
936 Assume you have installed your guest operating system in your VM,
937 and you have taken a snapshot. Later, your VM is infected with a
938 virus and you would like to go back to the snapshot. With a normal
939 hard disk image, you simply restore the snapshot, and the earlier
940 state of your hard disk image will be restored as well and your
941 virus infection will be undone. With an immutable hard disk, all
942 it takes is to shut down and power on your VM, and the virus
943 infection will be discarded. With a write-through image however,
944 you cannot easily undo the virus infection by means of
945 virtualization, but will have to disinfect your virtual machine
946 like a real computer.
947 </para>
948
949 <para>
950 You might find write-through images useful if you want to preserve
951 critical data irrespective of snapshots. As you can attach more
952 than one image to a VM, you may want to have one immutable image
953 for the operating system and one write-through image for your data
954 files.
955 </para>
956
957 </sect1>
958
959 <sect1 id="diffimages">
960
961 <title>Differencing Images</title>
962
963 <para>
964 The previous section mentioned differencing images and how they
965 are used with snapshots, immutable images, and multiple disk
966 attachments. This section describes in more detail how
967 differencing images work.
968 </para>
969
970 <para>
971 A differencing image is a special disk image that only holds the
972 differences to another image. A differencing image by itself is
973 useless, it must always refer to another image. The differencing
974 image is then typically referred to as a
975 <emphasis>child</emphasis>, which holds the differences to its
976 <emphasis>parent</emphasis>.
977 </para>
978
979 <para>
980 When a differencing image is active, it receives all write
981 operations from the virtual machine instead of its parent. The
982 differencing image only contains the sectors of the virtual hard
983 disk that have changed since the differencing image was created.
984 When the machine reads a sector from such a virtual hard disk, it
985 looks into the differencing image first. If the sector is present,
986 it is returned from there. If not, VirtualBox looks into the
987 parent. In other words, the parent becomes
988 <emphasis>read-only</emphasis>. It is never written to again, but
989 it is read from if a sector has not changed.
990 </para>
991
992 <para>
993 Differencing images can be chained. If another differencing image
994 is created for a virtual disk that already has a differencing
995 image, then it becomes a <emphasis>grandchild</emphasis> of the
996 original parent. The first differencing image then becomes
997 read-only as well, and write operations only go to the
998 second-level differencing image. When reading from the virtual
999 disk, VirtualBox needs to look into the second differencing image
1000 first, then into the first if the sector was not found, and then
1001 into the original image.
1002 </para>
1003
1004 <para>
1005 There can be an unlimited number of differencing images, and each
1006 image can have more than one child. As a result, the differencing
1007 images can form a complex tree with parents, siblings, and
1008 children, depending on how complex your machine configuration is.
1009 Write operations always go to the one <emphasis>active</emphasis>
1010 differencing image that is attached to the machine, and for read
1011 operations, VirtualBox may need to look up all the parents in the
1012 chain until the sector in question is found. You can view such a
1013 tree in the Virtual Media Manager:
1014 </para>
1015
1016 <mediaobject>
1017 <imageobject>
1018 <imagedata align="center" fileref="images/virtual-disk-manager2.png"
1019 width="12cm" />
1020 </imageobject>
1021 </mediaobject>
1022
1023 <para>
1024 In all of these situations, from the point of view of the virtual
1025 machine, the virtual hard disk behaves like any other disk. While
1026 the virtual machine is running, there is a slight run-time I/O
1027 overhead because VirtualBox might need to look up sectors several
1028 times. This is not noticeable however since the tables with sector
1029 information are always kept in memory and can be looked up
1030 quickly.
1031 </para>
1032
1033 <para>
1034 Differencing images are used in the following situations:
1035 </para>
1036
1037 <itemizedlist>
1038
1039 <listitem>
1040 <para>
1041 <emphasis role="bold">Snapshots.</emphasis> When you create a
1042 snapshot, as explained in the previous section, VirtualBox
1043 "freezes" the images attached to the virtual machine and
1044 creates differencing images for each image that is not in
1045 "write-through" mode. From the point of view of the virtual
1046 machine, the virtual disks continue to operate before, but all
1047 write operations go into the differencing images. Each time
1048 you create another snapshot, for each hard disk attachment,
1049 another differencing image is created and attached, forming a
1050 chain or tree.
1051 </para>
1052
1053 <para>
1054 In the above screenshot, you see that the original disk image
1055 is now attached to a snapshot, representing the state of the
1056 disk when the snapshot was taken.
1057 </para>
1058
1059 <para>
1060 If you <emphasis>restore</emphasis> a snapshot, and want to go
1061 back to the exact machine state that was stored in the
1062 snapshot, the following happens:
1063 </para>
1064
1065 <orderedlist>
1066
1067 <listitem>
1068 <para>
1069 VirtualBox copies the virtual machine settings that were
1070 copied into the snapshot back to the virtual machine. As a
1071 result, if you have made changes to the machine
1072 configuration since taking the snapshot, they are undone.
1073 </para>
1074 </listitem>
1075
1076 <listitem>
1077 <para>
1078 If the snapshot was taken while the machine was running,
1079 it contains a saved machine state, and that state is
1080 restored as well. After restoring the snapshot, the
1081 machine will then be in Saved state and resume execution
1082 from there when it is next started. Otherwise the machine
1083 will be in Powered Off state and do a full boot.
1084 </para>
1085 </listitem>
1086
1087 <listitem>
1088 <para>
1089 For each disk image attached to the machine, the
1090 differencing image holding all the write operations since
1091 the current snapshot was taken is thrown away, and the
1092 original parent image is made active again. If you
1093 restored the root snapshot, then this will be the root
1094 disk image for each attachment. Otherwise, some other
1095 differencing image descended from it. This effectively
1096 restores the old machine state.
1097 </para>
1098 </listitem>
1099
1100 </orderedlist>
1101
1102 <para>
1103 If you later <emphasis>delete</emphasis> a snapshot in order
1104 to free disk space, for each disk attachment, one of the
1105 differencing images becomes obsolete. In this case, the
1106 differencing image of the disk attachment cannot simply be
1107 deleted. Instead, VirtualBox needs to look at each sector of
1108 the differencing image and needs to copy it back into its
1109 parent. This is called "merging" images and can be a
1110 potentially lengthy process, depending on how large the
1111 differencing image is. It can also temporarily need a
1112 considerable amount of extra disk space, before the
1113 differencing image obsoleted by the merge operation is
1114 deleted.
1115 </para>
1116 </listitem>
1117
1118 <listitem>
1119 <para>
1120 <emphasis role="bold">Immutable images.</emphasis> When an
1121 image is switched to immutable mode, a differencing image is
1122 created as well. As with snapshots, the parent image then
1123 becomes read-only, and the differencing image receives all the
1124 write operations. Every time the virtual machine is started,
1125 all the immutable images which are attached to it have their
1126 respective differencing image thrown away, effectively
1127 resetting the virtual machine's virtual disk with every
1128 restart.
1129 </para>
1130 </listitem>
1131
1132 </itemizedlist>
1133
1134 </sect1>
1135
1136 <sect1 id="cloningvdis">
1137
1138 <title>Cloning Disk Images</title>
1139
1140 <para>
1141 You can duplicate hard disk image files on the same host to
1142 quickly produce a second virtual machine with the same operating
1143 system setup. However, you should <emphasis>only</emphasis> make
1144 copies of virtual disk images using the utility supplied with
1145 VirtualBox. See <xref
1146 linkend="vboxmanage-clonevdi" />. This
1147 is because VirtualBox assigns a unique identity number (UUID) to
1148 each disk image, which is also stored inside the image, and
1149 VirtualBox will refuse to work with two images that use the same
1150 number. If you do accidentally try to reimport a disk image which
1151 you copied normally, you can make a second copy using VirtualBox's
1152 utility and import that instead.
1153 </para>
1154
1155 <para>
1156 Note that newer Linux distributions identify the boot hard disk
1157 from the ID of the drive. The ID VirtualBox reports for a drive is
1158 determined from the UUID of the virtual disk image. So if you
1159 clone a disk image and try to boot the copied image the guest
1160 might not be able to determine its own boot disk as the UUID
1161 changed. In this case you have to adapt the disk ID in your boot
1162 loader script, for example
1163 <computeroutput>/boot/grub/menu.lst</computeroutput>. The disk ID
1164 looks like this:
1165 </para>
1166
1167<screen>scsi-SATA_VBOX_HARDDISK_VB5cfdb1e2-c251e503</screen>
1168
1169 <para>
1170 The ID for the copied image can be determined with:
1171 </para>
1172
1173<screen>hdparm -i /dev/sda</screen>
1174
1175 </sect1>
1176
1177 <sect1 id="iocaching">
1178
1179 <title>Host I/O Caching</title>
1180
1181 <para>
1182 Starting with version 3.2, VirtualBox can optionally disable the
1183 I/O caching that the host operating system would otherwise perform
1184 on disk image files.
1185 </para>
1186
1187 <para>
1188 Traditionally, VirtualBox has opened disk image files as normal
1189 files, which results in them being cached by the host operating
1190 system like any other file. The main advantage of this is speed:
1191 when the guest OS writes to disk and the host OS cache uses
1192 delayed writing, the write operation can be reported as completed
1193 to the guest OS quickly while the host OS can perform the
1194 operation asynchronously. Also, when you start a VM a second time
1195 and have enough memory available for the OS to use for caching,
1196 large parts of the virtual disk may be in system memory, and the
1197 VM can access the data much faster.
1198 </para>
1199
1200 <para>
1201 Note that this applies only to image files. Buffering does not
1202 occur for virtual disks residing on remote iSCSI storage, which is
1203 the more common scenario in enterprise-class setups. See
1204 <xref
1205 linkend="storage-iscsi" />.
1206 </para>
1207
1208 <para>
1209 While buffering is a useful default setting for virtualizing a few
1210 machines on a desktop computer, there are some disadvantages to
1211 this approach:
1212 </para>
1213
1214 <itemizedlist>
1215
1216 <listitem>
1217 <para>
1218 Delayed writing through the host OS cache is less secure. When
1219 the guest OS writes data, it considers the data written even
1220 though it has not yet arrived on a physical disk. If for some
1221 reason the write does not happen, such as power failure or
1222 host crash, the likelihood of data loss increases.
1223 </para>
1224 </listitem>
1225
1226 <listitem>
1227 <para>
1228 Disk image files tend to be very large. Caching them can
1229 therefore quickly use up the entire host OS cache. Depending
1230 on the efficiency of the host OS caching, this may slow down
1231 the host immensely, especially if several VMs run at the same
1232 time. For example, on Linux hosts, host caching may result in
1233 Linux delaying all writes until the host cache is nearly full
1234 and then writing out all these changes at once, possibly
1235 stalling VM execution for minutes. This can result in I/O
1236 errors in the guest as I/O requests time out there.
1237 </para>
1238 </listitem>
1239
1240 <listitem>
1241 <para>
1242 Physical memory is often wasted as guest operating systems
1243 typically have their own I/O caches, which may result in the
1244 data being cached twice, in both the guest and the host
1245 caches, for little effect.
1246 </para>
1247 </listitem>
1248
1249 </itemizedlist>
1250
1251 <para>
1252 If you decide to disable host I/O caching for the above reasons,
1253 VirtualBox uses its own small cache to buffer writes, but no read
1254 caching since this is typically already performed by the guest OS.
1255 In addition, VirtualBox fully supports asynchronous I/O for its
1256 virtual SATA, SCSI and SAS controllers through multiple I/O
1257 threads.
1258 </para>
1259
1260 <para>
1261 Since asynchronous I/O is not supported by IDE controllers, for
1262 performance reasons, you may want to leave host caching enabled
1263 for your VM's virtual IDE controllers.
1264 </para>
1265
1266 <para>
1267 For this reason, VirtualBox allows you to configure whether the
1268 host I/O cache is used for each I/O controller separately. Either
1269 select the <emphasis role="bold">Use Host I/O Cache</emphasis>
1270 check box in the Storage settings for a given virtual storage
1271 controller, or use the following VBoxManage command to disable the
1272 host I/O cache for a virtual storage controller:
1273 </para>
1274
1275<screen>VBoxManage storagectl "VM name" --name &lt;controllername&gt; --hostiocache off</screen>
1276
1277 <para>
1278 See <xref linkend="vboxmanage-storagectl" />.
1279 </para>
1280
1281 <para>
1282 For the above reasons, VirtualBox now uses SATA controllers by
1283 default for new virtual machines.
1284 </para>
1285
1286 </sect1>
1287
1288 <sect1 id="storage-bandwidth-limit">
1289
1290 <title>Limiting Bandwidth for Disk Images</title>
1291
1292 <para>
1293 Starting with version 4.0, VirtualBox allows for limiting the
1294 maximum bandwidth used for asynchronous I/O. Additionally it
1295 supports sharing limits through bandwidth groups for several
1296 images. It is possible to have more than one such limit.
1297 </para>
1298
1299 <para>
1300 Limits are configured using
1301 <computeroutput>VBoxManage</computeroutput>. The example below
1302 creates a bandwidth group named Limit, sets the limit to 20 MB per
1303 second, and assigns the group to the attached disks of the VM:
1304 </para>
1305
1306<screen>VBoxManage bandwidthctl "VM name" add Limit --type disk --limit 20M
1307VBoxManage storageattach "VM name" --storagectl "SATA" --port 0 --device 0 --type hdd
1308 --medium disk1.vdi --bandwidthgroup Limit
1309VBoxManage storageattach "VM name" --storagectl "SATA" --port 1 --device 0 --type hdd
1310 --medium disk2.vdi --bandwidthgroup Limit</screen>
1311
1312 <para>
1313 All disks in a group share the bandwidth limit, meaning that in
1314 the example above the bandwidth of both images combined can never
1315 exceed 20 MBps. However, if one disk does not require bandwidth
1316 the other can use the remaining bandwidth of its group.
1317 </para>
1318
1319 <para>
1320 The limits for each group can be changed while the VM is running,
1321 with changes being picked up immediately. The example below
1322 changes the limit for the group created in the example above to 10
1323 MBps:
1324 </para>
1325
1326<screen>VBoxManage bandwidthctl "VM name" set Limit --limit 10M</screen>
1327
1328 </sect1>
1329
1330 <sect1 id="storage-cds">
1331
1332 <title>CD/DVD Support</title>
1333
1334 <para>
1335 Virtual CD/DVD drives by default support only reading. The medium
1336 configuration is changeable at runtime. You can select between the
1337 following options to provide the medium data:
1338 </para>
1339
1340 <itemizedlist>
1341
1342 <listitem>
1343 <para>
1344 <emphasis role="bold">Host Drive</emphasis> defines that the
1345 guest can read from the medium in the host drive.
1346 </para>
1347 </listitem>
1348
1349 <listitem>
1350 <para>
1351 <emphasis role="bold">Image file</emphasis> gives the guest
1352 read-only access to the data in the image. This is typically
1353 an ISO file.
1354 </para>
1355 </listitem>
1356
1357 <listitem>
1358 <para>
1359 <emphasis role="bold">Empty</emphasis> means a drive without
1360 an inserted medium.
1361 </para>
1362 </listitem>
1363
1364 </itemizedlist>
1365
1366 <para>
1367 Changing between the above, or changing a medium in the host drive
1368 that is accessed by a machine, or changing an image file will
1369 signal a medium change to the guest operating system. The guest OS
1370 can then react to the change, for example by starting an
1371 installation program.
1372 </para>
1373
1374 <para>
1375 Medium changes can be prevented by the guest, and VirtualBox
1376 reflects that by locking the host drive if appropriate. You can
1377 force a medium removal in such situations via the VirtualBox GUI
1378 or the VBoxManage command line tool. Effectively this is the
1379 equivalent of the emergency eject which many CD/DVD drives
1380 provide, with all associated side effects. The guest OS can issue
1381 error messages, just like on real hardware, and guest applications
1382 may misbehave. Use this with caution.
1383 </para>
1384
1385 <note>
1386 <para>
1387 The identification string of the drive provided to the guest,
1388 displayed by configuration tools such as the Windows Device
1389 Manager, is always VBOX CD-ROM, irrespective of the current
1390 configuration of the virtual drive. This is to prevent hardware
1391 detection from being triggered in the guest operating system
1392 every time the configuration is changed.
1393 </para>
1394 </note>
1395
1396 <para>
1397 The standard CD/DVD emulation allows for reading standard data CD
1398 and DVD formats only. As an experimental feature, for additional
1399 capabilities, it is possible to give the guest direct access to
1400 the CD/DVD host drive by enabling <emphasis>passthrough</emphasis>
1401 mode. Depending on the host hardware, this may potentially enable
1402 the following things to work:
1403 </para>
1404
1405 <itemizedlist>
1406
1407 <listitem>
1408 <para>
1409 CD/DVD writing from within the guest, if the host DVD drive is
1410 a CD/DVD writer
1411 </para>
1412 </listitem>
1413
1414 <listitem>
1415 <para>
1416 Playing audio CDs
1417 </para>
1418 </listitem>
1419
1420 <listitem>
1421 <para>
1422 Playing encrypted DVDs
1423 </para>
1424 </listitem>
1425
1426 </itemizedlist>
1427
1428 <para>
1429 There is a Passthrough check box in the GUI dialog for configuring
1430 the media attached to a storage controller, or you can use the
1431 <computeroutput>--passthrough</computeroutput> option with
1432 <computeroutput>VBoxManage storageattach</computeroutput>. See
1433 <xref
1434 linkend="vboxmanage-storageattach" />.
1435 </para>
1436
1437 <para>
1438 Even if passthrough is enabled, unsafe commands, such as updating
1439 the drive firmware, will be blocked. Video CD formats are never
1440 supported, not even in passthrough mode, and cannot be played from
1441 a virtual machine.
1442 </para>
1443
1444 <para>
1445 On Solaris hosts, passthrough requires running VirtualBox with
1446 real root permissions due to security measures enforced by the
1447 host.
1448 </para>
1449
1450 </sect1>
1451
1452 <sect1 id="storage-iscsi">
1453
1454 <title>iSCSI Servers</title>
1455
1456 <para>
1457 iSCSI stands for "Internet SCSI" and is a standard that allows for
1458 using the SCSI protocol over Internet (TCP/IP) connections.
1459 Especially with the advent of Gigabit Ethernet, it has become
1460 affordable to attach iSCSI storage servers simply as remote hard
1461 disks to a computer network. In iSCSI terminology, the server
1462 providing storage resources is called an <emphasis>iSCSI
1463 target</emphasis>, while the client connecting to the server and
1464 accessing its resources is called an <emphasis>iSCSI
1465 initiator</emphasis>.
1466 </para>
1467
1468 <para>
1469 VirtualBox can transparently present iSCSI remote storage to a
1470 virtual machine as a virtual hard disk. The guest operating system
1471 will not see any difference between a virtual disk image (VDI
1472 file) and an iSCSI target. To achieve this, VirtualBox has an
1473 integrated iSCSI initiator.
1474 </para>
1475
1476 <para>
1477 VirtualBox's iSCSI support has been developed according to the
1478 iSCSI standard and should work with all standard-conforming iSCSI
1479 targets. To use an iSCSI target with VirtualBox, you must use the
1480 command line. See <xref linkend="vboxmanage-storageattach" />.
1481 </para>
1482
1483 </sect1>
1484
1485</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