Suggestions needed for udev, udisks, autofs, notification setup for a complete automounting solution on Linux

autofsautomountinggentoonetworkingudev

Continuing on Automounting plugged devices in linux, which left things a bit basic. Running Gentoo, I'm automounting a combination of local and network devices on my laptop with autofs-5.0.4-r5. Doing autofs alone gives me a couple of gripes:

  • I have to predefine names for mountpoints per device, but occasionally after rebooting my MMC card reader switches positions with my bootable USB stick
  • I'd like automatic LABEL based mountpoints to appear, autofs alone AFAIK can't do that

Which is what udev and udisks are certainly capable of doing. But:

  • I don't want the filesystem to be mounted automatically when plugging the device, just give me the ghost mount point named LABEL

Actual filesystem mounting should only occur on first access to the mountpoint, just like autofs ghosting works. This should lower the risk of dirtying filesystems by accidentally unplugging devices, while still providing great accessibility.

On top of this I could use knowing at all times what's going on, in my DE.

  • Is there a system tray app that is capable of indicating status of all automounts i.e. green = nothing is mounted, red = something is mounted?
  • Is there a distribution-agnostic way to provide filesystem (un)mount operation notifications, for example using notify-send? What about Gentoo-specific, that works for me too. Scripting udev doesn't help with NFS and CIFS, right?

This combo should be the ultimate automount setup, or am I missing something?

Best Answer

This is all feasible with udev. Have a look at UAM, which seems to address most of the issues you've mentioned, but actually does mount automatically. If you like, you could make use of the great capabilities it provides, but modify it so that the media are not mounted automatically. You could also contact the author and suggest your non-automatic mounting approach as a new feature. Meanwhile, have a brief look at its capabilities:

  • It works on top of udev, making it DE-independent and event-based. (It also suggests a workaround for optical media that might not be spotted by udev.)
  • Lets you define MOUNTPOINT_TEMPLATES that can solve the naming issue you've mentioned in a number of custom ways (see uam.conf), potentially also using LABEL (as you desired)
  • Notification mechanisms are supported, you'll just need to adjust them to your DE-specific needs.
  • It seems to have a clear design, letting you easily locate where, when and how each action is triggered.
Related Question