Use udev to enable automatic mounting of USB flash drives

Source: Internet
Author: User
Article Title: Use udev to automatically mount a USB flash drive. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

I. It is inconvenient to mount the mount command to the specified directory on the same machine with the same USB flash drive. If you can plug it in, you can mount it to the specified directory on your own. Next we will use udev to implement this function.

II. Implementation steps

1. Insert a USB flash drive, # fdisk? L check the drive letter. Here we get sdb

Disk/dev/sdb: 8015 MB, 8015282176 bytes

255 heads, 63 sectors/track, 974 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/sdb1 1 974 7823623 + B W95 FAT32

2. # udevinfo? A? P/sys/block/sdb:

SYSFS {serial} = "0013729945E6F930762704A0"

SYSFS {manufacturer} = "Kingston"

3. # Run cd/etc/udev/rules. d to view the numbers starting with an existing rule, and create a rule that starts with a number larger than the existing one, such

# Vi 99-my-usb-storage.rules

ACCTION = "add", BUS = "usb", SYSFS {serial} = "0013729945E6F930762704A0", SYSFS {manufacturer} = "Kingston ", KERNEL = "sd *", NAME = "% k", SYMLINK + = "usbStorage _ % n ", RUN + = "/bin/mount/dev/usbStorage _ % n/tmp/work"

Mount the last part to/tmp/work.

In this way, you can directly use the USB flash drive, # df View

/Dev/sdb1 7808356 7028484 779872 91%/tmp/work

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.