Virtualization affords the ability to easily make
changes to virtual hardware. You can easily add or remove CPUs, memory
disk and network interface cards (NICs) at any time by shutting the
virtual machines (VMs) down and changing their settings. But how do you
increase or decrease an existing disk's size? In this article we will
cover several methods for re-sizing your virtual hard disks.
VMware Converter: It's like a partition do-over
Discovering
that the virtual disk file that you originally created for your VM is
no longer large enough is a common problem. More disk space can be
always be achieved by adding an additional virtual hard disk, but then
you will end up with a second disk partition and drive letter which may
not be desirable. You may also find that the disk file that you created
for your VM is far too large. Thus, you will want to shrink it to
reclaim space on your host server for other VMs to use.
One of the simplest methods to either increase or decrease the size of an existing virtual disk is to use the free VMware Converter utility.
When you run the utility it gives you the option to re-size the
existing disks so they are either larger or smaller than the original
disks. Converter doesn't modify the original disk files; rather it
creates a new VM with virtual disks that are the size you specified and
copies the data from the original VM to the newly created VM. After you
verify that the new VM is working, you can delete the original VM.
Follow these steps to use VMware Converter to re-size your disks:
- Download and install Converter on the VM you wish to re-size. Also,
you can run Converter remotely if you have the Enterprise version.
- Select your Source Type, either "Physical machine," if
you are running it directly on the VM or "ESX Server or VirtualCenter
virtual machine," if you are running it remotely.
- On the Source Login screen select either "This local
machine" if you are running it directly on the VM, or your ESX/VC
server login if you are running it remotely. In addition select the
source VM if you are running it remotely.
- When the Source Data screen appears it will display all
the disks that the VM has assigned to it. Here is where you can resize
your disks, choose to select volumes and re-size and then select one of
the options, (i.e. 'Type Size in GB') and enter a new size. If you are
decreasing the size of the disk you must enter a value larger then the
total amount of disk space that is currently in use on the disk. For
example if you had 8GB of data on a 24GB disk on your original server,
you must enter a value greater then 8GB for the new size.

- Next, select a Destination ESX host which will
typically be the same host as the source the VM is on. Then assign a
name for the VM (name must be different from the source, you can rename
it afterwards once you delete the source server), then select a data
store to put the VM on, a network for the VM and finally click Finish
to begin the process.
- The time it takes to complete will vary based on how
much data is stored on the source server. Once it completes you can
power off your source VM, power on the newly created VM and verify that
it is working correctly. Afterwards you can delete the original source
VM and rename the new VM to match the original name.
Changing disk size with vmkfstool
The next method, which is to only increases disk size, involves using a
command line utility called vmkfstools. If you are running ESX 3.5,
however, you can now also use the VI Client. Older versions of ESX 2.x
allowed you to use the vmkfstools command to reduce the size of a disk
file, but the ability to do this was removed from it in ESX 3.x.
Increasing the size using vmkfstools:
- Power off the VM.
- Log in to the ESX Service Console.
- Switch to the VM's working directory where the disk file is located.
- Type "vmkfstools, followed by the virtual disk
filename, then –X, and finally place the new disk size you want to
implement followed by a G. (ie. "vmkfstools myvm1.vmdk –X 12G"). You
can also specify the new disk size in kilobytes or megabytes by using
"K" or "M" instead of "G."
Increasing the size using the 3.5 VI Client:
- Power off the VM.
- Edit the settings of the VM with the VI Client.
- Select the hard disk that you want to increase and under Capacity enter a new size.

- Click OK.
Once you have increased the size of your disk power on the VM, go
into the disk management utility and ensure that the new disk space is
visible to the operating system (OS). The additional space will show up
as separate unallocated space on your existing virtual disk.

Now that we've successfully increased the size of your virtual
disk it's time to change the existing partition's size to include the
extra space. Part two of this article will cover how to extend your
operating system partition to include the newly added unallocated space
to it. We will cover two different methods for accomplishing this.
To create more space for your apps and data on a
virtual machine (VM), you could create a new VM, but it may be more
efficient to increase virtual disk space on the same VM.
But if you want to increase virtual disk file space, you need to
resize the virtual disk files. To use the newly available disk space,
you have to increase the size of the previously existing disk
partitions. There are two methods for executing this task and each
requires several steps.
Before attempting to increase the size of the original disk
partition, it's a good idea to make a backup of your disk file. You can
do this by either copying the two VMDK files to a temporary directory
on your ESX host, or by using the vmkfstools command with the –i option
which creates a copy of the disk file. The syntax is:
vmkfstools -i <source disk name> <destination disk name>
Or in our example:
vmkfstools -i myvm1.vmdk myvm1-backup.vmdk
The disk file name should be the non-flat file name. Vmkfstools
automatically copies both the descriptor VMDK file and the –flat data
VMDK file.
The first method for accomplishing a disk partition re-size
involves attaching the disk file to another VM and using the Windows
DISKPART utility to extend the volume. DISKPART will not allow you to
extend a system or boot volume on the server you are running it on,
which is why we must extend it using another server. The second method
involves booting from a Gnome Partition Editor (GPartEd) live CD and
using the utility to extend the volume.
Windows helper VM method:
- Shut down the VM whose disk was extended (VM1).
- Select a VM to be used as a Helper (VM2). The VM should preferably be running the same OS and be on the same ESX host as VM1.
- Shutdown the VM which will be the helper (VM2).
- Edit the VM settings for VM2, add an additional hard
disk, select to use an existing virtual disk and browse to VM1's disk
file and click OK to finish.
- Power on VM2. If you go into the disk management utility you will see the second hard drive.

Click image for larger view
- Go to a command prompt and type DISKPART. Next type
LIST VOLUME to see all the available volumes. Then, find the volume
number of the disk from the other server. You can usually tell which
one it is by the drive letter and size, and it should also be the one
that is not a system volume.
- Type SELECT VOLUME <volume #> to select it. Once
it is selected type EXTEND to extend it. If you enter LIST VOLUME again
you will see the new size.

Click image for larger view
- Exit out of the DISKPART utility. If you check in
the Disk Management utility you will also see that the previously
unallocated space it gone and the disk is now larger.

Click for larger view
- Shutdown VM2, edit VM2's settings and remove the hard disk from it. Make sure you only remove it and do NOT delete the disk file.

Click image for larger view
- Power on VM1. Once it boots and you log into it
you will probably see a prompt asking you to restart. Let it restart,
log back in, load Disk Management and you should see that your disk has
been successfully increased.

Click image for larger view
GPartEd method:
- Shutdown the VM whose disk was extended.
- Download the ISO file for the GpartEd Live CD.
- Copy the ISO to the VMFS volume of the ESX server so
it can be mounted by the VM. Edit the VM's settings, select the CD
drive, select the data store ISO file for the device type, browse to
your ISO file and select it and make sure you have Connect at Power On
checked.

Click image for larger view
- The next part can be a bit tricky because of the
very brief amount of time that the VM's BIOS screen displays when it is
started. This delay is not configurable in ESX 3.0.x but can be
modified in ESX 3.5. You may want to temporarily increase the delay if
your VM is on a ESX 3.5 server. To do this, edit the VM's settings by
going to the Options tab, then selecting Boot Options and change the
Power-on Boot Delay to 5,000 milliseconds (5 seconds).
- Make sure you have the VM's console open and click the
Power On icon. As soon as you see the BIOS screen displayed, quickly
click inside the console window to give it focus and hit the ESC key
which will bring up the Boot menu. If you miss it, let the server boot,
log into it, do a shutdown and restart and wait for the BIOS screen to
appear and try again.

Click image for larger view
- Once you get the boot menu, select CD-ROM and it will boot from the ISO file that you selected.
- The GPartEd screen will appear, hit ENTER to continue.

Click image for larger view
- The live CD will start loading, hit ENTER to load
the default key map, choose a language or hit ENTER for US. The live CD
will continue loading until the GUI screen is finally displayed.
- Select your partition (/dev/sda1) in the list and click the Resize/Move button.

Click image for larger view
- Move your mouse to the right-arrow. The cursor
should change to a double-arrow. Make sure you do not move into the
green area which is Move (four-way arrow cursor) instead of Re-size.

Click image for larger view
- Drag the right-arrow all the way to the right to increase the partition size to the maximum size.

Click image for larger view
- Click the Resize/Move button and the
Resize/Move window will disappear. Click the Apply button to start the
Resize operation. Click Apply a second time to confirm.

Click image for larger view
- The Resize operation will begin and
should quickly complete. You can expand the details heading to see
detailed information on the operation. Once it completes click the
Close button.

Click image for larger view
- Click the Exit button and select the
Reboot option. The server will reboot. Windows servers will typically
do a Check Disk when booting after the partition has been modified
outside of Windows. Once the Check Disk finishes, log in to the server.
Windows will have detected the change and will want to restart. Let it
restart, log in again, load Disk Management and you should see that
your partition has been enlarged.
That's it, you should now have more disk
space for your virtual machine to enjoy. There are a few other methods
for increasing and decreasing virtual disk sizes but the methods in
this article tend to work the best. You can also read about additional methods here.
Also further leeched this article (http://searchvmware.techtar[…]179_gci1324177_mem1,00.html) and added to this same one to make a MEGA tutorial. :)