VMWare Tools to shrink disk / reclaim unused space

Since the vmdk with HASS OS currently requires twice the amount of space than HASS OS is actually using inside the VM, I tried to reclaim the unused space, to.shrink the vmdk using the defragment and compact buttons in the VM options, this did not reclaim any unused space. For Windows VM’s there’s a clean up disk button, which is missing with the HASS OS VM.

Then I remembered that with Linux guests, a command needs to be run inside the VM, with Ubuntu that’s “sudo vmware-toolbox-cmd disk shrink /”, this requires VMWare Tools or open-vm-tools to be installed.

So far I haven’t found how to do this in HASS OS. Can the vmware-toolbox-cmd tool be added the HASS OS?

Sadly I do not think,so. Hassos being based on alpine . I have the same need.
I will end up switching to supervised on debian

+1 for including open-vm-tools as an option that is activated if VMware hypervisor platform is detected

1 Like

@Hedda @dvbit The VMDK has shrunk to about half of what it was just now :slight_smile:

Turns out two things need to be done:
SSH to HASS: cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill
After shutdown VM on Windows host: vmware-vdiskmanager -k “C:\pathtoVMDK\haos_ova-6.2.vmdk”

Thanks.
Question: your HASS flavor is debian or ubuntu correct?
I do not know if the first commands will be available on alpine based

trying the first command it seems hanged.
rm the file zero.fill and rebooted

Shali I wait till end with patience :slight_smile:
Merry Christmas

I’m using the zipped VMDK from Releases · home-assistant/operating-system · GitHub, entered the command with the help of the Terminal & SSH addon and PuTTY.

Just leave it running for a couple of minutes, looks indeed like it hanged, it’s not (check hdd LED on host-pc, should blink a lot). At some point it will give a not enough storage space available warning, this can be ignored since file will be deleted.

1 Like

I was running HAOS as VM on VirtualBox (Windows host) for almost 2.5 years before switching to VMware Player 17 (free version) around middle of 2023. However by Nov-2023 I came across the same challenge as the OP … ever growing vmdk file for that VM.

Searching HA community forum brought me to this post (from 2021) and I am happy to report that zero.fill command worked great through addon “Terminal & SSH” using Web UI (found on Info page after installing that addon; no need for Putty when using Web UI). Thanks @bartgrefte :slight_smile: And for the second step I found that one does not have to use vmware-vdiskmanager utility (some folks may not have it on their system anyway, like me using free version of VMware). The same can be achieved using “Compact” button in VM options in VMware Player 17 (after shutdown VM on Windows host): Edit vm settings > Hardware > Hard Disks > Disk Utilities > Compact

Using this method my HA vmdk file reduced from 9+ GB to 4+ GB (almost 50% reduction!)

Pre-req: Install & setup the “Terminal & SSH” addon for HA to access backend (requires advanced mode)

Step 1: Use HA > Settings > Add-ons to access “Terminal & SSH” and use “Open Web UI” (found on Info page of that addon) to execute the following command at the Linux command line:

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

This may run for a while depending on amount of space used in your HA instance. You may see a message about not enough storage space available; this can be ignored.

Step 2: In WMware Player 17, stop or shutdown your virtual machine for HA, then use Edit vm settings > Hardware > Hard Disks > Disk Utilities > Compact.

This may run for a while depending on size of your virtual disk/vmdk file. The Disk Utilities section also shows the size of virtual disk/vmdk file, so if you like you can note/copy the before & after numbers from this same screen.

1 Like