
Also note that until something attempts an access, the automounted drives will not appear in the output of the mount command. No hard-coded fstab entries are required. If no further accesses are made within that period the drive is unmounted. When an access is attempted on the automounted drive, SystemD kicks-in and mounts it for the period specified the automount file's directive " TimeoutIdleSec". mount file to " /dev/sdc1" and " /dev/sdd1" for the 3rd & 4th mounts when copying and pasting. Be sure and change the " What" directive in the. Only the automount service need be enabled.Įxtending the script to ALL 4 USB Ports: I've given you (2) automounts so can see the pattern for creating additional mounts.

mount file created by the script when raising the mount, but that's it. mount file, I only enable the automount service.

Service Enabling: You'll note int he script that although there is a. Mount Naming: Be aware if you change my directory naming convention in the script that the SystemD mount file created should be named same as its mountpoint as specified in " Where" directive in the. Just cut-n-paste this snippet into a file and chmod 700 it and you're set.

This is arbitrary- set it for as long or short as you wish. The default mount period I've set is 300 seconds (5 min) in the " TimeoutIdleSec" directive in the. mount file, but obviously tweak this value to one that's appropriate for your USB storage format. I specified the " exfat" for the " Type" directive in the. Here's a general script I provide that you can just tweak a bit for your own use-case to quickly configure automounting as a SystemD service (on a Pi or any other SystemD Linux host).
