Linux to implement the USB disk, SD card automatic mount function __linux

Source: Internet
Author: User
Tags mkdir

in Linux we often use U disk, SD card mount problem, each time manually mount or uninstall is very troublesome, we can take the following methods to achieve automatic mount or uninstall U disk, SD card

1, first in the/ETC/INIT.D/RSC to add the following statement

Echo/sbin/mdev >/proc/sys/kernel/hotplug


2, under the/etc/resume medv.conf the document, 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] 0:0 666 $ (/etc/hotplug/remove.sh $MDEV $SUBSYSTEM)


3, under the/etc/to establish the following folder HotPlug, and in the HotPlug directory to establish the following files, including the following content

insert.sh:

if [-N ' $]; 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 $ | cut-d '-f3)
Umount $MOUNTS
RM-RF $MOUNTS


insert U disk, SD and other devices, you can in the root directory of the/media directory to establish the appropriate folder, mount the correct disk files

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.