In Linux, we often use USB flash drives and SD card mounting. It is very difficult to manually mount or detach each time. We can use the following methods to automatically mount or detach USB flash drives and SD cards.
1. Add the following statement to/etc/init. d/RSC:
Echo/sbin/mdev>/proc/sys/kernel/hotplug
2. The file "medv. conf" under "/etc/" contains the following content:
SD [A-Z] [0-9] 0:0 666 @ (/etc/hotplug/insert. Sh $ mdev $ subsystem)
SD [A-Z] 0: 0 $666 $ (/etc/hotplug/remove. Sh $ mdev $ subsystem)
UB [A-Z] [0-9] 0: 0 666 @ (/etc/hotplug/insert. Sh $ mdev $ subsystem)
UB [A-Z] 0: 0 $666 $ (/etc/hotplug/remove. Sh $ mdev $ subsystem)
Mmcblk [0-9] P [0-9] 0: 0 666 @ (/etc/hotplug/insert. Sh $ mdev $ subsystem)
Mmcblk [0-9] 666 $ (/etc/hotplug/remove. Sh $ mdev $ subsystem)
3. Create the following folder hotplug under/etc/, and create the following file under the hotplug directory, including the following content
Insert. sh:
If [-n "$1"]; then
If [-B/dev/$1]; then
If [! -D/media]; then
Mkdir-P/Media
Fi
If [! -D/Media/$1]; then
Mkdir-P/Media/$1
Fi
Mount/dev/$1/Media/$1
If [$? -Ne 0]; then
Rm-RF/Media/$1
Fi
Fi
Fi
Remove. sh:
Mounts = $ (Mount | grep $1 | cut-d'-F3)
Umount $ mounts
Rm-RF $ mounts
Insert a USB flash drive, SD, and other devices to create a folder in the/Media Directory of the root directory and mount the disk files used by the peer.