VMware Communities
bravo88
Contributor
Contributor

Linux host -No clean up disks availability for VMware workstation pro

Hi I would like some help with cleaning up my virtual disks, in windows host there is an option to reclaim disk space but running with linux as host, that doesn't exist and I dont know any alternatives to clean my disks.

I run linux as my host OS and windows 10 guest.

I currently have to boot into my windows host do the clean disks there then reboot linux....is there an option to clean disks  under linux ?

Reply
0 Kudos
7 Replies
watcher1
Enthusiast
Enthusiast

VMwareCompactLinux.jpg

Reply
0 Kudos
bravo88
Contributor
Contributor

Ye those options are there but the compact disk space  from experience does not reclaim as much as the clean disk space option.

I just did what you suggested, compact disk in linux it reclamimed about 8 or 10 GB

After that I booted up windows and performed a disk clean, it shows 30 GB available to be reclaimed....note this is after performing compact disk operation in linux

So we need this option in linux ....the clean disk option

Reply
0 Kudos
watcher1
Enthusiast
Enthusiast

Defrag first, then compact.

Compact compacts the dynamically allocated virtual disk to recover host space.

Defragment adjusts client virtual disk space.

A Compact alone will not even be visible to the client.

Reply
0 Kudos
bravo88
Contributor
Contributor

Thnx for the help but sorry to say after complete defrag followed by compact disk in linux.....when booted in windows I still see 30 GB recliamable.....

So yea we need that missing button...clean up disks.....strange that its probably the only difference between the ui on windows and linux....

Reply
0 Kudos
wila
Immortal
Immortal

Hi,

The cleanup option under Windows is a nice feature that is indeed not available at a Linux host. I suspect that it has to do with a technical limitation due to how cleanup on Windows works.

To be more specific on Windows the cleanup is direct, it does not have to create a copy of your virtual disk first, it immediately creates more free space.

There's a few other alternatives as the compact option though.

I have listed them 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
Reply
0 Kudos
watcher1
Enthusiast
Enthusiast

, your referenced link while informative is also in my opinion inadvertently misleading, here's why I say that:

Zero out unused space in a Linux VM

Before we try to shrink the virtual disk files, we should try to remove any unneeded files from the virtual machine to free space.

Clean up your repositories:

For example, on Debian-based VMs, you can run

apt-get clean all

to clear out the local repository of retrieved package files.

On red hat based VMs that would be:

yum clean     ... omitted ...

This is a Linux command to cleanup Linux repositories, it's completely unrelated to VMs. If it's run within a Linux client VM it will incidentally act on that Linux (not Windows) VM as would any other linux command, but run from the HOST system, it has no effect on a client VM. As written it's technically correct, but it implies that it's effecting a VMDK from the host but it does not.

Next run:

cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill

to fill the unused space with zeros and then remove the "zero.fill" that has all the zero's.

As this command writes to the disk until it runs out of disk space, you will get an error "No space left on the device". This is expected.

Note that you have multiple partitions that you have to repeat the above command to zero out for each partition. Adjust "zero.fill" to the relevant mountpoint, for example if you have a separate partition for home it would become:

cat /dev/zero > /home/zero.fill;sync;sleep 1;sync;rm -f /home/zero.fill

Zero out a part of your disk

If your machine cannot be taken down and you do not want to shut down services that might end up corrupting files because of the "No space left on the device" problem then an idea that might work is to zero out a part of your partition.

This for example creates a 100MB size file filled with zero's

# dd if=/dev/zero of=zero.fill bs=1024 count=102400 1  ... omitted ...

Again this is a Linux command that if run from the HOST sytem will have zero effect on a client VMDK. It has to be run from the Linux (not Windows) client, not the host.

So everything in the link is technically correct, but easily misleading in my opinion and not applicable to the original question of recovering VMDK space using the Host system.

Reply
0 Kudos
wila
Immortal
Immortal

Hi,

Thanks for the reply.

The topic of that article is all VMs, not just Windows virtual machines and it also discusses ALL VMware desktop products on all available platforms (Windows / Linux / macOS )

I understand that that makes it easy to be confused and will see if I can somehow simplify that.

The part you are highlighting has subject "Zero out unused space in a Linux VM" ... it's not about running those commands at the host, it is about running them in the VM.

Running these commands at the host indeed won't help.

edit: For me the text was clear, but just to make sure I did add some extra "in the VM" and a tad bit of extra background info. Hopefully this helped.

Also note that the "vmware-vdiskmanager -k " is a command you can run from the host if you want to reclaim disk space (and it is mentioned)

However nowadays the vmware tools option to cleanup from within the guest is just fine too and works quite well.

--

Wil

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