This section briefly introduces how to automatically mount USB storage devices under the command line. In the Linux gnome/kde window, there is a mobile Storage Management Program, which can automatically mount mobile storage devices, however, the mount command is usually used to manually mount the USB storage device under the command line.
By adding a rule configuration file to the device management service udev in linux, You can automatically mount USB storage devices under the command line.
Enter the command
Sudo nano/etc/udev/rules. d/10-usbstorage.rules
Copy and paste the script to the editing window.
KERNEL! = "Sd *", GOTO = "media_by_label_auto_mount_end"
SUBSYSTEM! = "Block", GOTO = "media_by_label_auto_mount_end"
IMPORT {program} = "/sbin/blkid-o udev-p % N"
ENV {ID_FS_TYPE }== "", GOTO = "media_by_label_auto_mount_end"
ENV {ID_FS_LABEL }! = "", ENV {dir_name} = "% E {ID_FS_LABEL }"
ENV {ID_FS_LABEL} = "", ENV {dir_name} = "Untitled-% k"
ACTION = "add", ENV {mount_options} = "relatime, sync"
ACTION = "add", ENV {ID_FS_TYPE} = "vfat", ENV {mount_options} = "iocharset = utf8, umask = 000"
ACTION = "add", ENV {ID_FS_TYPE} = "ntfs", ENV {mount_options} = "iocharset = utf8, umask = 000"
ACTION = "add", RUN + = "/bin/mkdir-p/media/% E {dir_name }", RUN + = "/bin/mount-o $ env {mount_options}/dev/% k/media/% E {dir_name }"
ACTION = "remove", ENV {dir_name }! = "", RUN + = "/bin/umount-l/media/% E {dir_name }", RUN + = "/bin/rmdir/media/% E {dir_name }"
LABEL = "media_by_label_auto_mount_end"
Save and exit
The usb storage device is automatically mounted to the directory under the/media Directory and supports the utf8 format of Chinese file names.