Raspberry Pi automatically mount USB storage device

Source: Internet
Author: User

A simple introduction to the implementation of the command line USB storage device automatic Mount method, Linux gnome/kde window environment has a mobile storage management program can be implemented to automatically mount the mobile storage device, but at the command line usually need to manually mount the USB storage device with the Mount command.


By adding a rule profile to the Device Management Service Udev under Linux, you can automatically mount the USB storage device at the command line


Create 10-usbstorage.rules

sudo vim/etc/udev/rules.d/10-usbstorage.rules

Copy and paste the following code

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= "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.

Inserting the USB storage device again will automatically mount to the directory below the/media directory and support the Chinese file name in the UTF8 format.

Attention:

After initializing the installation Raspbian, don't forget to configure the localization, otherwise, Chinese will be garbled

sudo raspi-config

In the Raspberry Pi software Configuration Tool window, select the 4 localisation Options Enter,

After entering, select I1 change Local, and in the Locales to be generated list, select the following:

Use the keyboard pagedown directly to the end to see the following items

[] ZH_CN. GB2312

[] ZH_CN. GBK GBK

[] ZH_CN. UTF-8 UTF8


Remove the USB flash drive using the unmount command, do not directly dial out, to the kills!

sudo unmount/media/u the name of the disk




This article is from the "Enterprise to create an exhibition" blog, please be sure to keep this source http://uppower.blog.51cto.com/1759096/1889556

Raspberry Pi automatically mount USB storage devices

Related Article

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.