您的位置:首页 > 运维架构

OpenWRT挂载U盘

2015-07-10 10:08 1916 查看
需要选中的包有:Kernel modules ---> USB Support --->



选中上面的包就可以识别USB设备了,然后挂载需要识别文件系统: Kernel modules --->Filesystems --->



选中上面就支持NTFS的文件系统了,只要插上U盘就会自动挂载到mnt目录下。此外,还需要选中语言支持,否则会有挂载警告。===========================================================================================从网上了解到,NTFS文件系统挂载后不可写:
'/etc/config/fstab'配置文件定义了系统启动时将要激活的静态文件系统和交换分区。 注意在系统启动时,包含这些文件系统和交换分区的磁盘必须是可用的,否则就只能在启动后进行手动挂载。 同样,用于加载特定文件系统的模块必须被安装或者加载到内核。 这些模块的名称可以是kmod-fs-ext3, kmod-fs-ext4, kmod-fs-vfat等。切记ntfs文件系统仍然是闭源的,并且通过kmod-fs-ntfs只能对ntfs分区进行读操作,如要进行写操作,还需要安装ntfs-3g。

[/code]我们需要用到ntfs-3g的文件系统。我们先把NTFS的选项取消,然后重新选择NTFS-3g的选项。Utilities ---> Filesystem --->



烧录完成后,在系统中看不到ntfs-3g的文件系统选项,但是这个文件格式还是可以用的,就是需要先取消挂载:
root@OpenWrt:/#ls mnt/sda1/

root@OpenWrt:/#umount /dev/sda1

umount: can't umount /dev/sda1: Invalid argument

root@OpenWrt:/#mount -t ntfs-3g /dev/sda1 /mnt/sda1/

The disk contains an unclean file system (0, 0).

The file system wasn't safely closed on Windows. Fixing.



^C

root@OpenWrt:/#umount /dev/sda1

umount: can't umount /dev/sda1: Invalid argument

root@OpenWrt:/#mount -t ntfs-3g /dev/sda1 /mnt/sda1/

root@OpenWrt:/#

root@OpenWrt:/#ls /mnt/sda1/

README                 mt7621_ddr_param.txt   readme.txt

mkconfig               mt7621_stage_sram.bin  uboot_version.h

mt7621_ddr.sh          pct                    鏂板缓鏂囦欢澶[0m

root@OpenWrt:/#

[/code]如果想要自动挂载,那么需要修改系统脚本:
#U盘,移动硬盘自动挂载脚本

编辑/etc/hotplug.d/block/10-mount  (用winscp工具连接路由,编辑文件)

___________________________以下是文件内容_________________________________

#!/bin/sh


# Copyright (C) 2009 OpenWrt.org  (C) 2010 OpenWrt.org.cn


blkdev=`dirname $DEVPATH`

if [ `basename $blkdev` != "block" ]; then


device=`basename $DEVPATH`

case "$ACTION" in

add)

mkdir -p /mnt/$device

# vfat & ntfs-3g check

if  [ `which fdisk` ]; then

isntfs=`fdisk -l | grep $device | grep NTFS`

isvfat=`fdisk -l | grep $device | grep FAT`

isfuse=`lsmod | grep fuse`

isntfs3g=`which ntfs-3g`

else

isntfs=""

isvfat=""

fi


# mount with ntfs-3g if possible, else with default mount

if [ "$isntfs" -a "$isfuse" -a "$isntfs3g" ]; then

ntfs-3g -o nls=utf8 /dev/$device /mnt/$device

elif [ "$isvfat" ]; then

mount -t vfat -o iocharset=utf8,rw,sync,umask=0000,dmask=0000,fmask=0000 /dev/$device /mnt/$device

else

mount /dev/$device /mnt/$device

fi

if [ -f /dev/${device}/swapfile ]; then

mkswap /dev/${device}/swapfile

swapon /dev/${device}/swapfile

fi

;;

remove)

if [ -f /dev/${device}/swapfile ]; then

swapoff /dev/${device}/swapfile

fi

umount /dev/$device

;;

esac


fi


________________________________文件尾_________________________________

chmod 777 /etc/hotplug.d/block/10-mount  #加运行权限

这样就完成了自动挂载

插入USB硬盘后就会自动挂载

[/code]config配置文件



然后,这个自动挂载的脚本我们最后用补丁的形式打到系统中,可以将这个补丁放到Zigbee的补丁目录下,在编译网关的时候将补丁打进去。
------------------------------------------------------------y
遇到一个问题,U盘在挂载后中文乱码,
sda1:

README                 mt7621_ddr_param.txt   uboot_version.h

a                      mt7621_stage_sram.bin  鏂板缓鏂囦欢澶[0m

mkconfig               pct

mt7621_ddr.sh          readme.txt

[/code]

来自为知笔记(Wiz)

附件列表

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: