Hard disk controllers

If we look at the physical servers or computers, all the devices (for example, DVD drives and hard drives) are connected to the physical hard disk controller, which is responsible for all the I/O operations of these devices. In contrast, VirtualBox emulated these hard disk controllers. VirtualBox emulates the most commonly used hard disk controllers such as IDE, SATA, SCSI, and SAS, which are described as follows:

  • IDE (ATA): This was the most widely used controller standard, but it has certain limitations and is now being replaced by the SATA standard. These controllers are backward compatible. So, if a guest operating system doesn't support SCSI or SATA, it would fall back to use IDE (ATA). For each guest VM in VirtualBox, there might be one IDE controller enabled that supports or allows up to four storage devices to be connected to a guest VM. It does so by using the primary master, secondary master, primary slave, and secondary slave slots. Out of these four storage devices, the secondary device master slot is preconfigured for CD/DVD devices. If additional IDE disks are required, the VirtualBox SATA controller for the VM must be enabled in the SATA IDE compatibility mode.

    If you migrate a guest VM from another virtualization solution to VirtualBox, then you are expected to provide the exact controller type. In VirtualBox, you can select the PIIX3, PIIX4, or ICH6 controller type.

  • Serial ATA (SATA/AHCI): This is now the most widely used and latest drive controller standard. SATA provides higher levels of storage performance, unlike the IDE standard. It does not impose restrictions on the number of devices that can be connected or attached to a single disk controller. Another big advantage of using SATA is that disks can be added or removed on the fly without shutting down the system. These disk controllers can be configured to run in IDE compatibility mode to allow access from guest operating systems that lack Advanced Host Controller Interface (AHCI) support. A guest VM can be configured with up to 30 SATA ports in VirtualBox. The first four of these SATA ports are configured by default to operate in the IDE compatibility mode. Considering all the advantages and features, VirtualBox uses the SATA controller as the default controller for any newly created VM.

    VirtualBox creates one SATA controller by default, and the default disk that is created with the new guest VM is attached to this controller.

    If it's not enabled for some guest VMs, you can enable it by clicking the Storage tab under the Settings dialog. Then, click on the Add controller button and select Add SATA Controller.

  • Small Computer System Interface (SCSI): This is now a popular storage connection standard. This standard is based on a bus topology allowing up to 15 storage devices to be connected to a disk controller in a daisy chain configuration. Each of the devices is assigned a unique SCSI identifier, which distinguishes the devices from each other on the SCSI bus. VirtualBox provides emulation for BusLogic and LSI Logic SCSI disk controllers.

    To enable a SCSI controller, select the VM under Settings, click on the Storage tab, click on the Add Controller button under the Storage Tree section, and then select Add SCSI Controller.

  • Serial Attached SCSI (SAS): Like SCSI, this standard uses the SCSI command set. In this type of connection, serial cables are used instead of parallel cables. This results in simplified physical device connections. It is more reliable and faster compared to SCSI.

    To support high-end guests that require SAS controllers, VirtualBox emulates a LSI Logic SAS controller. This can be enabled in the same way as a SCSI controller. This standard supports up to eight devices, which can be connected to the SAS controller.

To sum up, VirtualBox provides the following categories of virtual storage slots, provided they are enabled. In this case, they are supported by the guest operating system:

  • Four slots attached to the traditional IDE controller; avoid this controller unless this is the only controller supported by your guest OS
  • 30 slots supported by the SATA controller
  • 15 slots supported by the SCSI controller
  • Eight slots supported by the SAS controller

Disk image files (VDI, VMDK, VHD, and HDD)

Guest VMs accesses virtual disk images that are stored on the physical hard disk in the host computer. When a guest VM tries to access these disk images, the read/write disk access is redirected by VirtualBox to the virtual disk image.

A virtual disk image is similar to a physical hard disk. It has size that is basically specified when you create the VM. Upon creation, the entire size of the virtual disk might be used for the image or the image might be dynamically expanded. These two types refer to thick and thin provisioning.

There are four types of disk images supported by VirtualBox:

  • VDI: Also known as Virtual Disk Image
  • VMDK: The VMware format of a virtual hard disk
  • VHD: The Microsoft format of a virtual hard disk
  • HDD: This is the image file of Parallels Version 2 format; VirtualBox also supports this format

You can create two kinds of disk images: fixed size images or dynamically allocated images:

  • Dynamically expanding: When you select this option, the disk image will be created with a minimal size, but it grows automatically when more space is needed by the guest operating system. However, during the creation of a dynamically expanding disk, you specify a maximum capacity, which is the maximum capacity the disk will expand to. The main advantage of using this feature is that you are not wasting the disk space on the host before it is required, but there is a disadvantage associated with it in that it results in a slow performance if disk expansion happens pretty frequently.
  • Fixed size: When you select this option, a disk image file is created with the specified size. This option improves the write performance, but the disadvantage is that it will take a long time to create the disk image in the first place and you might end up wasting the disk space if it's not required.

VirtualBox keeps track of all the disk types, such as hard disk, CD/DVD ROM, and floppy disks, which are used by the guest VM. These are known as Known Media. Virtual Media Manager is used to either view or change these known media. VMM can be accessed from the File menu in the VirtualBox main window.

Virtual Media Manager looks like the following screenshot:

Disk image files (VDI, VMDK, VHD, and HDD)

Known media are grouped into three categories as follows:

  • Hard disk images can be either a VDI native format for VirtualBox or any third-party format, such as VMDK
  • CD/DVD images in the ISO format
  • Floppy disk images in the standard RAW format

Virtual Media Manager also allows you to copy, modify, remove, or release a disk image.

Image write modes

We have already learned about fixed and dynamic disk images, and apart from this there are multiple options available that dictate the way data is written to the disk drive.

The options are listed as follows:

  • Normal: When you create a disk image, the default setting is Normal. In this mode, any operation such as read or write performed by the guest VM is performed on the disk image itself. Disk images in the normal mode can only be associated with one running guest VM. Also, any data written to the disk is permanent even if you power off the guest VM.
  • Immutable: This mode ensures that the data written on the disk image is read-only. But when a guest VM writes any data to the disk, it gets stored in a separate differencing disk image. When the guest VM is reset or powered off, all the data written in the differencing disk will be lost. So, the immutable disk is untouched. This approach is used when you want to share the same disk image across multiple VMs, each being assigned its own differencing disk during run time.
  • Multi-attach: This setting is very much similar to how an Immutable image works, apart from the fact that the differencing image is not reset every time the guest virtual machine starts.
  • Writethrough: These disk images allow read/write operations to be performed on the disk image. When the VM is powered off or reset, the state of the disk image is not saved; therefore it reverts to its original state next time the VM starts.
  • Sharable: These are a variant of write through hard disks but the state is not saved when a snapshot is taken and can't be restored when the snapshot is restored. You can attach this disk to multiple guest VMs that run concurrently and access this file concurrently. But only fixed sized images are candidates to play the role of a shareable hard disk. If you try to attach dynamic images, they will be rejected.
  • Read-only image: These are used by a CD-ROM/DVD image by default as they are read-only in nature.

Cloning a virtual disk image

Cloning a disk helps to duplicate hard disk image files on the same host to quickly reproduce a second VM as the primary image.

VirtualBox assigns a Unique Identity Number (UUID) to each disk image, which is also stored inside the image. So if you have multiple disks with the same UUID number, VirtualBox will refuse to work.

To clone the disk, use the following command:

VBoxManage clonehd <source image file> <target image file> -format <format>

To check the disk ID, the following command can be used:

hdparm -i  <device>

Bandwidth control for disk images

Starting with Version 4.0, VirtualBox allows for limiting the maximum bandwidth used for asynchronous I/O. Additionally, it supports sharing limits through bandwidth groups for several images. It is possible to have more than one such limit.

Limits are configured through the VBoxManage command-line interface. The following example creates a bandwidth group named Limit, sets the limit to 20 MB/s, and assigns the group to the attached disks of the VM:

VBoxManage bandwidthctl "VM name" add Limit --type disk --limit 20M
VBoxManage storageattach "VM name" --controller "SATA" --port 0 --device 0 --type hdd --medium disk1.vdi --bandwidthgroup Limit
VBoxManage storageattach "VM name" --controller "SATA" --port 1 --device 0 --type hdd --medium disk2.vdi --bandwidthgroup Limit

All disks in a group share the bandwidth limit, meaning that in the preceding example the bandwidth of both images combined can never exceed 20 MB/s. However, if one disk doesn't require bandwidth, the other can use the remaining bandwidth of its group.

The limits for each group can be changed while the VM is running, with changes being picked up immediately. The following example changes the limit for the group created in the preceding example to 10 MB/s:

VBoxManage bandwidthctl "VM name" set Limit --limit 10M
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.14.245