![自动卸载 USB 驱动器](https://linux22.com/image/1042757/%E8%87%AA%E5%8A%A8%E5%8D%B8%E8%BD%BD%20USB%20%E9%A9%B1%E5%8A%A8%E5%99%A8.png)
我曾经长期使用 ubuntu 10.10,后来换了一台新机器,所以不得不转到 Ubuntu 13.04。我现在缺少的一个功能是自动卸载 USB 驱动器。我在网上找不到简单的信息。
答案1
創建
/etc/udev/rules.d/80-usb-autounmount.rules
:# Auto-unmount USB storage (on remove): ACTION=="remove", SUBSYSTEM=="block", ENV{DEVNAME}=="/dev/sd??", RUN+="/usr/bin/logger auto umounting %k" ACTION=="remove", SUBSYSTEM=="block", ENV{DEVNAME}=="/dev/sd??", RUN+="/bin/umount /dev/%k" ACTION=="remove", SUBSYSTEM=="block", ENV{DEVNAME}=="/dev/sd??", RUN+="/bin/umount -lf /dev/%k" ACTION=="remove", SUBSYSTEM=="block", ENV{DEVNAME}=="/dev/sd???", RUN+="/usr/bin/logger auto umounting %k" ACTION=="remove", SUBSYSTEM=="block", ENV{DEVNAME}=="/dev/sd???", RUN+="/bin/umount /dev/%k" ACTION=="remove", SUBSYSTEM=="block", ENV{DEVNAME}=="/dev/sd???", RUN+="/bin/umount -lf /dev/%k"*
当然,您仍然需要小心打开的文件,主要是书面文件。
希望它能够帮助其他人。