openwrt U盘热插拔自动挂载

  • 添加USB相关支持
    Kernel modules —> USB Support —> <*> kmod-usb-core.  ##默认已经选了
    Kernel modules —> USB Support —> <*> kmod-usb-ohci.  ##默认已选 old usb1.0
    Kernel modules —> USB Support —> <*> kmod-usb-uhci.  ## usb1.1
    Kernel modules —> USB Support —> <*> kmod-usb-storage.
    Kernel modules —> USB Support —> <*> kmod-usb-storage-extras.
    Kernel modules —> USB Support —> <*> kmod-usb2.  ##默认已经选了 usb2.0

  • 添加SCSI支持
    Kernel modules —> Block Devices —> <*>kmod-scsi-core  ##默认已经选了 usb3.0

  • 添加USB挂载
    Base system —> <*>block-mount

  • 添加文件系统支持
    Kernel modules —> Filesystems —> <*> kmod-fs-ext4 (移动硬盘EXT4格式选择)
    Kernel modules —> Filesystems —> <*> kmod-fs-vfat(FAT16 / FAT32 格式 选择)
    Kernel modules —> Filesystems —> <*> kmod-fs-ntfs (NTFS 格式 选择)

  • 退出保存 make V=99

自动挂载U盘:编辑 /etc/hotplug.d/block/10-mount 写入以下内容
#!/bin/ash

case "$ACTION" in
	add)
		for i in $(ls /dev/ | grep 'sd[a-z][1-9]')
		do
			mkdir -p /mnt/$i
			mount -o iocharset=utf8,rw /dev/$i /mnt/$i
			if [ $? -ne 0 ]
			then
				mount -o rw /dev/$i /mnt/$i
			fi
		done
		;;
	remove)
		MOUNT=`mount | grep -o '/mnt/sd[a-z][1-9]'`
		for i in $MOUNT
		do
			umount $i
			if [ $? -eq 0 ]
			then
				rm -r $i
			fi
		done
		;;
esac

你可能感兴趣的:(openwrt U盘热插拔自动挂载)