top of page
  • Writer's pictureNick Lansley

Compressing MacOS / OSX files transparently using AFSCTOOL

As my Macbook Pro goes through a phase of getting full and needing to have its disk swept of old files from time to time, I wish that MacOS had a ‘compression’ tag for its files like Windows has.That way, files would remain on the disk in a compressed state without having to move them into a compressed archive file such as those created by ZIP and 7Z.

Well of course now I find out that MacOS has indeed such a capability, but it needs a command-line utility installed to set it up!

If you’ve followed my technical articles on this blog, you should have Homebrew installed. If not, head here.

Now you need to install afsctool with this command:

brew install afsctool

That’s it! Before we set it work I better show what got me started on this journey: I discovered that most Apple-provided applications such as iMovie and Aperture are already compressed.

By highlighting some apps in the Applications folder such as Garageband and tapping CMD + I (for ‘Info’) on the keyboard, I discovered this:

Notice that the Size says: 1,312,325,403 bytes (1.05 GB on disk)

Here’s Aperture with an even more impressive compression ratio:

The size says: 1,012,034,825 bytes (585.8 MB on disk)

My investigation led to the revelation (for me) that the HFS+ filesystem supports transparent compression and that Apple tend to use it for downloadingand installingtheir own large applications. It’s weird how Apple keeps this quiet – there’s no checkbox to simply turn it on for files, and only the faintest of clues uncovered by checking the size of files on disk.

So here’s how I turned it on for other files:

Let’s take Microsodt OneNote, which yields this information:

Size: 895,315,444 bytes (928.8 MB on disk) – so not compressed at all. I also noted that the full application filename is “Microsoft” and we know it is in the /Applications folder:

Going back to terminal, I typed this command (it needs to run under sudo):

sudo afsctool -s 10 -vc "/Applications/Microsoft"

After typing the sudo password, nothng happened for a good minute while the compression ran, and then this response:

Number of HFS+ compressed files: 11981
Total number of files: 12247
Total number of folders: 1327
Total number of items (number of files + number of folders): 13574
Folder size (uncompressed; reported size by Mac OS 10.6+ Finder): 895315444 bytes / 928.8 MB (megabytes) / 885.8 MiB (mebibytes)
Folder size (compressed - decmpfs xattr; reported size by Mac OS 10.0-10.5 Finder): 463997598 bytes / 474.1 MB (megabytes) / 452.1 MiB (mebibytes)
Folder size (compressed): 470432815 bytes / 480.5 MB (megabytes) / 458.3 MiB (mebibytes)
Compression savings: 47.5%

..and when I looked at the Info window, the size now said:

895,315,444 bytes (474.1 MB on disk) – nearly half the size!

Microsoft OneNote then ran as usual as if nothing had happened.

Next, I compressed Word, Excel and PowerPoint, achieving 40%+ compression and no effect on those applications at all. If the ability to update those applications is affected I’ll post an update here.

For now, I’m probably going to go a bit compression mad and get loads of disk space back. What could possibly go wrong?! (BTW I will perform a full disk backup before I do this!).

254 views0 comments

Recent Posts

See All

The Daily Peacehaven Timelapse Video

A couple of posts ago I wrote about the ‘WeatherPi’ Raspberry Pi that collects the latest weather readings every 10 minutes and make a decision whether or not to lower the storm shutters in front of o

Live weather data and images!

I wanted to take the peaceful few days between Christmas and New Year to really refresh the data collected from the local weather that helps our Raspberry Pi-powered Storm Shutters Controller (known a

Post: Blog2_Post
bottom of page