参考 http://h-wrt.com/en/doc/flash

1. 查看usb存储在启动日志中的信息

# dmesg

[    5.720000] usbcore: registered new interface driver usbfs
[ 5.730000] usbcore: registered new interface driver hub
[ 5.740000] usbcore: registered new device driver usb
[ 5.740000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 5.750000] ehci-platform: EHCI generic platform driver
[ 5.760000] ehci-platform ehci-platform: EHCI Host Controller
[ 5.760000] ehci-platform ehci-platform: new USB bus registered, assigned bus number
[ 5.770000] ehci-platform ehci-platform: irq , io mem 0x1b000000
[ 5.800000] ehci-platform ehci-platform: USB 2.0 started, EHCI 1.00
[ 5.800000] hub -:1.0: USB hub found
[ 5.810000] hub -:1.0: ports detected
[ 5.810000] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 5.820000] ohci-platform: OHCI generic platform driver
[ 5.820000] ohci-platform ohci-platform: Generic Platform OHCI controller
[ 5.830000] ohci-platform ohci-platform: new USB bus registered, assigned bus number
[ 5.840000] ohci-platform ohci-platform: irq , io mem 0x1c000000
[ 5.910000] hub -:1.0: USB hub found
[ 5.910000] hub -:1.0: ports detected
[ 6.140000] usb -: new high-speed USB device number using ehci-platform
[ 6.720000] init: - preinit -
[ 7.250000] ar71xx: pll_reg 0xb8050010: 0x11110000
[ 7.250000] eth0: link up (1000Mbps/Full duplex)
[ 7.270000] random: procd urandom read with bits of entropy available
[ 10.540000] jffs2: notice: () jffs2_build_xattr_subsystem: complete building xattr subsystem, of xdatum ( unchecked, orphan) and of xref ( dead, orphan) found.
[ 10.570000] mount_root: loading kmods from internal overlay
[ 11.460000] SCSI subsystem initialized
[ 11.460000] uhci_hcd: USB Universal Host Controller Interface driver
[ 11.470000] usb-storage -:1.0: USB Mass Storage device detected
[ 11.480000] scsi host0: usb-storage -:1.0
[ 11.490000] usbcore: registered new interface driver usb-storage
[ 11.740000] block: attempting to load /tmp/jffs_cfg/upper/etc/config/fstab
[ 11.760000] block: extroot: not configured
[ 11.760000] mount_root: switching to jffs2 overlay
[ 11.800000] eth0: link down
[ 11.820000] procd: - early -
[ 11.820000] procd: - watchdog -
[ 12.490000] scsi :::: Direct-Access Generic- SD/MMC 1.00 PQ: ANSI: CCS
[ 12.560000] procd: - ubus -
[ 13.170000] sd :::: [sda] -byte logical blocks: (15.4 GB/14.4 GiB)
[ 13.200000] sd :::: [sda] Write Protect is off
[ 13.200000] sd :::: [sda] Mode Sense:
[ 13.200000] sd :::: [sda] No Caching mode page found
[ 13.210000] sd :::: [sda] Assuming drive cache: write through
[ 13.240000] sda: sda1
[ 13.250000] sd :::: [sda] Attached SCSI removable disk

2. 用fdisk对usb storage进行分区

root@WNDR3800:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.25.).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. # 查看磁盘信息
Command (m for help): p
Disk /dev/sda: 14.4 GiB, bytes, sectors
Units: sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disklabel type: dos
Disk identifier: 0x00000000 Device Boot Start End Sectors Size Id Type
/dev/sda1 .4G HPFS/NTFS/exFAT # 删除分区
Command (m for help): d
Selected partition
Partition has been deleted.
# 创建新分区, 直接回车, 回车
Command (m for help): n
Partition type
p primary ( primary, extended, free)
e extended (container for logical partitions)
Select (default p): p
Partition number (-, default ):
First sector (-, default ):
Last sector, +sectors or +size{K,M,G,T,P} (-, default ): Created a new partition of type 'Linux' and of size 14.4 GiB.
# 保存
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe() or kpartx(). # 重启
root@WNDR3800:~# reboot

3. 使用ext4格式化

# 查看命令参数
root@WNDR3800:~# mkfs.ext4
Usage: mkfs.ext4 [-c|-l filename] [-b block-size] [-C cluster-size]
[-i bytes-per-inode] [-I inode-size] [-J journal-options]
[-G flex-group-size] [-N number-of-inodes]
[-m reserved-blocks-percentage] [-o creator-os]
[-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]
[-O feature[,...]] [-r fs-revision] [-E extended-option[,...]]
[-t fs-type] [-T usage-type ] [-U UUID] [-jnqvDFKSV] device [blocks-count]
# 格式化
root@WNDR3800:~# mkfs.ext4 -b 4096 -L Ext4U01 /dev/sda1
mke2fs 1.42. (-Aug-)
Creating filesystem with 4k blocks and inodes
Filesystem UUID: 355a69cf-7a07--a97d-f81a6956c786
Superblock backups stored on blocks:
, , , , , , , , Allocating group tables: done
Writing inode tables: done
Creating journal ( blocks): done
Writing superblocks and filesystem accounting information: /
done
# 完成
# 如果要设置为swap分区
mkswap /dev/sda1
Setting up swapspace version 1, size = 523235840 bytes

4. 重启后(让其自动mount), 查看文件系统, 如果df没有-T参数, 可以直接用mount命令查看格式

root@WNDR3800:~# df -h -T
Filesystem Type Size Used Available Use% Mounted on
rootfs rootfs 12.1M 3.5M 8.6M % /
/dev/root squashfs 2.3M 2.3M % /rom
tmpfs tmpfs 61.5M .0K 61.3M % /tmp
/dev/mtdblock5 jffs2 12.1M 3.5M 8.6M % /overlay
overlayfs:/overlay overlay 12.1M 3.5M 8.6M % /
tmpfs tmpfs .0K .0K % /dev
/dev/sda1 ext4 .1G 36.0M .3G % /mnt/sda1
[root@TIMEPLUG_CF37:/root]#mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/mtdblock7 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlayfs (rw,noatime,lowerdir=/,upperdir=/overlay)
tmpfs on /dev type tmpfs (rw,relatime,size=512k,mode=)
devpts on /dev/pts type devpts (rw,relatime,mode=)
/dev/sda1 on /mnt/sda1 type ext4 (rw,relatime,data=ordered)
/dev/mtdblock6 on /mnt/mtdblock6 type squashfs (ro,relatime)

5. 性能测试. 需要hdparm, 如果没有的话, 通过opkg install hdparm安装

root@WNDR3800:~# hdparm -Tt /dev/sda

/dev/sda:
Timing cached reads: MB in 2.01 seconds = 127.67 MB/sec
Timing buffered disk reads: MB in 3.09 seconds = 14.24 MB/sec

以及dd

root@WNDR3800:/mnt/sda1# time dd count= bs=1M if=/dev/zero of=test.test
+ records in
+ records out
real 0m .65s
user 0m .00s
sys 0m .74s

计算大致的写入为 128/28.64=4.47MB/s

Update 2017-10-08: 使用unitek(优越者)某款2.5寸usb3.0硬盘盒挂载时出现错误导致被挂载为只读, 具体错误为

Thu Oct   ::  kern.info kernel: [   19.904000] EXT4-fs (sda1): mounting ext3 file system using the ext4 subsystem
Thu Oct :: kern.info kernel: [ 19.968000] sd :::: [sda] Invalid command failure
Thu Oct :: kern.info kernel: [ 19.972000] sd :::: [sda]
Thu Oct :: kern.warn kernel: [ 19.976000] Result: hostbyte=0x00 driverbyte=0x08
Thu Oct :: kern.info kernel: [ 19.980000] sd :::: [sda]
Thu Oct :: kern.warn kernel: [ 19.984000] Sense Key : 0x5 [current]
Thu Oct :: kern.info kernel: [ 19.988000] sd :::: [sda]
Thu Oct :: kern.warn kernel: [ 19.992000] ASC=0x24 ASCQ=0x0
Thu Oct :: kern.info kernel: [ 19.992000] sd :::: [sda] CDB:
Thu Oct :: kern.warn kernel: [ 19.996000] cdb[]=0x2a: 2a
Thu Oct :: kern.err kernel: [ 20.000000] end_request: critical target error, dev sda, sector
Thu Oct :: kern.err kernel: [ 20.008000] Buffer I/O error on device sda1, logical block
Thu Oct :: kern.warn kernel: [ 20.016000] lost page write due to I/O error on sda1
Thu Oct :: kern.err kernel: [ 20.020000] JBD2: Error - detected when updating journal superblock for sda1-.
Thu Oct :: kern.warn kernel: [ 20.028000] EXT4-fs warning (device sda1): ext4_clear_journal_err:: Filesystem error recorded from previous mount: IO failure
Thu Oct :: kern.warn kernel: [ 20.040000] EXT4-fs warning (device sda1): ext4_clear_journal_err:: Marking fs in need of filesystem check.
Thu Oct :: kern.warn kernel: [ 20.056000] EXT4-fs (sda1): warning: mounting fs with errors, running e2fsck is recommended
Thu Oct :: kern.info kernel: [ 20.068000] EXT4-fs (sda1): recovery complete
Thu Oct :: kern.info kernel: [ 20.072000] sd :::: [sda] Invalid command failure
Thu Oct :: kern.info kernel: [ 20.076000] sd :::: [sda]
Thu Oct :: kern.warn kernel: [ 20.080000] Result: hostbyte=0x00 driverbyte=0x08
Thu Oct :: kern.info kernel: [ 20.084000] sd :::: [sda]
Thu Oct :: kern.warn kernel: [ 20.088000] Sense Key : 0x5 [current]
Thu Oct :: kern.info kernel: [ 20.092000] sd :::: [sda]
Thu Oct :: kern.warn kernel: [ 20.096000] ASC=0x24 ASCQ=0x0
Thu Oct :: kern.info kernel: [ 20.100000] sd :::: [sda] CDB:
Thu Oct :: kern.warn kernel: [ 20.100000] cdb[]=0x2a: 2a
Thu Oct :: kern.err kernel: [ 20.108000] end_request: critical target error, dev sda, sector
Thu Oct :: kern.err kernel: [ 20.112000] Buffer I/O error on device sda1, logical block
Thu Oct :: kern.warn kernel: [ 20.120000] lost page write due to I/O error on sda1
Thu Oct :: kern.err kernel: [ 20.124000] JBD2: Error - detected when updating journal superblock for sda1-.
Thu Oct :: kern.err kernel: [ 20.132000] Aborting journal on device sda1-.
Thu Oct :: kern.info kernel: [ 20.136000] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts:

以及

Thu Oct   ::  kern.crit kernel: [   22.264000] EXT4-fs error (device sda1): ext4_journal_check_start:: Detected aborted journal
Thu Oct :: kern.crit kernel: [ 22.272000] EXT4-fs (sda1): Remounting filesystem read-only
Thu Oct :: daemon.err block: /dev/sda1 is already mounted on /mnt/sda1

在更换为其他硬盘盒(硬盘不变)后, 错误消失.

OpenWrt中对USB文件系统的操作, 以及读写性能测试的更多相关文章

  1. OpenWrt中开启usb存储和samba服务

    在从官网安装的WNDR3800 15.05.1版本OpenWrt中, 不带usb存储支持以及samba, 需要另外安装 1. 启用usb支持 USB Basic Support https://wik ...

  2. python 中文件输入输出及os模块对文件系统的操作

    整理了一下python 中文件的输入输出及主要介绍一些os模块中对文件系统的操作. 文件输入输出 1.内建函数open(file_name,文件打开模式,通用换行符支持),打开文件返回文件对象. 2. ...

  3. 转:openwrt中luci学习笔记

    原文地址:openwrt中luci学习笔记 最近在学习OpenWrt,需要在OpenWrt的WEB界面增加内容,本文将讲述修改OpenWrt的过程和其中遇到的问题. 一.WEB界面开发         ...

  4. Linux--安装过程中的根文件系统的分析

    前言: 在这篇文章中S3C6410公版的Linux BSP和U-Boot为了分析,名词和数据文件的所有内容本文是基于环境为例,所有的代码是在设置的示例进行分析的过程中.哈. 假设有不对或者不完好的地方 ...

  5. U-Boot中支持USB

    转载: http://blog.csdn.net/qiurihuanghua/article/details/6234832 今天查看了一下在P4080DS板子的U-Boot中支持USB,主要是加入U ...

  6. 云计算分布式大数据Hadoop实战高手之路第八讲Hadoop图文训练课程:Hadoop文件系统的操作实战

    本讲通过实验的方式讲解Hadoop文件系统的操作. “云计算分布式大数据Hadoop实战高手之路”之完整发布目录 云计算分布式大数据实战技术Hadoop交流群:312494188,每天都会在群中发布云 ...

  7. 解析Linux中的VFS文件系统之文件系统的来源与简介(一)

    最近挂载了N多的文件系统,大致了不同文件系统的相应特性及挂载方式,却还是对Linux的文件系统没有从源码方面去了解.不求甚解确实不好不好. 于是借鉴一些大牛的博客及自己的理解,总结了博客系列: 一.V ...

  8. linux(3)磁盘与文件系统管理/查看硬盘、内存空间/文件系统的操作/ 文件的压缩和打包

    一.磁盘与文件系统管理 1.分区与文件系统分区:记录每一个分区的开始柱面和结束柱面主引导区(master boot recorder):记录分区的数据,记录硬盘里所有的分区信息分区划分好后,要将分区格 ...

  9. OpenWRT中的按键和灯的GPIO控制实现_转

    本文转自:OpenWRT中的按键和灯的GPIO控制实现 基于BarrierBreaker版本,基于AR9331 AP121 Demo单板 来进行描述 1.灯 A.在mach-ap121.c中,定义了灯 ...

随机推荐

  1. 【springboot+easypoi】一行代码搞定excel导入导出

    原文:https://www.jianshu.com/p/5d67fb720ece 开发中经常会遇到excel的处理,导入导出解析等等,java中比较流行的用poi,但是每次都要写大段工具类来搞定这事 ...

  2. Phone重绘机制drawRect 转

    Phone重绘机制drawRect 如何使用iPhone进行绘图.重绘操作iPhone的绘图操作是在UIView类的drawRect方法中完成的,所以如果我们要想在一个UIView中绘图,需要写一个扩 ...

  3. 【idea】idea重新打包依赖了父级项目的子级项目,父级项目代码改变,但是子级项目打包依旧是老的代码 问题解决

    最简单的方法: 就是单独打包父级项目,然后替换本地maven仓库中的父级项目的jar,然后重新打包子级项目,就可以了.

  4. JDBC进阶之PreparedStatement执行SQL语句(MySQL)

    一.什么是PreparedStatement           参阅Java API文档,我们可以知道,PreparedStatement是Statement的子接口(如图所示),表示预编译的 SQ ...

  5. Eclipse 搭建struts2 spring3 hibernate3环境实战 待完善

    1.struts2 目前是2.3版本,下载地址http://struts.apache.org/download.cgi struts2包 struts2-core-2.3.16.3.jar stru ...

  6. 让Mac风扇面对PD不再疯狂

    对于所有喜欢Mac操作系统的用户来说,如果办公环境必须使用Windows及Windows程序,那一定会非常崩溃,因为你很可能使用了Parallels Desktop来运行你的Windows虚拟机,那么 ...

  7. Informatica 常用组件Lookup之三 关系和平面文件查找

    创建查找转换时,您可以选择使用关系表或平面文件作为查找源. 关系查找 使用关系表作为查找源来创建查找转换时,您可以使用 ODBC 连接到查找源并导入表定义作为查找转换的结构. 仅可对关系查找使用以下选 ...

  8. Javascript模块化工具require.js教程

    转自:http://www.w3cschool.cc/w3cnote/requirejs-tutorial-1.html, http://www.w3cschool.cc/w3cnote/requir ...

  9. Android中的树状(tree)列表

    树状列表前端挺常用的,还有人专门写过Ztree,Android中有的时候也需要使用到树状列表,上篇文章写了一下ExpandableListView,ExpandableListView最多支持两级结构 ...

  10. JSP简单练习-定时刷新页面

    <%@ page contentType="text/html; charset=gb2312" %> <%@ page import="java.ut ...