Linux自动挂载与卸载USB设备
一、实现udev规则
SUBSYSTEMS=="block",ACTION=="add",RUN{program}+="/bin/mkdir /mnt/%k",RUN{program}+="/usr/bin/systemd-mount --no-block --collect /dev/%k /mnt/%k"
SUBSYSTEMS=="block",ACTION=="remove", RUN{program}+="/usr/bin/systemd-umount /mnt/%k",RUN{program}+="/bin/rmdir /mnt/%k"
二、重启规则
sudo service udev restart