Difference between revisions of "Understanding and Configuring VirtualBox Virtual Hard Disks"

From Virtuatopia
Jump to: navigation, search
Line 1: Line 1:
Most operating systems require access to some form of storage space, typically in the form of a disk drive, to store operating system files, applications and user data. The guest operating systems supported by VirtualBox are no exception to this rule and to meet this requirement, VirtualBox provides a number of virtual hard disk drive configuration options, each of which is the topic of this chapter.
+
Most operating systems require access to some form of storage space, typically in the form of a disk drive, to store operating system files, applications and user data. The guest operating systems supported by VirtualBox are no exception to this rule. To meet this requirement, VirtualBox provides a number of virtual hard disk drive configuration options, each of which is the topic of this chapter.
  
 
== VirtualBox Virtual Hard Disk Controllers ==
 
== VirtualBox Virtual Hard Disk Controllers ==
  
VirtualBox provides access to storage by presenting virtual hard disk controllers to virtual machines. Although controllers are essentially software emulations of hard disk controllers, as far as the guest operating systems are concerned, these appear as real, physical devices. A number of different standards of disk controller have developed over the years and VirtualBox provides virtual versions of the following standards:
+
VirtualBox provides access to storage by presenting virtual hard disk controllers to virtual machines. Although these virtual controllers are essentially software emulations of physical hard disk controllers, as far as the guest operating systems are concerned, these appear as real, physical devices. A number of different standards of disk controller have developed over the years and VirtualBox provides virtual versions of the following standards:
  
* '''Serial ATA (SATA/AHCI)''' - The latest drive controller standard, SATA provides higher levels of storage access performance and, unlike the older IDE standard, does not impose restrictions on the number of devices that can be attached to a single disk controller. In addition, SATA is designed to allow disk drives to be added and removed without powering down the system. SATA disk controllers may be configured to run in IDE compatibility mode to allow access from guest operating systems lacking Advanced Host Controller Interface (AHCI) support.  VirtualBox allows up to 30 SATA ports to be configured per virtual machine. The first four of these are configured by default to operate in IDE compatibility mode. The SATA controller is disabled by default for new Virtual Box virtual machines. To enable the SATA controller, select the required virtual machine, click on ''Settings'' in the toolbar, select '' for the selected virtual machine, select ''Hard Disks'' from the list of categories and set the ''Enable SATA Controller'' check box. Finally, click ''OK'' to commit the change.
+
* '''Serial ATA (SATA/AHCI)''' - The latest drive controller standard, SATA provides higher levels of storage access performance and, unlike the older IDE standard, does not impose limited restrictions on the number of devices that can be attached to a single disk controller. In addition, SATA is designed to allow disk drives to be added and removed without powering down the system. SATA disk controllers may be configured to run in IDE compatibility mode to allow access from guest operating systems lacking Advanced Host Controller Interface (AHCI) support.  VirtualBox allows up to 30 SATA ports to be configured per virtual machine. The first four of these SATA ports are configured by default to operate in IDE compatibility mode. The SATA controller is disabled by default for new VirtualBox virtual machines. To enable the SATA controller, select the required virtual machine, click on ''Settings'' in the toolbar, select ''Hard Disks'' from the list of categories and set the ''Enable SATA Controller'' check box. Finally, click ''OK'' to commit the change.
  
* '''Integrated Drive Electronics (IDE)''' - Perhaps the most widely used disk controller standard, these controllers are now being replaced in favor of the SATA standard. The VirtualBox virtual IDE disk controller allows up to four storage devices to be connected to a virtual machine using the ''Primary Master'', ''Primary Slave'', ''Secondary Master'' and ''Secondary Slave'' slots. The ''Secondary Master'' connection is reserved for CD/DVD devices, allowing for the attachment of three virtual hard disks to the controller. If additional disks are required, it will be necessary to enable the VirtualBox SATA controller for the virtual machine as outlined above.
+
* '''Integrated Drive Electronics (IDE)''' - Perhaps the most widely used disk controller standard, IDE controllers are now being replaced in favor of the SATA standard. The VirtualBox virtual IDE disk controller allows up to four storage devices to be connected to a virtual machine using the ''Primary Master'', ''Primary Slave'', ''Secondary Master'' and ''Secondary Slave'' slots. The ''Secondary Master'' connection is reserved for CD/DVD devices, allowing for the attachment of three virtual hard disks to the controller. If additional IDE disks are required, it will be necessary to enable the VirtualBox SATA controller for the virtual machine as outlined above and use the SATA IDE compatibility mode.
  
 
* '''Small Computer System Interface (SCSI)''' - A popular storage connection standard, SCSI is based on a bus topology allowing up to 16 stroage devices to be connected to a disk controller in a daisy chain configuration. Each device is assigned a unique SCSI identifier to distinguish it from other devices on the SCSI bus. VirtualBox provides emulation for BusLogic and LsiLogic 53c1030 SCSI disk controllers. SCSI virtual disk controller support is currently categorized as ''experimental'' in VirtualBox 2.1.
 
* '''Small Computer System Interface (SCSI)''' - A popular storage connection standard, SCSI is based on a bus topology allowing up to 16 stroage devices to be connected to a disk controller in a daisy chain configuration. Each device is assigned a unique SCSI identifier to distinguish it from other devices on the SCSI bus. VirtualBox provides emulation for BusLogic and LsiLogic 53c1030 SCSI disk controllers. SCSI virtual disk controller support is currently categorized as ''experimental'' in VirtualBox 2.1.
Line 13: Line 13:
 
== Virtual Disk Images and Types ==
 
== Virtual Disk Images and Types ==
  
The most common method for providing disk storage to virtual machines is through the use of virtual disk image files. A virtual disk image file is nothing more than a file residing on the file system of the host which is treated by a virtual disk controller in the same way as a physical disk drive is used. The guest operating system interacts with this image through a virtual disk controller and is completely unaware of the fact that what it thinks is a physical hard disk drive is actually a file.
+
The most common method for providing disk storage to virtual machines is through the use of virtual disk image files. A virtual disk image file is nothing more than a file residing on the file system of the host that is treated by a virtual disk controller in the same way as a physical disk drive is used. The guest operating system interacts with this image through a virtual disk controller and is completely unaware of the fact that what it thinks is a physical hard disk drive is actually a file.
  
 
Virtual disk images can be created as either ''fixed-size'' or ''dynamically expanding'':
 
Virtual disk images can be created as either ''fixed-size'' or ''dynamically expanding'':
Line 29: Line 29:
 
* '''Normal''' - This is the default setting for newly created disk images. Any data read or write operations performed on the disk image by the guest operating system are performed on the disk image itself. As such, a normal disk may only be associated with one running virtual machine at any one time. In addition, any changes to the data on the disk are remain after the guest system is powered off.
 
* '''Normal''' - This is the default setting for newly created disk images. Any data read or write operations performed on the disk image by the guest operating system are performed on the disk image itself. As such, a normal disk may only be associated with one running virtual machine at any one time. In addition, any changes to the data on the disk are remain after the guest system is powered off.
  
* '''Immutable''' - When a virtual disk image is configured as immutable, the contents of the disk are read-only. Any data written by a guest operating system to an immutable disk are stored in a separate ''differencing'' disk image. When the virtual machine to which the disk image is powered of reset, the differencing disk and the contents therein are discarded, leaving the immutable disk unaltered. This approach allows multiple virtual machines to share the same disk image file, each being assigned its own differencing disk during run time.
+
* '''Immutable''' - When a virtual disk image is configured as immutable, the contents of the disk are read-only. Any data written by a guest operating system to an immutable disk are stored in a separate ''differencing'' disk image. When the virtual machine to which the disk image is attached is powered or reset, the differencing disk and the contents therein are discarded, leaving the immutable disk unaltered. This approach allows multiple virtual machines to share the same disk image file, each being assigned its own differencing disk during run time.
  
 
* '''Write-through''' - Write-through disk images allow read and write operations to be performed on the disk image. When the virtual machine is powered off or reset, however, the state of the disk image is not saved, thereby reverting to its original state next time the virtual machine starts.
 
* '''Write-through''' - Write-through disk images allow read and write operations to be performed on the disk image. When the virtual machine is powered off or reset, however, the state of the disk image is not saved, thereby reverting to its original state next time the virtual machine starts.
  
To convert an existing virtual disk image to immutable or write-through type it must first be detached from any virtual machines. This can achieved by selecting the virtual machine to which the disk is attached from the VirtualBox management interface and clicking on the ''File->Virtual Media Manager'' menu option. In the Media Manager dialog, select the disk to be modified and click on the ''Release'' toolbar button.  
+
To convert an existing virtual disk image to immutable or write-through type it must first be detached from any virtual machines. This can be achieved by selecting the virtual machine to which the disk is attached from the VirtualBox management interface and clicking on the ''File->Virtual Media Manager'' menu option. In the Media Manager dialog, select the disk to be modified and click on the ''Release'' toolbar button.  
  
 
Before changing the type of a virtual disk image, it is often useful to find out the current configuration settings. This can be achieved using VBoxManage command as follows:
 
Before changing the type of a virtual disk image, it is often useful to find out the current configuration settings. This can be achieved using VBoxManage command as follows:
Line 74: Line 74:
 
</pre>
 
</pre>
  
To convert an immutable or writethrough disk back to the normal type:
+
To convert an immutable or write-through disk back to the normal type:
  
 
<pre>
 
<pre>
Line 89: Line 89:
  
 
In addition to the standard Virtual Disk Image (VDI) format, VirtualBox is also able to support VMware's VMDK and Microsoft's VHD virtual hard disk formats. Virtual disk image files in either of these third party formats may be added to the VirtualBox media library using the ''Virtual Media Manager'' dialog (accessed via the ''File->Virtual Media Manager'' menu option) and subsequently attached to virtual machines.
 
In addition to the standard Virtual Disk Image (VDI) format, VirtualBox is also able to support VMware's VMDK and Microsoft's VHD virtual hard disk formats. Virtual disk image files in either of these third party formats may be added to the VirtualBox media library using the ''Virtual Media Manager'' dialog (accessed via the ''File->Virtual Media Manager'' menu option) and subsequently attached to virtual machines.
 +
 +
== Cloning a Virtual Disk Image ==
 +
 +
Virtual disk images may be cloned for use in other virtual machines using the VBoxManage command. If the disk image is in a format other than VirtualBox VDI format, the format should be specified when performing the clone operation. For example, to clone a VDI disk image named Ubuntu.vdi, naming the clone Ubuntu2.vdi, the following command is executed:
 +
 +
<pre>
 +
vboxmanage clonehd Ubuntu.vdi Ubuntu2.vdi -format VDI
 +
 +
VirtualBox Command Line Management Interface Version 2.1.4
 +
(C) 2005-2009 Sun Microsystems, Inc.
 +
All rights reserved.
 +
 +
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
 +
Clone hard disk created in format 'VDI'. UUID: 53deab63-0492-400b-9c8f-ad3ad3756f9d
 +
</pre>
 +
 +
Once the cloning process is complete (the exact duration of the process depends on the size of the original virtual disk), the cloned image will need to be added to the VirtualBox virtual media inventory using the Virtual Media Manager so that it is available for attachment to a virtual machine.

Revision as of 15:09, 25 March 2009

Most operating systems require access to some form of storage space, typically in the form of a disk drive, to store operating system files, applications and user data. The guest operating systems supported by VirtualBox are no exception to this rule. To meet this requirement, VirtualBox provides a number of virtual hard disk drive configuration options, each of which is the topic of this chapter.




VirtualBox Virtual Hard Disk Controllers

VirtualBox provides access to storage by presenting virtual hard disk controllers to virtual machines. Although these virtual controllers are essentially software emulations of physical hard disk controllers, as far as the guest operating systems are concerned, these appear as real, physical devices. A number of different standards of disk controller have developed over the years and VirtualBox provides virtual versions of the following standards:

  • Serial ATA (SATA/AHCI) - The latest drive controller standard, SATA provides higher levels of storage access performance and, unlike the older IDE standard, does not impose limited restrictions on the number of devices that can be attached to a single disk controller. In addition, SATA is designed to allow disk drives to be added and removed without powering down the system. SATA disk controllers may be configured to run in IDE compatibility mode to allow access from guest operating systems lacking Advanced Host Controller Interface (AHCI) support. VirtualBox allows up to 30 SATA ports to be configured per virtual machine. The first four of these SATA ports are configured by default to operate in IDE compatibility mode. The SATA controller is disabled by default for new VirtualBox virtual machines. To enable the SATA controller, select the required virtual machine, click on Settings in the toolbar, select Hard Disks from the list of categories and set the Enable SATA Controller check box. Finally, click OK to commit the change.
  • Integrated Drive Electronics (IDE) - Perhaps the most widely used disk controller standard, IDE controllers are now being replaced in favor of the SATA standard. The VirtualBox virtual IDE disk controller allows up to four storage devices to be connected to a virtual machine using the Primary Master, Primary Slave, Secondary Master and Secondary Slave slots. The Secondary Master connection is reserved for CD/DVD devices, allowing for the attachment of three virtual hard disks to the controller. If additional IDE disks are required, it will be necessary to enable the VirtualBox SATA controller for the virtual machine as outlined above and use the SATA IDE compatibility mode.
  • Small Computer System Interface (SCSI) - A popular storage connection standard, SCSI is based on a bus topology allowing up to 16 stroage devices to be connected to a disk controller in a daisy chain configuration. Each device is assigned a unique SCSI identifier to distinguish it from other devices on the SCSI bus. VirtualBox provides emulation for BusLogic and LsiLogic 53c1030 SCSI disk controllers. SCSI virtual disk controller support is currently categorized as experimental in VirtualBox 2.1.

Virtual Disk Images and Types

The most common method for providing disk storage to virtual machines is through the use of virtual disk image files. A virtual disk image file is nothing more than a file residing on the file system of the host that is treated by a virtual disk controller in the same way as a physical disk drive is used. The guest operating system interacts with this image through a virtual disk controller and is completely unaware of the fact that what it thinks is a physical hard disk drive is actually a file.

Virtual disk images can be created as either fixed-size or dynamically expanding:

  • Dynamically Expanding - The disk image file is created at a minimal size and then grows automatically as more space is needed by the guest operating system (up to a specified maximum). This has the advantage that disk space on the host is not used until it is needed, but can result in slower performance if the disk needs to be enlarged frequently.
  • Fixed-size - The disk image file is created to the specified size. This pre-allocates all the requested disk space regardless of whether it is immediately needed, but results in improved disk write performance.

The disk image type is specified during the virtual disk creation process, details of which are covered in the chapter entitled Creating and Managing VirtualBox Virtual Machines.

Normal, Immutable and Write-Through Disk Images

In addition to the option to make a virtual disk image size fixed or dynamic, three additional options are available in the form of immutable, normal and write-through settings, each of which is associated with the way in which data is written to the disk drive:

  • Normal - This is the default setting for newly created disk images. Any data read or write operations performed on the disk image by the guest operating system are performed on the disk image itself. As such, a normal disk may only be associated with one running virtual machine at any one time. In addition, any changes to the data on the disk are remain after the guest system is powered off.
  • Immutable - When a virtual disk image is configured as immutable, the contents of the disk are read-only. Any data written by a guest operating system to an immutable disk are stored in a separate differencing disk image. When the virtual machine to which the disk image is attached is powered or reset, the differencing disk and the contents therein are discarded, leaving the immutable disk unaltered. This approach allows multiple virtual machines to share the same disk image file, each being assigned its own differencing disk during run time.
  • Write-through - Write-through disk images allow read and write operations to be performed on the disk image. When the virtual machine is powered off or reset, however, the state of the disk image is not saved, thereby reverting to its original state next time the virtual machine starts.

To convert an existing virtual disk image to immutable or write-through type it must first be detached from any virtual machines. This can be achieved by selecting the virtual machine to which the disk is attached from the VirtualBox management interface and clicking on the File->Virtual Media Manager menu option. In the Media Manager dialog, select the disk to be modified and click on the Release toolbar button.

Before changing the type of a virtual disk image, it is often useful to find out the current configuration settings. This can be achieved using VBoxManage command as follows:

C:\Program Files\Sun\xVM VirtualBox>VBoxmanage showhdinfo Ubuntu.vdi
VirtualBox Command Line Management Interface Version 2.1.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

UUID:                 22ccb1e6-5b5f-4343-8788-f90ab19203a6
Accessible:           yes
Logical size:         11100 MBytes
Current size on disk: 4397 MBytes
Type:                 normal
Storage format:       VDI
Location:             C:\Users\nas\.VirtualBox\HardDisks\Ubuntu.vdi

Once the disk has been released from any virtual machines, use the VBoxManage command as follows to change the type to immutable:

VBoxmanage modifyhd <disk image>.vdi settype immutable

VirtualBox Command Line Management Interface Version 2.1.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

where <disk image> is the name of the image file to be modified.

A disk image may similarly be converted to write-through as follows:

VBoxmanage modifyhd <disk image>.vdi settype writethrough

VirtualBox Command Line Management Interface Version 2.1.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

To convert an immutable or write-through disk back to the normal type:

VBoxmanage modifyhd <disk image>.vdi settype normal

VirtualBox Command Line Management Interface Version 2.1.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Once the disk image type conversion is complete, re-attach the disk image to the virtual machine to which it belongs using the Settings screen in the VirtualBox GUI management interface.

Support for Third Party Disk Image Formats

In addition to the standard Virtual Disk Image (VDI) format, VirtualBox is also able to support VMware's VMDK and Microsoft's VHD virtual hard disk formats. Virtual disk image files in either of these third party formats may be added to the VirtualBox media library using the Virtual Media Manager dialog (accessed via the File->Virtual Media Manager menu option) and subsequently attached to virtual machines.

Cloning a Virtual Disk Image

Virtual disk images may be cloned for use in other virtual machines using the VBoxManage command. If the disk image is in a format other than VirtualBox VDI format, the format should be specified when performing the clone operation. For example, to clone a VDI disk image named Ubuntu.vdi, naming the clone Ubuntu2.vdi, the following command is executed:

vboxmanage clonehd Ubuntu.vdi Ubuntu2.vdi -format VDI

VirtualBox Command Line Management Interface Version 2.1.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 53deab63-0492-400b-9c8f-ad3ad3756f9d

Once the cloning process is complete (the exact duration of the process depends on the size of the original virtual disk), the cloned image will need to be added to the VirtualBox virtual media inventory using the Virtual Media Manager so that it is available for attachment to a virtual machine.