Implementation of automatic mount of USB storage device in embedded Linux system

Source: Internet
Author: User

There are usually two ways to implement automatic mounting of USB storage devices like USB drive: Udev and Mdev. Because Udev is relatively simpler and has better support in the kernel, select Udev to implement functionality.


# cd/etc/udev/rules.d/

Compile a rules file, such as: 50-udev-default.rules, add the following at the end of the file:

kernel== "sd[a-z][0-9]", name=%k ", owne=" root ", group=" root "
action== "Add", kernel== "sd[a-z][0-9]", run+= "/bin/mount/dev/%k/mnt/usb"
action== "Remove", kernel== "sd[a-z][0-9", run+= "/bin/umount/mnt/usb"


After you save the exit, use the following command to make the new content take effect (restart the system also.)

Udevcontrol Reload_rules 50-udev-default.rules


This also supports the hot plug of the USB drive.

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.