参考 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. Delphi 跨平台 Socket 通讯库

    Delphi 跨平台 Socket 通讯库 免费开源的Delphi 跨平台 Socket 通讯库. 源码URL:https://github.com/winddriver/Delphi-Cross-S ...

  2. Android下setLatestEventInfo警告、Handler警告、SimpleDateFormat警告

    正 文: 今天飘易在做Android 4.4.2下的APP开发时,使用了Notification下的setLatestEventInfo()方法时,Eclipse却提示:“ 不建议使用类型 Notif ...

  3. 使用msm配置分布式tomat,实现session共享

    一,环境说明 操作系统是Windows7家庭版(有点不专业哦,呵呵!),JDK是1.6的版本, Tomcat是apache-tomcat-6.0.35-windows-x86,下载链接:http:// ...

  4. [翻译] AnimatedPath 动画路径(持续更新)

    AnimatedPath动画路径 感谢原作者分享精神,有空补上使用教程 https://github.com/twotoasters/AnimatedPath AnimatedPath explore ...

  5. Google浏览器Chrome安装失败,错误代码0xa0430721解决办法

    谷歌浏览器安装失败错误代码0xa0430721 的解决办法 这个是因为我们删除的时候没有删除干净.然后又重装了谷歌浏览器.所以就出现这个问题了. 1.删除旧的配置文件,比如C:\Documents a ...

  6. Java开发牛人十大必备网站

    以下是我收集的Java开发牛人必备的网站.这些网站可以提供信息,以及一些很棒的讲座, 还能解答一般问题.面试问题等.质量是衡量一个网站的关键因素,我个人认为这些网站质量都很好.接下来,我会跟大家分享我 ...

  7. NLP 依存分析

    NLP 依存分析 https://blog.csdn.net/sinat_33741547/article/details/79258045

  8. Loadrunner视频教程汇总

    小布老师视频:测试工具概述,兼LoadRunner介绍 -1-4http://www.boobooke.com/v/bbk1046http://www.boobooke.com/v/bbk1046.z ...

  9. Bootstrap学习js插件篇之提示框

    案例 受到Jason Frame开发的jQuery.tipsy插件的启发,我们才把这个工具提示插件做的更好,而且此插件不依赖图片,只是使用CSS3来实现动画效果,并使用data属性存储标题. 将鼠标悬 ...

  10. 修改一行SQL代码 性能提升了100倍

    在PostgreSQL中修改了一行不明显的代码,把(ANY(ARRAY[...]) 改成 ANY(VALUES(...))),结果查询时间从20s变为0.2s.最初我们学习使用 EXPLAN ANAL ...