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.