write two rules in udev to launch a systemd unit when a usb device is connected or disconnected through this file /etc/udev/rules.d/50-local.rules
inside the file create those two rules:
KERNEL=="sd[a-z][0-9]", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/bin/systemctl --no-block start usb-mount@%k.service" KERNEL=="sd[a-z][0-9]", SUBSYSTEMS=="usb", ACTION=="remove", RUN+="/bin/systemctl --no-block stop usb-mount@%k.service"
* the %k is a udev placeholder that contain the devicename ( like sdc1 )
create a systemd unit /etc/systemd/system/usb-automount@.service
[Unit]
Description=Automount USB Drive on /mnt/%i
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/bin/mount -m /dev/%i /mnt/%i
ExecStop=/usr/bin/umount /dev/%i
* We use the @ in the name of the unit for using the %i placeholder inside the unit that contain the called unit name ( after the @ )
* mount -m will create the folder if it does not already exists