在路由器上挂载 USB 设备 - OpenWrt

Mount USB device on router - OpenWrt

我是 OpenWrt 的新手并且 Linux/Unix shell。在此之前,使用 dd-wrt 已有 2 年。最近切换到 OpenWrt 并完成了基本设置(wifi/internet 工作)。我需要安装传输我的路由器。但是,USB 设备无法挂载。

路由器详细信息如下:

路由器型号: 华硕 RT-N13U B1

图像闪烁: chaos_calmer 15.05.1 (openwrt-15.05.1-ramips-rt305x-rt-n13u-squashfs-sysupgrade.bin)

USB 详细信息: 克鲁斯 Blade 16GB USB 2.0 使用 GParted 可启动 cd

格式化为 ext4

已安装的驱动程序:

以下是 dev/sda、/dev/sda1 和 /mnt(手动设置 777)的权限:

~#ls -l /dev
brwxrwxrwx    1 root     root        8,   0 Jan 17 21:56 sda
brwxrwxrwx    1 root     root        8,   1 Jan 17 21:56 sda1

~#ls -l ..
drwxrwxrwx    2 root     root             0 Jan 16 21:28 mnt

安装时出错:

~# mount -t ext4 /dev/sda1 /mnt
mount: mounting /dev/sda1 on /mnt failed: No such file or directory

echo $?
255

sda1 存在于 dev 中并且存在 /mnt 目录。仍然显示错误。

我试过installing/reinstalling然后挂载,结果一样。此外,当我断开 USB sdasda1 文件夹消失,然后在 USB 重新连接时重新出现,所以我猜设备被成功检测到。

我错过了什么?

编辑: 添加了评论中建议的编辑。

dmesg output (输出很大所以链接一下)

编辑 2: 切换到 LEDE 17。更稳定并且在过去一周内出现零问题。

dmesg 输出的关键部分是

[ 9.410000] mount_root: loading kmods from internal overlay

[ 9.940000] SCSI subsystem initialized

[ 9.960000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver

[ 9.980000] ehci-platform:EHCI generic platform driver [ 9.990000] usb-storage 1-1:1.0: no of_node; not parsing pinctrl DT

[ 9.990000] usb-storage 1-1:1.0: USB Mass Storage device detected

[ 10.010000] scsi host0: usb-storage 1-1:1.0

[ 10.020000] usbcore: registered new interface driver usb-storage

[ 10.100000] block: attempting to load /tmp/jffs_cfg/upper/etc/config/fstab

[ 10.120000] block: extroot: not configured

[ 10.130000] mount_root: switching to jffs2 overlay

[ 10.180000] procd: - early -

[ 11.020000] scsi 0:0:0:0: Direct-Access SanDisk Cruzer Blade 1.27 PQ: 0 ANSI: 6

[ 11.030000] sd 0:0:0:0: no of_node; not parsing pinctrl DT

[ 11.050000] sd 0:0:0:0: [sda] 30529536 512-byte logical blocks: (15.6 GB/14.5 GiB)

[ 11.070000] sd 0:0:0:0: [sda] Write Protect is off

[ 11.070000] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00

[ 11.090000] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA

[ 11.120000] sda: sda1

[ 11.130000] sd 0:0:0:0: [sda] Attached SCSI removable disk

[ 11.550000] EXT4-fs (sda1): Cannot load crc32c driver

哦不,这似乎是一个错误

错误#819725:ext4 在 crc32c 模块上缺少 softdep

https://lists.debian.org/debian-kernel/2016/04/msg00013.html

以下解决方法不适用,因为 initramfs 在启动时 (https://en.wikipedia.org/wiki/Initramfs) 是一个本机文件系统并且具有系统完全启动时没有影响(挂载了rootfs):

Until this is fixed in the kernel package, you can work around it by either:

  • Setting base-installer/initramfs-tools/driver-policy to "most" instead of "dep"
  • Setting base-config/late_command to a script that adds crc32c to /etc/initramfs-tools/modules

post 堆栈跟踪,也许还有其他解决方法

这东西太复杂了...

这也许是一个解决方案https://forum.openwrt.org/viewtopic.php?id=69175

download kmod-lib-crc32c and kmod-crypto-crc32c

如果这不起作用可能最简单的解决方案是将 USB 堆栈格式化为 VFAT 并等待新内核...


这不是权限错误。权限错误将 return EPERM -> 错误代码 1 不允许操作

了解 mount return 的退出代码会很有趣。 'exit behavior is very different in the several mount version'mount(2)mount(8)

获取return值,输入shell命令

mount /dev/sda1 /mnt

然后

echo $?

数字是 mount 的 returned 退出代码(255 表示 'exit status out of range' 在本例中为 '-1', http://www.tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF)

mount(8) 退出代码列表在 http://www.whosebug.com/questions/33167585/what-are-the-return-codes-values-of-linux-umount

http://www.becane.com/2014/09/02/understanding-exit-codes-and-how-to-use-them-in-a-bash-script

除了 return 值 mount(2) 还在 errno (http://man7.org/linux/man-pages/man3/errno.3.html). printing errno in shell is a bit difficult it is easier to get a reference like http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html 并搜索错误字符串,在本例中为 No such file or directory

字符串没有那个文件或目录是系统错误ENOENT

作为系统错误 ENOENT 表示 路径名为空或包含不存在的组件。 (http://man7.org/linux/man-pages/man2/mount.2.html)

试试sudo mount -t ext4 /dev/sda1 /mnt因为棒子的格式是ext4

如果这不起作用 dmesg 输出会很有趣

分离 USB 设备,重新连接 USB 设备,键入 dmesg 并查看输出。在 dmesg 的输出中,您还可以看到为设备加载了哪些驱动程序

https://wiki.openwrt.org/doc/howto/usb.storage 说您还需要几个驱动程序 (block-mount, kmod-scsi-core,...) 因为 USB 记忆棒 (USB Mass Storage class) 也是一个 SCSI 和一个块设备...

(linux系统错误码在http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html)

打印堆栈跟踪 sudo strace -f mount -t ext4 -o default /dev/sda1 /mnt 和 post 它