一、实现udev规则
创建规则:sudo vi /etc/udev/rules.d/usb.rules
SUBSYSTEMS=="usb",SUBSYSTEM=="block",ACTION=="add",RUN{program}+="/bin/mkdir /mnt/%k",RUN{program}+="/usr/bin/systemd-mount --no-block --collect /dev/%k /mnt/%k"
SUBSYSTEMS=="usb",SUBSYSTEM=="block",ACTION=="remove", RUN{program}+="/usr/bin/systemd-umount /mnt/%k",RUN{program}+="/bin/rmdir /mnt/%k"
二、重启规则
sudo service udev restart