linux U盘/SD卡 热插拔以及自动挂载完整机制
【摘要】
/mnt/nand # mmc_host mmc0: Bus speed (slot 0) = 100000000Hz (slot req 50000000Hz, actual 50000000HZ di...
/mnt/nand # mmc_host mmc0: Bus speed (slot 0) = 100000000Hz (slot req 50000000Hz, actual 50000000HZ div = 1)
mmc0: new high speed SDHC card at address 1234
mmcblk0: mmc0:1234 SA04G 3.68 GiB
mmcblk0: p1
/mnt/nand # ls -l /dev/m*
crw-rw---- 1 root root 1, 1 Jan 2 23:39 /dev/mem
brw-rw---- 1 root root 179, 0 Jan 2 23:40 /dev/mmcblk0
brw-rw---- 1 root root 179, 1 Jan 2 23:40 /dev/mmcblk0p1
crw-rw---- 1 root root 90, 0 Jan 2 23:39 /dev/mtd0
crw-rw---- 1 root root 90, 1 Jan 2 23:39 /dev/mtd0ro
crw-rw---- 1 root root 90, 2 Jan 2 23:39 /dev/mtd1
crw-rw---- 1 root root 90, 3 Jan 2 23:39 /dev/mtd1ro
crw-rw---- 1 root root 90, 4 Jan 2 23:39 /dev/mtd2
crw-rw---- 1 root root 90, 5 Jan 2 23:39 /dev/mtd2ro
crw-rw---- 1 root root 90, 6 Jan 2 23:39 /dev/mtd3
crw-rw---- 1 root root 90, 7 Jan 2 23:39 /dev/mtd3ro
crw-rw---- 1 root root 90, 8 Jan 2 23:39 /dev/mtd4
crw-rw---- 1 root root 90, 9 Jan 2 23:39 /dev/mtd4ro
brw-rw---- 1 root root 31, 0 Jan 2 23:39 /dev/mtdblock0
brw-rw---- 1 root root 31, 1 Jan 2 23:39 /dev/mtdblock1
brw-rw---- 1 root root 31, 2 Jan 2 23:39 /dev/mtdblock2
brw-rw---- 1 root root 31, 3 Jan 2 23:39 /dev/mtdblock3
brw-rw---- 1 root root 31, 4 Jan 2 23:39 /dev/mtdblock4
/mnt/nand # mmc0: card 1234 removed
·增加script “mdev.conf”(/etc/mdev.conf)
# Block devices
# for usb
sd[a-z][0-9] 0:6 660 */path/automount.sh /tmp/vrecord/videoclips/
# for sd/mmc card
mmcblk[0-9]p[0-9] 0:6 660 */path/automount.sh /tmp/vrecord/videoclips/
·增加script “automount.sh”(/path/automount.sh)
#!/bin/sh
destdir=$1
my_umount()
{
if grep -qs "^/dev/$1 " /proc/mounts ; then
umount "${destdir}";
fi
[ -d "${destdir}/$1" ] && rmdir "${destdir}"
}
my_mount()
{
mkdir -p "${destdir}" || exit 1
usleep(20)
if [ -e /dev/${1}p1 ]; then
devname=${1}p1
else
devname=${1}
fi
if ! mount -t auto -o sync "/dev/$1" "${destdir}"; then
# failed to mount, clean up mountpoint
rmdir "${destdir}"
exit 1
fi
}
case "${ACTION}" in
add|"")
my_umount ${MDEV}
my_mount ${MDEV}
;;
remove)
my_umount ${MDEV}
;;
esac
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
文章来源: blog.csdn.net,作者:悟空胆好小,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/xushx_bigbear/article/details/123364818
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)