VMWare Workstation – Resizing hard disks

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!

About these ads

22 responses to “VMWare Workstation – Resizing hard disks

  1. I do steps that u say, but GParted can not detect any partitions. Why it can be?
    Thanx.

  2. 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.

  3. 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!

    • 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…..

  4. Thank you, your instructions helped a lot.

  5. 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…

    • 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!

  6. thanks a lot for the tips

  7. Pingback: Resize vmdk in VM Workstation - JessWatts.com - If Want() Then Do()

  8. 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 ?

  9. 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).

    • 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

      • 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.

  10. 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.

  11. Richard, Thank’s for the how-to; your instructions did the trick for me!

  12. First Great how-to.
    second i try everything you say until the resize part.
    i want to resize a partition but i just can’t he say this is the maximum size for this partition i can’t make it smaller or bigger.
    he let me do it to other partitions that i have created.
    if someone could help me it will be greate thanks.

  13. Pingback: Resize vmdk in VM Workstation | JessWatts.com

  14. I used vmware-vdiskmanager.exe to increase virtual disk size. When I run the command, I get failed to initailize log file. Any ideas??

    Thanks..

  15. Found my problem… Command prompt needs to be run as administrator…

  16. Thank you so much for posting these instructions! Worked like a charm.

  17. thank you very much for the good tutorial, and for the answer in the comments about that error=)

    finally getting that vmdk of mine ready for mass deployment, youve been reducing my worktime quite alot.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s