### USB hard drives / thumb drives

KERNEL=="sd[a-z][0-9]", SUBSYSTEMS=="usb", ACTION=="add",    RUN+="/bin/systemctl start usb-mount@%k.service"
KERNEL=="sd[a-z][0-9]", SUBSYSTEMS=="usb", ACTION=="remove", RUN+="/bin/systemctl stop  usb-mount@%k.service"

### USB floppy drives

# Detect a USB add with floppy disk already inserted, or a floppy disk
# insertion on an existing USB drive       
KERNEL=="sd[a-z]", SUBSYSTEMS=="usb", ATTRS{bInterfaceClass}=="08", ATTRS{bInterfaceSubClass}=="04", \
  ACTION=="add|change", ENV{ID_FS_USAGE}=="filesystem" RUN+="/bin/systemctl start usb-mount@%k.service"
# Detect a floppy disk ejection
KERNEL=="sd[a-z]", SUBSYSTEMS=="usb", ATTRS{bInterfaceClass}=="08", ATTRS{bInterfaceSubClass}=="04", \
  ACTION=="change", ENV{ID_FS_USAGE}=="", RUN+="/bin/systemctl stop usb-mount@%k.service"
# Detect a USB removal (floppy disk may or may not be inserted, but the
# service is idempotent)
KERNEL=="sd[a-z]", SUBSYSTEMS=="usb", ATTRS{bInterfaceClass}=="08", ATTRS{bInterfaceSubClass}=="04", \
  ACTION=="remove", RUN+="/bin/systemctl stop usb-mount@%k.service"
