参考 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集成RabbitMQ并实现消息确认机制

    原文:https://blog.csdn.net/ctwy291314/article/details/80534604 RabbitMQ安装请参照RabbitMQ应用 不啰嗦直接上代码 目录结构如下 ...

  2. 浅谈Android RecyclerView

    Android RecyclerView 是Android5.0推出来的,导入support-v7包即可使用. 个人体验来说,RecyclerView绝对是一款功能强大的控件. 首先总结下Recycl ...

  3. Android 系统服务一览表

    在<Zygote进程[3]--SystemServer的诞生>一文中介绍了SystemServer的诞生,本文来看一下SystemServer中初始化的系统服务. 1.AccountMan ...

  4. 计算Fisher vector和VLAD

    This short tutorial shows how to compute Fisher vector and VLAD encodings with VLFeat MATLAB interfa ...

  5. guess-number-higher-or-lower

    // Forward declaration of guess API. // @param num, your guess // @return -1 if my number is lower, ...

  6. How To Open An URL In Android’s Web Browser

    How To Open An URL In Android’s Web Browser 以下核心代码片断,将展现使用“android.content.Intent” 打开一个指定的 URL. butt ...

  7. Windows Server上用于iSCSI的网卡的必备设置

    如下的修改是iSCSI网卡的推荐配置, 新装起来的Host不要忘记改起来哦. 其原理是强制走iSCSI通讯的网卡立即对到来的TCP报文(segment)做出acknowledge, 从而解决iSCSI ...

  8. iOS开发-多线程简介

    多线程从概念上理解是指从软件或者硬件上实现多个线程并发执行的技术,简单点理解就是同一时间可以执行多个事情(比如说一边听歌一边码代码),听歌是一个线程,码代码是一个线程,如果是单核CPU的话,上面两个动 ...

  9. Java方法重写与方法重载

    方法重载:发生在同一个类中,方法名相同方法形参列表不同就会重载方法. 方法重写:发生在继承当中,如果子的一个类方法与父类中的那个方法一模一样(方法名和形参列表一样),那么子类就会重写父类的方法. 方法 ...

  10. 如何利用SQL语句求日期的时间差值,并汇总网上的一些信息

    MySQL本身提供了 DATEDIFF 函数,用来计算时间差. 手册:http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.ht ...