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

openwrt挂载U盘

2014-11-13 17:44 232 查看
Openwrt挂载U盘

1、内核编译配置:

Kernel modules  ---> 

USB Support  ---> 

-*- kmod-usb-core

<*> kmod-usb-ohci

<*> kmod-usb-storage

Filesystems  ---> 

<*> kmod-fs-vfat

 

2、创建U盘挂载目录/overlay/mnt

#mkdir /overlay/mnt

 

3、手动挂载

在板子上输入以下命令可以看到U盘的设备文件sad sda1

#ls /dev/

 

手动挂载命令:

#mount  /dev/sda1 /overlay/mnt

------------------------

问题记录:手动挂载时报错了

原因:系统缺少字符编码

解决:根据缺少的字符编码,编译内核时加上配置选项,手动挂载成功。

Kernel modules  ---> 

Native Language Support  --->

 
<*> kmod-nls-cp437.........Codepage 437 (United States, Canada) 

  

当只选上cp437这一个编码时,下次手动挂载时还是报错了因为还缺少一个字符编码,也加上来

 

<*> kmod-nls-iso8859-1..ISO 8859

 -------------------------

4、热拔插自动挂载:

在/etc/hotplug.d/block目录下创建文件10-mount,并写入以下内容,如果没有block目录可以自己创建。

最后一定要记得修改10-mount的文件权限到最高

文件内容:root@OpenWrt:/etc/hotplug.d/block# cat 10-mount 

#!/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 /mnt/$device

                rm -rf /mnt/$device

                ;;

    esac

 

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