VirtualBox

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

最後變更 在這個檔案從47991是 46207,由 vboxsync 提交於 12 年 前

doc/manual: Move all id=... attributes from the title tags up one level, as otherwise the DocBook converters create inconsistent HTML filesi with lots of dangling links. The LaTeX converter now acts as a guard dog against reintroducing such bugs, it will take those attributes only from the correct tag and incorrect attribute use will thus lead to "undefined references" when creating the PDF manual.

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

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