Archive for February, 2016

Shrink a Linux partition in VMWare Workstation

Friday, February 19th, 2016

I ran across an issue recently on two Linux VMs in my home lab.

They are each configured with a dynamic disk so they can grow as needed, and so I gave them very generous disk quotas “just in case” I’d ever need lots of space (300GB quotas each).

Unfortunately, each had a situation recently where a log file grew until it filled up the drive. I tracked down and deleted the problem log files in both cases freeing up the space in the local operating systems, but now I was stuck with two virtual machines that should be 6-8GB each taking up 600GB of total space on my drive.

I thought the solution would be simple – in the VM drive properties in VMWare Workstation there is a “Compact” button.  I shut the machines down and clicked that button and it ran for a bit and said it finished, but the size of the machine hadn’t changed after the operation completed. This does make sense as the guest OS has used the blocks but there was no clear way to release that space from the OS level.

I did some research and learned of a command line utility part of VMWare tools.  I did have VMWare tools already installed on both virtual machines (it’s always the first thing I do after building a machine) but was no clear way to use this tool. f I entered ‘vmware-toolbox-cmd’ there was no obvious way to list any help screen output even with the usual help arguments added to the command. (–help , -help, /help, etc)

The error message when simply running the command by itself was

vmware-toolbox-cmd: Missing command


I finally found a VMware PDF doc online that mentioned this tool, it too didn’t have very detailed instructions but I figured out the correct way to shrink a partition was by using this command:

vmware-cmd disk shrink /

It then gives you a progress/status indicator and starts running



It took a good while to complete, and when it was finished there was an error (as the tool itself said there would be), which we ignore.

This was all done as an online operation with no reboot needed.