linux rootfs 指令碼實現 USB 磁碟機自動掛載記錄

來源:互聯網
上載者:User


author:DriverMonkey

mail:bookworepeng@hotmail.com

qq:196568501

phone:13410905075

-歡迎交流

測試硬體平台-am335x(linux 3.2)

前提條件:1.busybox 已經支援 mdev

                     2.核心已經直至隨身碟

1) 在etc/init.d/ 目錄下船艦rcS 指令碼

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

2)在etc/init.d/ 目錄下船艦 sysfs.sh 指令碼

#!/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) 在etc 下建立 mdev 設定檔

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) 在 /etc/hotplug/usb 下建立 udisk_insert 指令檔

#!/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

在 /etc/hotplug/usb 下建立 udisk_remove 指令檔

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.