How to shrink Catalina guests?

Apple disabled `diskutil secureErase freespace`..., claiming that this reduces the life of SSD's. But for *virtual* SSD's it is essential to zero out and compactify volumes, to prevent the virtual disk from wasting a lot of storage space on the host. For example, an old Mojave VM provided 40 GB of virtual space, but only needed 8 GB on the host.

It stands to reason that a comparable savings ratio could apply to Catalina. Of the boxes I'm seeing on Vagrant Cloud, the numbers are closer to 100 GB virtual capacity, with 40 GB of host box storage space, which drives my host storage bonkers and ties up my Internet bandwidth for quite some time.

Perhaps Catalina can be installed without involving APFS. Unknown if that is enough to allow the command to work again. Unknown if macOS allows this. Unknown impact on Catalina to run on HFS+ partitions.

`dd` usually does the trick for UNIX guests, but has historically not worked for macOS.

VMware provides a disk shrinking utility. Unknown if that still works for Catalina. In any case, this is helpful for some providers but not VirtualBox, libvirt / qemu, parallels, Azure, AWS, Docker, and so on.

I wonder if `dd` could effectively zero out and shrink APFS partitions, were the mac VM is halted and analyzed by Gparted or similar livecd, at the end of the Vagrant provisioning process. Worth experimenting.

Or perhaps there is another way of accomplishing this?

1 thought on “How to shrink Catalina guests?”

  1. `dd` is used to fill the storage with zeros, which is a markers for “free” space for VM hypervisor. You just create as large zero-filled file as possible, sync it to storage, delete, than stop VM and ask for storage compaction.

    It is the hummer solution. Like FS spends inode structures to keep references to zeros, but there is no way to reclaim that storage space with such trick.

    EXT4 and other FS have utilities helping with compacting of FS + have TRIM support.

    As I know VirtualBox still has problems with TRIM.


Leave a Comment