Expanding VMDK Drives Without Tears

Posted by: on December 21st, 2011 | Categories: VMware, Windows | Tags: , ,

One of the simple ways to expand the size of your virtual machine vmdk drive is using the ESX or vSphere Service Console. I’ve personally used it with ESX 3.5 and up to vSphere 4.1 and today i’ll show you how easily this can be done !

Before you start anything i strongly recommend that you take a full backup of your VM  just in case.

Now, lets role our sleeves and get our hands dirty:

1- shutdown and power off the VM using the vSphere client
2- delete all the VM server snapshots if there is any.
3- from the local server or using SSH logon the Service Console with your root access.
4- cd to your vmdk file as the following:

[root@esx01 /]# cd /vmfs/datastore-name/vm-server-name/

5- using the vmkfstools command, specify the new vmdk size, lets say your current vmdk is 50 GB and you need to expand it to 70 GB, you enter the following command:

[root@esx01 vm-server-name]# vmkfstools -X 70G virtualdrive.vmdk

This doesn’t take time at all, its maybe 2 seconds or less, in fact, what you did here is just adding new unallocated free space to your hard drive and in the next step I’m going to show you how can you allocate all or some of that free space on your current disk or partition, but lets first verify that we have added an additional 20 GB and now our vmdk is a 70 GB.
Type the following command:

[root@esx01 vm-server-name]# ls -alh

Verify the size of your vmdk, and if every thing is ok, then log off the ESX Service Console and start your VM using the vSphere client.

6- in this article i’ll show you how to extend your hard drive on a Windows 2008 R2 VM and if you are doing this on a Linux VM, then expanding the size of the vmdk file will work up to step #5, however, claiming the free space is totally different in Linux and unfortunately its out of the scope of this article, but here is a hint: google “resize2fs” command.

a. Logon your Windows machine and launch the Server Manager, then select the Disk Management from the left pane

b. Select the disk with with the unallocated free space, and then right-click on it and choose Extend Volume…

c. add the additional space that you need or max it up if you want.

d. thats it, you’re done … you can now smile 🙂



Print Friendly

No comments yet.
You must be logged in to post a comment.