How to add Virtual Hard Disks and get them to work inside the Guest Operating System
This article explains how to add additional virtual hard disks and get them to work inside the Guest OS in a VMware virtual environment.
As IT is moving towards Server Consolidations, the need for knowledge of managing and administration of Virtual Machines is also necessary.
The important configurable elements of virtual machines are CPU, Memory, and Disk. We need to add the virtual disks or manage them frequently depending on the demand or utilization of space by the workload in the Data Center.
What is a Virtual Disk?
A Virtual Disk is nothing but a file(s) that emulates a physical disk to the Guest Operating System when attached to it. These Virtual Disks can be in the same local machine or in any remote storage reachable by a host. Remote Storage can be ISCSI, SAN or NAS that are attached to the host. We can use virtual disks to store the data or install the OS in them.
We can configure the Virtual Disks in two modes, Preallocated Disks and Growable Disks.
In the Preallocated Disks, the space for the virtual disk is allocated when it is created, but in Growable Disks, the space will get allocated to it whenever it requires. It is suggested to use the “Preallocated Disk” type mode for good performance of a VM because it takes longer to write the data to the virtual disks of Growable Disk mode.
How the file system affects the size of the Virtual Disk
The size of the virtual disk file is limited by both the Hypervisor and the File system. Suppose the support of the storage file system max file size is 10GB, then we can’t create a virtual disk file more than 10GB. Instead we will create multiple max size files and attach them to the virtual machine.
The hypervisor can also limit the max file size of a virtual disk for many reasons, like performance, or backups, etc.
For a VMware virtual disk we can configure the disk to be an Independent Disk type which adds a control and complexity layer to the virtual disks. Once the virtual disk is configured as an Independent disk, then we can configure it as a Persistent or Non-Persistent disk.
In Persistent disks, the changes made to the disks are save permanently, but in the Non-Persistent disks the changes are lost when the virtual machine is powered off.
Adding the virtual disk to the virtual machine isn’t enough for the Guest OS to start using it. When we add the disk for the first time it will be in raw disk format. This article explains about how to add the extra virtual disks to a Virtual Machine which is very specific to VMware visualization solutions and a common procedure to use them in the Guest OS.
The way to add virtual disks to the Virtual Machine may vary from one virtualization solution to another virtualization solution, but once it is added to the Virtual Machine the remaining process is common.
This article clearly explains how to add virtual disks to Linux (SLES) and Windows (WIN2K) OS.
Login to the ESX server using the Virtual infrastructure client or open the VMware Workstation.
- Adding the Virtual Disk to a Virtual Machine:
- Make sure the VM is in the Power Off (shutdown) state.
- Right-click on the VM and click “Edit Settings”.
- A dialog will appear to modify the configurations of the Virtual machine.
Click on “ADD” and a dialog appears showing what elements that can be added to a virtual machine.
Select the “Hard Disk” item.
A wizard will help you configure the virtual hard disk.
Specify the size of the virtual disk you want.
Location: Specify the location of any of the attached storages to the Server or you can specify to keep the disk in the location where the VM is currently residing.
After adding the disk successfully it will show in the Settings Dialog that a new disk was added to the virtual machine.
The above mentioned process is common for adding a virtual disk to any kind of Guest OS.
To configure the virtual hard disk for Persistent or Non-Persistent select Advanced Options.
Click on Independent.
After selecting Independent, then you can set the option whether the disk is to be Persistent or Non-Persistent.
After adding the Virtual Disk to the Linux OS:
Once the virtual disk is appended to the Linux guest OS, power on the Virtual Machine.
In SUSE Linux run YaST2 and select the partitioner.
In the partitioner it will show the new virtual hard disks that were added to the virtual machine. Now it’s up to the user how to partition and use the disks.
In non-SUSE Linux or in consoled based Linux we can use the fdisk utility to create the partition and use the volumes.
For more detail on how to use the fdisk utility, see DamianMyerscough’s cool solution on how to manually partition the hard drive. http://www.novell.com/communities/node/1578/manually-partitioning-your-hard-drive-fdisk
After adding the Virtual Disk to the Windows OS:
Power on the Virtual Machine.
Open the Computer Management tool.
Start > Run > compmgmt.msc.
In Computer Management select Disk Management.
A Wizard will pop up informing you that a new disk was added to the OS.
If the wizard does not pop up, then in the disk management tool it will show the list of new disks that are attached.
Now it’s up to the user on how to format them and partition them into volumes.
This process is common in the VMware workstation, ESX Server, GSX Server, VMServer.