第一步,添加内核相关支持
编译openwrt支持USB自动mount功能
make menuconfig
1). 添加USB相关支持
Kernel modules —> USB Support —> <*> kmod-usb-core.
Kernel modules —> USB Support —> <*> kmod-usb-ohci.
Kernel modules —> USB Support —> <*> kmod-usb-uhci.
Kernel modules —> USB Support —> <*> kmod-usb-storage.
Kernel modules —> USB Support —> <*> kmod-usb-storage-extras.
Kernel modules —> USB Support —> <*> kmod-usb2.
2). 添加SCSI支持
Kernel modules —> Block Devices —> <*>kmod-scsi-core
3). 添加USB挂载
Base system —> <*>block-mount
4). 添加自动挂载工具
Utilities —> Filesystem —> <*> badblocks
5). 添加文件系统支持
Kernel modules —> Filesystems —> <*> kmod-fs-ext4
Kernel modules —> Filesystems —> <*> kmod-fs-vfat
Kernel modules —> Filesystems —> <*> kmod-fs-ntfs
6). 添加UTF8编码,CP437编码,ISO8859-1编码
Kernel modules —> Native Language Support —> <*> kmod-nls-cp437
Kernel modules —> Native Language Support —> <*> kmod-nls-iso8859-1
Kernel modules —> Native Language Support —> <*> kmod-nls-utf8
Utilities ---> disc ---> <*> fdisk.................................... manipulate disk partition table
Utilities ---> <*> usbutils................................... USB devices listing utilities
第二步,开机自动挂载
df一下应该就可以看到挂载的USB硬盘了
下面写一个启动脚本,让路由器在启动时自动挂载USB硬盘。
vim /etc/init.d/usbdisk
写入脚本:
#!/bin/sh /etc/rc.common
START=99
STOP=10
start() {
mount -t ext3 -o noatime /dev/scsi/host0/bus0/target0/lun0/part1 /mnt
}
stop()
{
sync
umount /dev/scsi/host0/bus0/target0/lun0/part1
}
restart()
{
stop
start
}
加入可执行权限
chmod 755 /etc/init.d/usbdisk
加入到启动目录
ln -s /etc/init.d/usbdisk /etc/rc.d/S99usbdisk
第三步,热插拔支持
自动挂载脚本,在/etc/hotplug.d/block/创建一个30-usbmount的文件, #!/bin/sh 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 done ;; esac【http://wenku.baidu.com/link?url=UIUZFGuZ0iNXmjh6N3EWodiR_Ybbw7q_MFxBnwbDusg12eWkVcEFEAiRwg9jRSmPyO_mPKfA7XijVDgjpAeNHfoyIiR7z8Gdmev8yWuVHxG###】
【相关资源来自网络】