VirtualBox

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

最後變更 在這個檔案從62639是 61818,由 vboxsync 提交於 8 年 前

bugref:6417 docs - sort compilation issue.

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

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