Accessing ext filesystem on macOS

A lot of people appreciate macOS because under the hood is unix (but not linux).
And that’s actually usually very nice, because most development tools can run natively – and still you have a good desktop experience.
However, sometimes the fact it’s not linux does hit you. For instance with docker, and the awful experience that is docker desktop; but no only.

Yesterday I had to make some emergency access to an SD card formatted with ext4. The only reader I have is on a mac, but macOS has no native support for that file system.
With a bit of googling, I found that there is possibility to use fuse to gain access; however all information seems a bit… vintage. Most of the articles refer to ntfs (now there is native support, no need to use fuse), or referred to obsolete versions, which do not even work any longer.

In the end, it was possible to do, but:

  • There is no comprehensive documentation.
  • Even documentation for every single steps is lacking.
  • The best documentation available has an open issue for… macOS.

Overall, the idea is simple: use macFUSE, then install additional file systems, and use them to mount a device.

Using macFUSE

Most documentation refers to osxfuse; now it’s called macFUSE. Installing it is very straightforward using brew:

brew install macfuse

Note that a reboot is suggested. I am not sure if it really is necessary, as the configuration panel works even without a reboot; but I did it.

That said, nothing really happens now. macFUSE is just a set of libraries that can be now used to develop – or just build – a file system in userland.
The configuration panel does nothing, and allows just to uninstall macFUSE.
Also, documentation on macFUSE site is a bit confusing, with information in the wiki about how to build new file systems in userland (which is always welcome) but no information on how to actually solve the problem why most people reach macFUSE.

Trying to find a solution in homebrew was also a dead end. Even in searching for fuse does find several results, most of them are not really available, not relevant or marked as deprecated. I tried one of those – as suggested on some of the old blogs I found – and nothing was working; actually one of those formulae even managed to completely block my mac when I tried to mount a device, forcing me to a power cycle.

Eventually, I stumbled upon fuse-ext2, which proved to work pretty well, but requires building locally. And in order to build locally, you need to have the full XCode, and not only the set of command line tools – I was lucky that I already had it, otherwise it would have been yet another step in yak shaving.

Note also that the instruction on the main are (at the time of writing) not working; instead a good solution is available in an open issue. Essentially, it involves creating a small script in a temporary directory and then executing it.

Finally, once it’s all setup and installed, it’s possible to mount a volume:

sudo fuse-ext2 /dev/disk2s2 /Users/roberto.liffredo/mnt
sudo umount /Users/roberto.liffredo/mnt

The mounted file system will be available at the mount point and an icon will also be placed on the desktop.

Side note: some nice commands used throughout the research

During this research, I stumbled upon a couple of nice commands that I have managed to never use in my last years using a mac :)

  • brew search for, uhm, search a formula or a cask. I never used before now, but it works quite well.
  • diskutil a utility to manage disks and volumes. Useful to know what device should be mounted.