Linux自动挂载与卸载USB设备
一、实现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
原文地址:https://blog.csdn.net/liutit/article/details/144696151
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!