分析:
首先,make menuconfig 检查一下 System init 的值是:procd-init
那么 是用 udev 实现热拔插的
脚本位置:/etc/hotplug.d/block/10-mount
mount_ntfs() {
case "${DEVNAME}" in
sda*)
mkdir -p /mnt/exUDISK
/usr/bin/ntfs-3g /dev/${DEVNAME} /mnt/exUDISK -o rw,noatime,nodiratime,nosuid,nodev
exit
;;
mmcblk*)
mkdir -p /mnt/SDCARD
/usr/bin/ntfs-3g /dev/${DEVNAME} /mnt/SDCARD -o rw,noatime,nodiratime,nosuid,nodev
exit
;;
*)
;;
esac
}
/sbin/block hotplug || {
if [ -n "${DEVNAME}" ] && [ "${ACTION}" = "add" ]; then
[ -f "/etc/config/fstab" ] && {
grep "option.*device.*${DEVNAME}" /etc/config/fstab &>/dev/null && {
if [ -x "/usr/bin/ntfs-3g" -a -x "/usr/bin/ntfs-3g.probe" ]; then
/usr/bin/ntfs-3g.probe --readwrite /dev/${DEVNAME} &>/dev/null
case $? in
0)
mount_ntfs
;;
12)
echo "${DEVNAME} doesn't have a NTFS filesystem"
;;
16)
echo "The volume is already exclusively opened and in use by a kernel driver or software."
break;
;;
*)
echo "Something wrong on file system of ${DEVNAME}. Fixing. Please wait for a few seconds"
[ -x "/usr/bin/ntfsfix" ] && /usr/bin/ntfsfix /dev/${DEVNAME}
mount_ntfs
;;
esac
fi
}
}
fi
}
改成这样:
#!/bin/sh
echo "------- $ACTION,$DEVNAME," > /dev/console
if [ "$ACTION" = "add" ]; then
if [ -b "$DEVNAME" ]; then
if [ "$SUBSYSTEM" = "block" ]; then
# 检查文件系统类型
FS_TYPE=$(udevadm info --query=all --name="$DEVNAME" | grep 'ID_FS_TYPE=' | cut -d'=' -f2)
if [ "$FS_TYPE" = "exfat" ]; then
MOUNT_POINT="/mnt/exUDISK/"
mkdir -p "$MOUNT_POINT"
mount -t exfat "$DEVNAME" "$MOUNT_POINT"
fi
fi
fi
elif [ "$ACTION" = "remove" ]; then
MOUNT_POINT="/mnt/exUDISK/"
if [ -d "$MOUNT_POINT" ]; then
umount "$MOUNT_POINT"
# rmdir "$MOUNT_POINT"
fi
fi
root@TinaLinux:/#
root@TinaLinux:/#
root@TinaLinux:/# cat /etc/hotplug.d/block/10-mount
#!/bin/sh
echo "------- $ACTION,$DEVNAME," > /dev/console
if [ "$ACTION" = "add" ]; then
if [ -b "$DEVNAME" ]; then
if [ "$SUBSYSTEM" = "block" ]; then
# 检查文件系统类型
FS_TYPE=$(udevadm info --query=all --name="$DEVNAME" | grep 'ID_FS_TYPE=' | cut -d'=' -f2)
if [ "$FS_TYPE" = "exfat" ]; then
MOUNT_POINT="/mnt/exUDISK/"
mkdir -p "$MOUNT_POINT"
mount -t exfat "$DEVNAME" "$MOUNT_POINT"
fi
fi
fi
elif [ "$ACTION" = "remove" ]; then
MOUNT_POINT="/mnt/exUDISK/"
if [ -d "$MOUNT_POINT" ]; then
umount "$MOUNT_POINT"
# rmdir "$MOUNT_POINT"
fi
fi
放在SDK这个位置:
target/allwinner/a133-a11/base-files/etc/hotplug.d/block/10-mount
离线