VirtualBox

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

最後變更 在這個檔案從76553是 76078,由 vboxsync 提交於 6 年 前

manual: integrate drop #30 with minimal manual adjustments (but everything into one book, with manually applied tweaks to turn the release notes into a pure changelog again and manually re-applied the last changelog change since it wasn't included yet)

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

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