VirtualBox

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

Last change on this file since 32363 was 32331, checked in by vboxsync, 14 years ago

doc/manual: cosmetical fixes

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

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