9

Windows has a useful feature where files can be transparently compressed/decompressed on the fly. This is activated by right-clicking on a File, directory or Disk, selecting Properties and then clicking on the Advanced... button to check the box "Compress contents to save disk space".

When enabled, files are transparently compressed when written to disk and decompressed when read from disk. This is managed by the file system and OS as needed.

I'd like a Mac OS equivalent of this. There's nothing obvious in the Finder and a preliminary search turns up nothing conclusive.

Is there a macOS option equivalent to this? Either natively or through 3rd party software?

10

5 Answers 5

2

This is actually a feature of the NTFS file system (I believe...) and hails from the days when disks were more expensive, much smaller and measured in megabytes. Microsoft has kept this functionality in all versions of windows since the early days of NT.

While you can manually compress files to save space I realize that is not what you are looking for. However I am not aware of a utility or feature of macOS that allows automatic file system level compression of disk contents.

Note that in an article on ArsTechnica it is noted that it sounds like file system compression may be coming to APFS in the (near or otherwise) future.

There may be something in APFS that allows this but so far neither Apple nor any third parties (that I am aware of) has implemented this functionality.

1
  • 3
    "hails from the days when disks were more expensive and much smaller" - with SSDs we're still hailing today. Commented Oct 11, 2019 at 17:21
1

Note: this is not exactly the end-to-end solution on MacOS but it leverages the transparent compression in NTFS.

I was looking for the same functionality as I work with large uncompressed rasters (DEM - digital elevation models) and I had to make sure I will not run out of the disk space while processing these files.

I've done this on USB drive. I attached the drive to Parallels Desktop (but I believe it can Virtual Box or any physical windows machine), formatted it using NTFS, created a folder and marked it as compressed - all in Windows.

Then I mounted the drive to my MacBook. (I use NTFS for Mac from Paragon Software but other apps like this one should handle it). Any file that i wrote to the folder created on windows was compressed automatically.

enter image description here

1
  • So, I presume one could achieve similar behavior by creating an NTFS partition on the internal drive?
    – WGroleau
    Commented Apr 6, 2020 at 19:06
1

Use AFSCTool https://github.com/RJVB/afsctool.git to compress files in a directory.

AFSCTool tells the file system to compress the files, and then they will be decompressed on-demand by the file system. If you later create any new files or modify any files they will be uncompressed, so I just run it weekly on older subfolders that haven't been touched in 10 weeks (6 million seconds) using a bash script:

export PATH=/usr/local/bin:$PATH
now="$(date +%s)"
find . -maxdepth 1 -mindepth 1 -type d -print0 |
    while IFS= read -r -d '' line; do 
        dirdate="$(stat -f %m $line)"
        # echo $now
        # echo $dirdate
        let diff="${now} - ${dirdate}"
        echo "Seconds since directory $line modified is $diff"
        if [ "$diff" -gt 6000000 ]; then
           echo "Compressing $line"
           afsctool -c -j1 -6 "$line"
        fi
    done
2
  • If I'm reading you right, that's only appropriate for files not commonly accessed. Whereas, NTFS compression was great for frequently accessed files (since the time to decompress by CPU was less than the time saved reading a smaller file onto the disk head) Commented Jan 30, 2023 at 22:44
  • That would be worth testing out. Perhaps with Apple File System Compression the time to decompress is also faster than the time to read. But, there's no way to compress-on-write in Apple File System nor HFS+. Whereas in NTFS the compression can save time on write and disk wear as well. Commented Feb 1, 2023 at 13:42
0

Short answer

There is no need for users to enable/disable transparent compression in macOS as it's built into the file system.

Long answer

In the pre-Mac OS X days there were a number of products that basically achieved the same thing. Disk Doubler was probably the most popular (because it started the trend), but other options included AutoDoubler and SuperDisk!

These products were very popular at the time (from memory, Disk Doubler was one of the most popular software packages sold for the Mac platform). However, the reason for their popularity was largely due to the small hard drive sizes of that era. As time went by the need (and popularity) for these packages waned significantly - mainly because the HFS+ file system was released in the late 1990s and this allowed much smaller block sizes and much larger disk capacities.

Over time Apple continually improved the HFS+ file system so that by the time Mac OS X 10.6 was launched it actually incorporated AppleFSCompression which is essentially the same feature you're referring to. Any software using Apple's APIs could take advantage of this, however at the time this was not enabled by default due to various reasons - users needed to use the Terminal to take advantage of it.

As time went by and software was updated, the use of Apple's compression technology became mainstream. With Mac OS X El Capitan (10.11) and iOS 9, Apple made further improvements by introducing a compression algorithm known as LZFSE into the operating system. This has since been adopted in watchOS and tvOS as well.

While the LZFSE algorithm is the fastest and most energy efficient option offered by Apple, it's not the only option available to developers. LZ4, LZMA and ZLIB are other options and there are various reasons why one may be chosen over another.

In summary, the operating system uses compression natively and, in the case of Apple and 3rd party software, developers have a number of options in terms of the compression algorithm they opt for. Regardless of the choice, compression is transparently taking place all the time and from a user's perspective there is nothing they need to do to take advantage of it.

4
  • 6
    I have never seen any evidence that supports your assertion that Apple makes extensive use of filesystem compression. Please cite your source. Commented Sep 18, 2018 at 2:35
  • 7
    There may very well be kernel-level support for compression, but that doesn't mean the filesystem uses it.
    – w00t
    Commented Apr 3, 2019 at 7:45
  • 1
    This looks highly improbable, -1. I got to this question because I am running out of disk space in a particular scenario: I mount a RAM disk and dump massive amounts of diagnostic HTML files into it. Periodically I run out of space and I was looking for the equivalent of NTFS's compress this folder content automatically. Guess what? If there were some magic pixie compressors working in the background (I am on Mojave) then I wouldn't have a problem because HTML compresses extremely well. I have 150MB in about 180 files which are probably 1 MB each, but would compress very well.
    – JL Peyret
    Commented Feb 27, 2020 at 21:09
  • I mean, it could be the RAM disk mount particulars, but otherwise other people have expressed doubts about your claims, which are long on historical aspects - and certainly full of praise of Apple's greatness - but very short on hard technical info, with not much to back it up, despite previous comments requesting details.
    – JL Peyret
    Commented Feb 27, 2020 at 21:12
-1

Since I have an external Seagate drive (a couple actually) I am making one of them NTFS mountable and will use compression and use the Parallels mounting tip above... if it works I'll add the "cookbook" here...

I am downloading the seagate Paragon Driver from the MacOS Support page from Seagate...

R

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .