Automatically Mount exfat File Systems in Linux

I do quite a bit of video on my camera, and the easiest way to transfer these rather large files to my computer is to insert the SD card into an SD card connected to my computer.

impossibleI wanted this to be as painless as possible, so I want the computer to auto mount anything inserted, without any distracting GUI stuff popping up.

The usbmount package was suggested, and it almost works. After inserting a card into the reader, it mounts it… but then three seconds later the mount point goes AWOL. If I df, I get this message:

# df
 df: ‘/media/usb1’: Transport endpoint is not connected

And it turns out that this is more complicated than you’d think, because udev and systemd.

The file system on the cards I use is exfat. exfat is a fuse (userland) file system, so usbmount ends up starting a userland process to handle the file system.

And you can’t do that from udev. It does not allow “long lived processes”: It’ll kill off everything started by an udev rule, and that includes the fuse process.

So now what?

It turns out that there is no easy way to do something as trivial as automatically mount an exfat SD card. But there’s a fiddly and yucky way, involving systemd units and other stuff that no sane person should feel necessary to know about, so I’ve created a little package for you with some files that you can just copy to the correct locations, and it’ll Just Work.

gladFor the next two weeks, until the udev/systemd brain trust fucks us all over again.

I’ve tested these files on Debian Jessie in mid July 2016, and it worked then.  Your mileage will vary.  I’ve cobbled this together by Googling for hours and mashing up various recipies that almost work.  Neither udev nor systemd are very good at reporting errors, so it’s all trial and error…

One thought on “Automatically Mount exfat File Systems in Linux”

Leave a Reply