Friday, February 15, 2008

Extend the windows disk under VMware

Few of the earlier windows installations we did with 5G or 10G OS partition started filling up and we constantly needed to juggle files around to keep it alive.
There is option available though to extend these disks, as long as the disks are basic disks and not dynamic disks(I haven't tried working with dynamic disks yet).
Another thing, there are other methods available to do the same also like using other disk partition software or ny using VMware converter, please evaluate what best suites your needs.
What would you need:
1. Downtime for the virtual machine which needs its disk extended.
2. Another Windows 2003 server virtual machine(on same vmware host or able to see the disk of 1st virtual machine) which you can power off twice.
3. ssh or telnet to the vmware esx host server.

Basically, it requires following steps:
1. Shutdown the virtual machine whose disk has to be extended.
2. Increase the disk size by ssh(or telnet) to vmware server host and using the vmkfstools command.
3. Present the disk to another Windows 2003 virtual machine.
4. Extend the disk in question.
5. Shut down the extending machine, remove the disk from this machine's resources.
6. Boot up your virtual machine in question and you should have an OS drive with more space now.
Please make sure you do a backup of the original file incase something doesn't go as expected.
Lets dive deep into these steps now:
1. Shutdown the Virtual machine in question: You have to schedule downtime for the virtual machine to extend its disk.
2. Login to vmware esx server using ssh(or telnet), whatever you use.
Issue the following command to extend the disk in question:
vmkfstools -X 15g /path/VMtest.vmdk
Replace 15g with whatever the new size you want, 10g, 20g etc.
and /path/VMtest.vmdk with the full path and vmdk file name for that host.
(Should be under /vmfs/volumes/[storage_name]/[Virtual Machine Name]/)
3. Through the virtual center now, Shut down the Windows 2003 server we are going to use to extend the disk in question. Edit settings > Click on Add, then Hard Disk, Next, Use and existing disk, Browse to the disk in question and add this. After this disk shows up the resources(or hardware), boot up this machine.
4. Through the disk manager, you should be able to see this new disk with new unpartitioned disk space. Go to command line and enter diskpart.exe.
On the prompt, type list disks.
Select the disk in question by using select disk 2, for example.
Then type List volumes and it would show you all the volumes. select the volume in question by using select volume 1, for example.
Now type "extend". This would extend the volume.
Disk Manager, should show you the disk now with extended capacity.
5. Now shut down this server, Edit settings again and remove this disk(do not delete)
6. Boot up the original virtual machine now and you should have an extended OS disk now.

5 comments:

Unknown said...

Thanks for the great instructions. Much Appreciated!

Unknown said...

This was awesome! made my life simple!

EsseJc said...

what happens if when you go back to see the sizes, it still read the old size.
Im trying to extend a 80 to 120gb on VM ESX but it just chances back after the process. any ideas?

Raj J said...

EsseJc, do you have the right permissions to do the extend?

EsseJc said...

I've figure out guys. thanks. it was snapshot, for future reference. you remove a snapshot and it worked. thanks!