A hardly known feature is "on-the-fly" compression for HFS+ Filesystems. It can be done with the tool afsctool (there is also an option with the command ditto --hfsCompression). Here is an example how to compress a complete Virtual Machine. Decompression is done automatically and on-the-fly. First, check the folder:
Olivers-Air-3:Virtual Machines oliver$ afsctool -v MSEdge\ Win10\ RS1.vmwarevm/
/Users/oliver/Virtual Machines/MSEdge Win10 RS1.vmwarevm/:
Number of HFS+ compressed files: 127
Total number of files: 400
Total number of folders: 45
Total number of items (number of files + number of folders): 445
Folder size (uncompressed; reported size by Mac OS 10.6+ Finder): 31457847028 bytes / 31.46 GB (gigabytes) / 29.3 GiB (gibibytes)
Folder size (compressed - decmpfs xattr; reported size by Mac OS 10.0-10.5 Finder): 31457770231 bytes / 31.46 GB (gigabytes) / 29.3 GiB (gibibytes)
Folder size (compressed): 31457842954 bytes / 31.46 GB (gigabytes) / 29.3 GiB (gibibytes)
Compression savings: 0.0%
Approximate total folder size (files + file overhead + folder overhead): 31458642155 bytes / 31.46 GB (gigabytes) / 29.3 GiB (gibibytes)
So there is nothing compressed. This is done by:
Olivers-Air-3:Virtual Machines oliver$ afsctool -c MSEdge\ Win10\ RS1.vmwarevm/
/Users/oliver/Virtual Machines/MSEdge Win10 RS1.vmwarevm/:
Number of HFS+ compressed files: 327
Check again:
Olivers-Air-3:Virtual Machines oliver$ afsctool -v MSEdge\ Win10\ RS1.vmwarevm/
/Users/oliver/Virtual Machines/MSEdge Win10 RS1.vmwarevm/:
Number of HFS+ compressed files: 327
Total number of files: 400
Total number of folders: 45
Total number of items (number of files + number of folders): 445
Folder size (uncompressed; reported size by Mac OS 10.6+ Finder): 31457847028 bytes / 31.46 GB (gigabytes) / 29.3 GiB (gibibytes)
Folder size (compressed - decmpfs xattr; reported size by Mac OS 10.0-10.5 Finder): 20076498546 bytes / 20.08 GB (gigabytes) / 18.7 GiB (gibibytes)
Folder size (compressed): 20076670136 bytes / 20.08 GB (gigabytes) / 18.7 GiB (gibibytes)
Compression savings: 36.2%
Approximate total folder size (files + file overhead + folder overhead): 20077126994 bytes / 20.08 GB (gigabytes) / 18.7 GiB (gibibytes)
More than 11 GB of disk space are free now!
If you wonder, why you don't get such a good compression, have a look at the next page, where a patch for afsctool is explained.