Disclaimer: Back up your data first! Do not attempt to re-size hard disks or partitions unless you have a reliable backup of your virtual machine. I will not accept liability for your stuff ups!
It’s nice to know that you can do this under VMware Workstation as well as with VMware server.
I had a virtual machine originally being used as a test environment. This VM became so useful, I thought that rather than re-create a production version I would simply increase the hard disk size and memory allocation.
There are two ways of doing this. The first is to simply add an additional virtual hard disk to the VM’s configuration. The second is to re-size the existing disk file, and then re-size the partition scheme within it.
I choose the second option as the internal partitioning scheme was based on a simple layout (One ext3 partition for / and a swap partition).
I should mention that this is a Debian Linux virtual machine running on top of a Windows PC.
Expanding the virtual hard disk
- Shut down the Debian virtual machine.
- Start a DOS session (Command prompt for the younger readers).
- Change directory to where you have installed VMware workstation. In my case, this was “C:\Program Files\VMware\VMware Workstation”
- The vmware-vdiskmanager.exe command requires two parameters;
- The size you want to expand the virtual disk to. You can specify the amount in GB. i.e. 20GB
- The path to the Virtual Machines .vmdk file. i.e. “c:\Virtual Machines\Debian\Disk1.vmdk”
- The final command for my needs (Ignore the word wrap, this should be on one line only) is;
vmware-vdiskmanager.exe -x 20GB “c:\Virtual Machines\Debian\Disk1.vmdk”
Obviously your command line should reflect your particular requirements!
Re-partitioning the extra hard disk space
- You will require a live CD .ISO with partitioning software. I used the GParted live CD, but Ubuntu should also do the trick.
- In Vmware, select “Settings” from the “VM” menu.
- Change the CD-ROM connection type to “Use ISO Image: “, and browse to your live CD image.
- Boot the VM, making sure to hit the ESC key at the VMware BIOS screen. This should give you a bootable device list. Select the CD-ROM and hit Enter!
- When booted, start the GParted software.
Delete the old swap partition.
- Select the swap partition.
- Click the “Delete” button.
- Click the “Apply” button.
Re-size the primary partition.
- Highlight the primary partition.
- Click the “Resize/Move” button.
- Change the size of the partition either by specifying the size in the “New Size” box (In MB) or by dragging the right hand arrow to the desired location.
- Important: Make sure that you have left enough room for your swap file!
- When you are ready, click the “Resize/Move” button followed by “Apply”.
Create the Swap partition;
- Highlight the left over empty space on the disk within GParted.
- Click the “New” button. The dialog box will have filled out the partition size as the remaining amount of disk space left.
- Make sure that you select “Linux-swap” as the File system type.
- Click the “Add” button.
- Click the “Apply” button.
Reboot the Virtual machine and check the available disk space with “df -h” or a graphical tool if you prefer.
Good luck!
I do steps that u say, but GParted can not detect any partitions. Why it can be?
Thanx.
By: Jonny on Friday 15 August, 2008
at 1:06 am
I would imagine that this is a disk driver issue. Try a different live CD and see if you get a better result.
Also, can you boot into the existing VM without the live CD? This will at least tell you if you have a good image to work with.
By: Richard on Friday 15 August, 2008
at 1:39 pm
Just wanted to give you a huge THANK YOU for blogging this. Had a great need to expand my vdisk, and this helped immensely.
Thanks!
By: Thankful User on Wednesday 27 August, 2008
at 1:22 pm
if you need to merge/expand etc virtual disk partitions, use the free Easeus Partition Master Home Edition 4.0.1… u can find it at download.com… I just added 10G to my vdisk, but it was of course unallocated and not part of the C drive. Most partition tools refuse to play with virtual disk partitrions. Finally I found this today and it is free and worked to add the new space to my C drive…..
By: endre on Friday 6 November, 2009
at 9:40 am
Thank you, your instructions helped a lot.
By: Anonymous on Friday 5 September, 2008
at 4:12 am
How about if I am on RHEL 5? Is there a similar tool to GParted available? I tried adding swapspace from a booted session and almost hosed my machine. My goal was to create a new virtual disk of, say, 4 GB purely for swap but when I rebooted, the kernel couldn’t find the mount-point. Any suggestions?
Need I mention it, I am on VMware Fusion 2.0.1…
By: mfinocchiaro on Monday 1 December, 2008
at 1:01 am
Hi,
Apologies if this sounds like an obvious question, but did you do these operations from a live CD?
If the new swap partition was on a separate disk, did you add it to /etc/fstab ?
I have never used Fusion before, so can’t comment if it has any impact on your scenario.
Good luck!
By: Richard on Tuesday 9 December, 2008
at 3:01 pm
thanks a lot for the tips
By: nicolas on Sunday 1 March, 2009
at 6:46 pm
[...] to Richard Young for this [...]
By: Resize vmdk in VM Workstation - JessWatts.com - If Want() Then Do() on Saturday 16 May, 2009
at 5:54 am
I have tried to resize my virtual disk according to the article, but I get a error message …
Failed to open the disk file ‘Ubuntu-flat.vmdk’ : The file specified is not a virtual disk .
This is indeed my virtual disk – it is 20 GB in size.
Any suggesstions / comments ?
By: Guy on Saturday 23 May, 2009
at 2:38 am
Hi there. I am getting the same error as above. Can anyone assist?
I’ve have used this procedure before to expand disk.
Had many snapshots and first deleted these.
Command line is:
c:vmware-vdiskmanager -x 15Gb “Windows XP Professional-cl1-flat.vmdk”
Error message:
Failed to open disk ‘Windows XP Professional-cl1-flat.vmdk’ : The file specified is not a virtual disk (16).
By: Keith on Monday 27 July, 2009
at 4:55 pm
Hi Keith,
I think that you are running this command against the wrong vmdk file (The flat file). You will probably have a file named “Windows XP Professional-cl1.vmdk” which is only a few K in size. This is the descriptor file, and running the command against this file should work.
Cheers
Richard
By: Richard on Tuesday 28 July, 2009
at 9:19 am
Thank you for clerifying that there are two vmdk files. I wish I stumbled to this page this morning. It took the whole day trying to figure out why my vmdk file is not a “virtual disk”. I was using the wrong vmdk file.
By: Anonymous on Friday 6 November, 2009
at 8:22 am
I used vmware-vdiskmanager.exe to increase virtual disk size. I didn’t have any errors and the correct disk size was also shown on VMware Devices panel. But when I typed “df” command in Ubuntu, it still displayed the old disk size. Did I miss something? Thanks.
By: Louis on Wednesday 16 September, 2009
at 9:51 am
Not sure why so difficult to enter the BIOS screen. Everytime it gives me the boot screen. But finally I got it. Thanks for great blogs.
By: Louis on Thursday 17 September, 2009
at 11:06 pm