VMware Cloud Community
bblqk83
Contributor
Contributor

Expanding a Virtual Disk in ESX

I need to expand a Virtual Disk in ESX, I have looked through the book and the VMWARE Site but no luck...

Does anybody know the Command to do this????

Cheers

Reply
0 Kudos
37 Replies
harved1
Contributor
Contributor

The VM must be powered down for this command....

vmkfstools -X new_sizevmfs_name:disk_name

i.e. vmkfstools -X 8192m sanVOL3:data.vmdk

Make a backup first....

Hope that helps!

Reply
0 Kudos
bblqk83
Contributor
Contributor

Sure thats just what I am looking for Smiley Happy

Thanks

Reply
0 Kudos
tsmerian
Enthusiast
Enthusiast

I needed this to! One question: How long does this take to perform and is there a way that I can monitor it's progress?

Obviously, I know enough about Linux to be dangerous...

Reply
0 Kudos
jason_farrow
Hot Shot
Hot Shot

The expansion takes only a few seconds. Remember that we are just changing the size of the .vmdk file in the VMFS disk. This is a simple metadata change. You would then need to use suitable tools to expand the VM's OS filesystem to use the additional space.

Remember also that the vmkfstools -X option sets the new file size and not expand the .vmdk file to an increased size.

Reply
0 Kudos
MR-T
Immortal
Immortal

I've done this on a few Windows 2003 VM's and it works a treat.

You can use the diskpart tool which comes with both Windows 2003 & XP to expand your disk once windows restarts.

I don't think Windows 2000 came with diskpart and requires the use of a resource kit utility.

It's a simple process.

Go to a cmd prompt

Type Diskpart

Dislpay your partitions by typing list partitions

Then you can simply focus on the partitoin by typing select partition

Finally type Extend

I think that's it, let me know.

Reply
0 Kudos
STS
Enthusiast
Enthusiast

We just add a extra .vmdk hard drive file to the existing VM and ghost between the old and the new, works a treat...

Reply
0 Kudos
stuartrobertson
Contributor
Contributor

It's worth noting that extend only works when the free space is contiguous space from the partition you wish to extend.

Reply
0 Kudos
default-user
Contributor
Contributor

Linux newbie here - that command apparently isn't in the path, and it took me way to long to find it. It's here:

/usr/sbin/vmkfstools

~Keith

Reply
0 Kudos
default-user
Contributor
Contributor

Hello

the best way is using wmkfstools -X to resize a VMDK file (see man mor exact syntax)

warning the size you 'll enter will be the final size.

Howether after this step, you need a third party like partition magic in order to resize the virtual disk inside of the virtual machine.

Cordially

Sorry for my english (I'm french)

Reply
0 Kudos
default-user
Contributor
Contributor

Hello

the best way is using wmkfstools -X to resize a VMDK file (see man mor exact syntax)

warning the size you 'll enter will be the final size.

Howether after this step, you need a third party like partition magic in order to resize the virtual disk inside of the virtual machine.

Cordially

Sorry for my english (I'm french)

Reply
0 Kudos
jerrycutshaw
Contributor
Contributor

You don't need a 3rd party utility just use Diskpart:

http://support.microsoft.com/kb/325590

Reply
0 Kudos
jerrycutshaw
Contributor
Contributor

When diskpart fails and you don't want to pay for partition magic you can always use gpart. It works great!

http://www.linux.com/article.pl?sid=06/04/25/1917228

Reply
0 Kudos
stavener
Contributor
Contributor

microsoft only support Diskpart for data volumes, NOT system boot partitions...

http://support.microsoft.com/kb/325590

we use Ghost and it works a treat, takes about 5-10mins to up a VM+OS to a larger disk.

How to Expand a System Boot partition for a VM.

1. shutdown VM

2. add a new VMDK to current VM, of required new size.

3. Boot into Ghost, (we boot VM via PXE/RIS into WinPE, then run Ghost32.exe, select `Backup and Restore` to load Ghost.

4. choose `disk to disk` imaging, select old small drive as source, new large drive as dest, wait for 10mins...

5. shutdown VM.

6. Take a note of the two VMDK disk name, including the SCSI BUS:ID

7. `Remove` the two VMDK disks.

8 `Add` the new larger VMDK file as the old SCSI BUS:ID

9. power up your VM and confirm Disk size has increased.

10. confirm it all works correctly and delete the old VMDK disk image.

This has several benefits..

It does not touch the original disks.. you can always revert back.

the new partition is automatically resized to fill the available space.

it only takes about 12 mins for a 8Gb Data migration to a new disk.

Note: this can also be applied to normal servers, if you choose to create an `disk to image` in Ghost, then swap out the disks for the larger size, and then `Image to Disk` to create the new larger partition.

Or a simple datavolume extension the Microsoft way......

vmkfstools -X new_sizevmfs_name:disk_name

Go to a cmd prompt

Type Diskpart

Dislpay your partitions by typing list partitions

Then you can simply focus on the partitoin by typing select partition

Finally type Extend

Reply
0 Kudos
guser
Contributor
Contributor

Just used gparted, did the job! Thanks for that jerrycutshaw.

http://gparted.sourceforge.net/index.php

Reply
0 Kudos
JOler
Contributor
Contributor

Just did my first expandion, Here's what I did.

\**** Expanding a ESX VM for Dummies ****

1. ssh to VM server, find the vm config file that needs to be expanded (*.vmdk).

2. Enter the following command

vmkfstools -X 10240m vmfs1:prod-hq-vm01.vmdk

(10240 will be the new dish size, it's in multables of 1024. So you want a 10GB hard drive, 1024x10=10240)

(vmfs1:prod-hq-vm01.vmdk is the full controller name, you can fine this by looking in the prod-hq-vm01.vmdk file)

(This process takes seconds)

3. boot the VM

4. shut down the VM, make sure it's a clean shutdown, do not power off the session.

5. download gperted.iso from http://gparted.sourceforge.net/download.php

6. copy the iso to a place that your VM session can boot from it.

7. Edit the properties of the VM seccion, Select CDROM

Check Connect at Power On

Select the iso image by by browsing to the file.

Save these changes.

8. From the VM console(Virtural center or open the console from the web page) boot the session.

Press Esc at boot up, this will bring up the boot device prompt, Select CDROM Device.

You should be seeing the gnone boot screen

(Waking up the USB takes a couple of miniutes

(Is you live in the US like I do, select the defaults all of the next 6-7 prompts. They all work fine for VM ESX.

(Language=US, Keymap=US, Xorg=xserver, video drive=vesa, screen depth=24, resolution=1024x768)

9. Select the hard drive you wish to expand.

Slide the bar to the size you want.

Select Apply

10. Process complete

Reply
0 Kudos
spuckett
Contributor
Contributor

One more helpful note for anyone that did something dumb like me and used spaces in their names, just enclose the whole thing in a set of single quotes, i.e. 'LocalVMFS:Win 2003 w-SQL 2000.vmdk' and it will work

Also you can find the name of the drive by opening the Web interface, then clicking on Manage Files, then open the vmfs folder and there will be a shortcut directory with the correct name in it, or at least that is how I found it, it is NOT the one that looks like this vmhba0:0:0:5.

Reply
0 Kudos
mikevalente
Contributor
Contributor

Thanks for the info. I'm doing my first expansion on ESX 3.0, and when I run the vmkfstools -X command with the path to the .vmdk file I want to expand, I get "The system can not find the file specified."

Is there a default directory on the host I should navigate to and run this command? I'm using /vmfs/volumes/xxxx.vmdk, and there are no spaces in the file name.

Reply
0 Kudos
mikevalente
Contributor
Contributor

Nevermind, I found it.

Interesting to note the actual location of these vmdk files - they reside in /vmfs/volumes/data_store_name/*.vmdk

Case sensitive text.

Reply
0 Kudos
Robski
Contributor
Contributor

the way I did this was to first resize the vmdk file using vmkfstools -X. I then mounted the vmdk as an additional drive to an existing VM as say, drive e:\. I used diskpart to then expand drive e:\ to the size of the vmdk file. Finally I removed it from that vm, and powered my existing VM back on again. Worked a treat and I think it might be faster than ghost.

Reply
0 Kudos