Enable automatic mounting of USB flash drives and SD cards in Linux

Source: Internet
Author: User

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.

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.