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