Automatic mounting of USB storage devices using Raspberry Pi commands

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.