The following udev rules are for automounting (hotplug) USB drives with the disk partition label. If you know what udev rules are and wish to use udev to automount USB drives, then this is for you. If you are not sure about udev rules, then I'd suggest looking into usbmount, autofs, ... to install one of these Debian packages to handle the automounting.
Create the automount rules file (or edit your current rules) /etc/udev/rules.d/70-automount.rules. Copy and paste the following rules below.
Create the automount rules file (or edit your current rules) /etc/udev/rules.d/70-automount.rules. Copy and paste the following rules below.
# NOTE:
# 1. use pmount --sync if drive label ends with Sync/SYNC/sync in add action to allow removal without corruption
# 2. avoid mounting EFI partition for a HFS+ drive
KERNEL!="sd*", GOTO="media_label_end"
ENV{ID_TYPE}!="disk", GOTO="media_label_end"
IMPORT{program}="/sbin/blkid -o udev -p %N", ENV{name}="%E{ID_FS_LABEL}"
ENV{ID_FS_TYPE}=="", GOTO="media_label_end"
ENV{ID_FS_LABEL}!="EFI", GOTO="continue"
ENV{ID_PART_TABLE_TYPE}=="gpt", GOTO="media_label_end"
LABEL="continue"
ENV{name}=="", ENV{name}="%k"
KERNEL=="sd*", SYMLINK+="usb-storage/%E{name}"
ENV{name}=="*SYNC", ENV{mode}="--sync"
ENV{name}=="*Sync", ENV{mode}="--sync"
ENV{name}=="*sync", ENV{mode}="--sync"
ENV{name}!="*SYNC", ENV{mode}=""
ACTION=="add", RUN+="/usr/bin/pmount -t %E{ID_FS_TYPE} %E{mode} %E{mode2} --noatime --umask 000 %k %E{name}"
ACTION=="add", RUN+="%E{mode3}"
ACTION=="remove", RUN+="/usr/bin/pumount --yes-I-really-want-lazy-unmount %E{name}"
LABEL="media_label_end"