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

OpenWrt学习笔记3 -- U盘自动挂载

2017-02-12 00:00 543 查看
OpenWrt提供了一个mountd机制,用于自动挂载usb存储设备。

运行

make menuconfig

选择以下配置为y(即*):

Kernel Modules ---> USB Support --->kmod-usb-storages-extras

Kernel Modules ---> Filesystems --->kmod-fs-ntfs 和 kmod-fs-vfat

Kernel Modules ---> Native Language Support ---> kmod-nls-cp437和kmod-nls-iso8859-1

Utilities ---> mountd

退出,保存到.config,编译,烧录。

补充说明:nls如果不设置的话,挂载U盘的时候会报错:

root@OpenWrt:/tmp# dmesg | tail -n 5
[   23.000000] br-lan: port 1(eth0.1) entered forwarding state
[   23.000000] br-lan: port 1(eth0.1) entered forwarding state
[   25.000000] br-lan: port 1(eth0.1) entered forwarding state
[   66.940000] random: nonblocking pool is initialized
[   89.650000] FAT-fs (sda1): codepage cp437 not found

烧录完毕后,每次开机、插上U盘就会自动挂载到/tmp/run/mountd目录下。

用mount命令查看:

root@OpenWrt:/tmp/run/mountd/sda1# mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
tmpfs on /tmp/root type tmpfs (rw,noatime,mode=755)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
mountd(pid1040) on /tmp/run/mountd type autofs (rw,relatime,fd=5,pgrp=1039,timeout=60,minproto=5,maxproto=5,indirect)
/dev/mtdblock6 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
/dev/sda1 on /tmp/run/mountd/sda1 type vfat (rw,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

可以看到最后一行就是mountd帮我们自动挂载上去的U盘了。

如果需要用到ntfs格式的U盘/移动硬盘的话,需要安装ntfs-3g,方法如下:

scripts/feeds  update packages
scripts/feeds  install ntfs-3g

下载好后,在menuconfig => Utilities => Filesystem,选上ntfs-3g
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: