Embedded Linux Implementation mdev SD card and USB stick automatic mount and unload method mdev.conf

Source: Internet
Author: User

First refer to these blogs to do some understanding: http://linux.chinaunix.net/techdoc/install/2009/11/18/1144936.shtml

Http://www.cnblogs.com/leaven/archive/2010/09/17/1828896.html, can also Baidu mdev.conf view other articles.


The kernel is sure to support Mdev and hotplug features.

Etc directory to have this file mdev.conf, the content is as follows (other similar):

SD[A-Z][0-9]      0:0 666        @/etc/hotplug/usb/udisk_insertsd[a-z]           0:0 666        $/etc/hotplug/usb/udisk_ REMOVEMMCBLK1P[0-9]   0:0 666        @/etc/hotplug/sd/sd_insertmmcblk1         0:0 666        $/etc/hotplug/sd/sd_remove
From the above can be seen dependent on four scripts, corresponding to the USB drive and SD card mount and uninstall.

Create the Udisk_insert and udisk_remove two scripts in the/ETC/HOTPLUG/USB directory with the following contents:

Udisk_insert:

#!/bin/shecho "Usbdisk insert!" >/dev/consoleif [-E "/dev/$MDEV"]  ; then  mkdir-p/mnt/usbdisk/$MDEV  mo unt/dev/$MDEV/mnt/usbdisk/$MDEV fi

Udisk_remove:

#!/bin/shecho "Usbdisk remove!" >/dev/consoleumount-l/mnt/usbdisk/sd*rm-rf/mnt/usbdisk/sd*

Create the Sd_insert and sd_remove two scripts in the/ETC/HOTPLUG/SD directory with the following contents:

Sd_insert:

#!/bin/shecho "SD card insert!" >/dev/console if [-E "/dev/$MDEV"]; Then  mkdir-p/mnt/sdcard/sd  mount-rw/dev/$MDEV/mnt/sdcard/sd fi

Sd_remove:

#!/bin/shecho "SD card remove!" >/dev/consoleumount-l/mnt/sdcard/sd*rm-rf/mnt/sdcard/sd*

This enables automatic recognition of mounts and uninstalls.


Embedded Linux Implementation mdev SD card and USB stick automatic mount and unload method mdev.conf

Related Article

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.