Debian USB, Revisited

I'm in the process of setting up a laptop with the current version of Debian Testing (Jessie, 8.0), and found that the default for automounting vfat usb drives is still to mount them as root:root, which is not very convenient if you want to use them with your user account. I want to mount them as root:floppy, so that my user account, in group 'floppy', has permissions to write and eject them. I have written on this topic previously, but this time around, I found that there is a little more that one needs to know to set up usb drive automounting nicely on Debian. I did a lot of searching and reading on this topic, and found a lot of incomplete and conflicting information, so when I solved the problem that I had, I decided to blog about it.

USB automounting is supported in a default install of current Debian Testing when in X. This function is performed by Gnome 3's file manager, Nautilus. Now, why a GUI file manager is concerning itself with hardware management, I couldn't venture to guess, but that is the way it's set up. Nautilus provides obnoxious features like reacting to a usb drive being plugged in by popping up a window over whatever you happen to be doing, to ask you what you might want to do instead. Fortunately, this is the least of our problems, and I'll come back to it later.

The best way to setup usb automounting still seems to be to use the 'usbmount' package. It works whether you are in X or not, and is independent of whatever desktop environment you happen to be using. It does not conflict with Nautilus, either — you can use both if you like. The first step is to install usbmount, and then edit /etc/usbmount/usbmount.conf as I described in my previous post on this topic. Basically, just edit the value of the variable FS_MOUNTOPTIONS, following the example given in the file.

The problem that I ran into was that although my usb drives were automounting, the system was not respecting the FS_MOUNTOPTIONS that I had set, and still mounting as root:root. I searched the web and asked around to no avail. I read the informative troubleshooting section of the usbmount README (in /usr/share/doc/usbmount), and scrutinized system logs. At last, I read the source code of usbmount and found the answer.

If /etc/fstab has an entry for the device of the usb drive, then usbmount will delegate mounting to fstab, and your FS_MOUNTOPTIONS will be ignored. Simple, eh?

So the end of this story is that to use usbmount successfully, you must look at your /etc/fstab, and if it contains entries for things that you want usbmount to manage (/dev/sdb1, /dev/sdb2, /dev/sdc1 in my case), remove them. (It should go without saying, be careful here — this is not a file that you want to mess up.)

Oh, and a quick followup on Nautilus. As I said, Nautilus does not conflict with usbmount, but if you happen to want to get rid of those annoying popups, go to System Settings → Details → Removable Media, and check "Never prompt or start programs on media insertion".