VMware Communities
m4ntic0r
Enthusiast
Enthusiast

Compact Disk on Linux guests does not work?

I have a problem..

i have two VMs, one Ubuntu 16.10 and a Debian 8.

Ubuntu 10G HDD, df -h shows used 2,2G but vmdk size on NTFS Host shows 9,2G

Debian 10G HDD, dh -h shows used 1,6G but vmdk size on NTFS Host shows 6.16G

I tried everything to shrink those vmdks..

1. In VM Settings, select HDD and "defrag" and "compact" disk -> no difference in size

2. I found this: Compact/shrink *.vmdk does NOT work (for Ubuntu guestOS)

3. run sudo e4defrag /dev/sdaX in both guests

4. run dd if=/dev/zero of=wipefile bs=1024x1024; rm wipefile in both guests

5. run defag and compact in vm settings again -> no difference in size

i dont know what i am doing wrong Smiley Sad

7 Replies
m4ntic0r
Enthusiast
Enthusiast

I found my own solution!

use the open-vm-tools (i already use them)

apt-get install open-vm-tools

then shrink live your file system:

vmware-toolbox-cmd disk shrink /


my vmdk files are now 1,95GB and 2,34GB big Smiley Happy

would always do a backup before this

bartgrefte
Contributor
Contributor

Thanks for posting that, worked perfectlySmiley Happy


But now I am curious why the dd-method didn't work (ran into the same thing here), I've been trying to get that method to do what's advertised on several websites, without succes.

0 Kudos
wila
Immortal
Immortal

Hi,

AFAIK the dd method still works, but should be followed up by a "vmware-vdiskmanager -k <disk>" run

I've listed all methods that I am aware about on hosted VMware platforms here:

Shrink guest on hosted platform - VI-Toolkit

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
0 Kudos
bartgrefte
Contributor
Contributor

According to your link that command is used on Linux hosts, I'm using a Windows host.

0 Kudos
wila
Immortal
Immortal

Hi,

For the record I wrote that article, I'm just posting a link as it has benefits over using copy&paste.

Besides that it allows me to improve the text over time without having to correct it in every reply.

The relevant part is this and I've bolded the bit about windows.

You can shrink the .vmdk file as follows:

vmware-vdiskmanager -k Ubuntu\ Desktop.vmdk 

On Windows the command also uses the -k option, so I leave that for you as an exercise.

Perhaps I should reword it a bit at the vi-toolkit.com site?

it is the same on Windows as is on Linux, but you will have to adjust operating specific things like use a backslash in the path instead of a forward slash.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
0 Kudos
bartgrefte
Contributor
Contributor

"For the record I wrote that article"

Thank you for that Smiley Happy


"The relevant part is this and I've bolded the bit about windows."

Woops, I overlooked that.:smileyblush:

0 Kudos
AdamLopes
Contributor
Contributor

Thanks very much @m4ntic0r​ for the tip

vmware-toolbox-cmd disk shrink /

For Ubuntu 18.x guests on OSX, this is the one that actually works. Couldn't tell you about other operating system combos.

I had a tonne of recorded video that was deleted, resulting in a bloated .vmdk file. Everything else either didn't exist (i.e. the mentioned UI element wasn't present) or failed to shrink the file, nor increase the amount of "reclaimable" space.

This did it with a single command issued from the Guest's shell.

0 Kudos