参考 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. UITableView 让 cell 被选中的颜色底色快速消失,而不是一直停留在cell上

    //单元格被选中 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath ...

  2. Arcgis10.5 python按属性分割图层,属性相同分为一个图层

    # coding=utf-8 """ Source code for potential gp tool to create outputs based on attri ...

  3. 如何利用javascript获取表单中select下拉列表中所选中项的值value

    1.html代码如下: <html> <head> </head> <body> <form name="form1" id= ...

  4. https跳转到http的过程在IE6中存在BUG(Bea-090475)

    前段时间做OA系统的https的安全登录功能(以前登录是采用的一般的http方式,后因为安全性考虑需要改成https的方式)在本机测试完全通过. 可是近期同事发现在测试环境下用IE6访问会出现不能访问 ...

  5. Spring3.1.2与Hibernate4.1.8整合

    整合Spring3.1.2 与 Hibernate 4.1.8 首先准备整合jar: Spring3.1.2: org.springframework.aop-3.1.2.RELEASE.jar or ...

  6. 24.Semaphore

    Semaphore     在进程方面完成信号线的控制,可以控制某个资源下,可被同时访问的线程个数.对系统的访问量进行评估,信号量维护了一个许可集:在许可前会阻塞每一个 semaphore.acqui ...

  7. bzoj 1975 [Sdoi2010]魔法猪学院

    1975: [Sdoi2010]魔法猪学院 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1758  Solved: 557[Submit][Statu ...

  8. go语言基础之切片的创建和截取

    1.切片的创建 示例: package main //必须有个main包 import "fmt" func main() { //切片和数组的区别 //数组[]里面的长度时固定的 ...

  9. Faster\Slower 快慢指针的应用

    leetcode很多题目都是利用快慢指针来解决题目,下面具体讲解下快慢指针. 概念: 快指针在每一步走的步长要比慢指针一步走的步长要多.快指针通常的步速是慢指针的2倍.在循环中的指针移动通常为:fas ...

  10. android中一些特殊字符(如:←↑→↓等箭头符号)的Unicode码值

    在项目中,有时候在一些控件(如Button.TextView)中要添加一些符号,如下图所示:                          这个时候可以使用图片的方式来显示,不过这些可以直接使用U ...