I’m using Home Assistant in a virtual appliance. I schedule complete backups at VM level every night.
Would be very nice if we had a way to zerofree the disks from time to time. Would be more than enough to just have a zerofree button in Lovelace config, which could schedule a zerofree procedure at next boot. We would just run this manually, doesn’t have to be automated.
This would save a lot of disk space on the backups.
zerofree has been written to be run from GNU/Linux systems installed as
guest OSes inside a virtual machine. In this case, it is typically run from
within the guest system, and a utility is then run from the host system to
shrink disk image (VBoxManage modifyhd --compact, provided with virtualbox,
is able to do that for some disk image formats).
I think it’s out of scope of the Home Assistant forum to start explaining/discussion about virtualization basics. I think you can find the answer to your question in quite a few places:
Well, this is the HA forum, and you’re asking for it, so it was fair to.ask why.
I genuinely didn’t know you had to zero the blocks before you could shrink the disk, before Nick pointing that out.
Certainly compression (eg zip/gzip) compresses “data followed by a million zeores” more efficiently than “data followed by a million random characters left over after deleting a whole lot of files”
For all my understanding, it’s not related to compression as such.
When shrinking the dynamic disk, “zeroed” block will be marked as such and not actually allocated on the host system.
Now, zerofree asks for the partition to be unmounted, or mounted RO. No clue on the partition design in HA VM image, but that’s an additional hurdle, considering HA runs in a container even in the VM image.
Pretty sure the HA guys are not keen to allow this kind of OS level manipulation in HAOS
I think an option to be added on demand from the UI that at next boot run zerofree before mount is not something that they’d find too difficult to implement.