Linux rootfs script for automatic mounting of U Disks

Source: Internet
Author: User

 

Author: DriverMonkey

Mail: bookworepeng@hotmail.com

Qq: 196568501

Phone: 13410905075

-Welcome to the discussion

Testing hardware platform-am335x (linux 3.2)

Prerequisites: 1. busybox supports mdev

2. the kernel has reached the USB flash drive.

1) Ship-to-ship rcS script in the etc/init. d/directory

#! /bin/sh/bin/mount -a/bin/SDG800/etc/init.d/sysfs.sh

2) run the sysfs. sh script on the ship under the etc/init. d/directory.

#!/bin/shif [ -e /proc ] && ! [ -e /proc/mounts ]; then  mount -t proc proc /procfiif [ -e /sys ] && ! [ -e /sys/kernel ] && grep -q sysfs /proc/filesystems; then  mount sysfs /sys -t sysfsfimount -t tmpfs mdev /devmkdir /dev/ptsmount -t devpts devpts /dev/ptsecho /sbin/mdev>/proc/sys/kernel/hotplugmdev -sexit 0

3) Create the mdev configuration file under etc

sd[a-z][0-9]  0:0 0660  @/etc/hotplug/usb/udisk_insertsd[a-z]       0:0 0660  $/etc/hotplug/usb/udisk_remove#mmcblk[0-9]p[0-9]  0:0 0660  @/etc/hotplug/sd/sd_insert#mmcblk[0-9]        0:0 0660  $/etc/hotplug/sd/sd_remove

4) create a udisk_insert script file under/etc/hotplug/usb

#!/bin/shecho "MDEV is ${MDEV}"if [ -d /sys/block/*/$MDEV ]  ; then  mkdir -p /media/udisk  mount /dev/$MDEV /media/udisk -t vfat -o utf8=1if [ -f /media/udisk ];thenecho "mount udisk usccessfully"fifi

Create a udisk_remove script file under/etc/hotplug/usb

 #!/bin/shumount -ltf /media/udiskrm -rf /media/udiskecho "remove you udisk safely!"

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.