I’ve been wondering how to enable automounting of USB drives on my Raspberry Pi server. The sollution is pretty simple with udev on Arch Linux.
- Create a new file
- Fill this script:
ACTION=="add",KERNEL=="sda*", RUN+="/usr/bin/mount /dev/sda1 /mnt/disk-a" ACTION=="remove", KERNEL=="sda*", RUN+="/usr/bin/umount /mnt/disk-a"
udevadm control --reload-rulesto reload the rules.
Naturally you should modify the script to your needs. What this one does for me is that when sda1 is connected, it is mounted as /mnt/disk-a (and unmounted when removed). Adding more lines like this can be used to mount more / other drives.