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

参考 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 1
[    5.770000] ehci-platform ehci-platform: irq 3, io mem 0x1b000000
[    5.800000] ehci-platform ehci-platform: USB 2.0 started, EHCI 1.00
[    5.800000] hub 1-0:1.0: USB hub found
[    5.810000] hub 1-0:1.0: 2 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 2
[    5.840000] ohci-platform ohci-platform: irq 14, io mem 0x1c000000
[    5.910000] hub 2-0:1.0: USB hub found
[    5.910000] hub 2-0:1.0: 2 ports detected
[    6.140000] usb 1-1: new high-speed USB device number 2 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 11 bits of entropy available
[   10.540000] jffs2: notice: (383) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 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-1:1.0: USB Mass Storage device detected
[   11.480000] scsi host0: usb-storage 1-1: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 0:0:0:0: Direct-Access     Generic- SD/MMC           1.00 PQ: 0 ANSI: 0 CCS
[   12.560000] procd: - ubus -
[   13.170000] sd 0:0:0:0: [sda] 30220288 512-byte logical blocks: (15.4 GB/14.4 GiB)
[   13.200000] sd 0:0:0:0: [sda] Write Protect is off
[   13.200000] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[   13.200000] sd 0:0:0:0: [sda] No Caching mode page found
[   13.210000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   13.240000]  sda: sda1
[   13.250000] sd 0:0:0:0: [sda] Attached SCSI removable disk

2. 用fdisk对usb storage进行分区

[email protected]:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.25.2).
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, 15472787456 bytes, 30220288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1        8192 30220287 30212096 14.4G  7 HPFS/NTFS/exFAT

# 删除分区
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
# 创建新分区, 直接回车, 回车
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-30220287, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-30220287, default 30220287): 

Created a new partition 1 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(8) or kpartx(8).

# 重启
[email protected]:~# reboot

3. 使用ext4格式化

# 查看命令参数
[email protected]:~# 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]
# 格式化
[email protected]:~# mkfs.ext4 -L Ext4U01 /dev/sda1
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 3777280 4k blocks and 944704 inodes
Filesystem UUID: 355a69cf-7a07-4752-a97d-f81a6956c786
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:   2/116
done
# 完成

4. 重启后(让其自动mount), 查看文件系统

[email protected]:~# df -h -T
Filesystem           Type            Size      Used Available Use% Mounted on
rootfs               rootfs         12.1M      3.5M      8.6M  29% /
/dev/root            squashfs        2.3M      2.3M         0 100% /rom
tmpfs                tmpfs          61.5M    264.0K     61.3M   0% /tmp
/dev/mtdblock5       jffs2          12.1M      3.5M      8.6M  29% /overlay
overlayfs:/overlay   overlay        12.1M      3.5M      8.6M  29% /
tmpfs                tmpfs         512.0K         0    512.0K   0% /dev
/dev/sda1            ext4           14.1G     36.0M     13.3G   0% /mnt/sda1

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

[email protected]:~# hdparm -Tt /dev/sda

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

以及dd

[email protected]:/mnt/sda1# time dd count=128 bs=1M if=/dev/zero of=test.test
128+0 records in
128+0 records out
real    0m 28.65s
user    0m 0.00s
sys    0m 0.74s

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

时间: 2024-08-08 01:53:54

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

OpenWrt中开启usb存储和samba服务

在从官网安装的WNDR3800 15.05.1版本OpenWrt中, 不带usb存储支持以及samba, 需要另外安装 1. 启用usb支持 USB Basic Support https://wiki.openwrt.org/doc/howto/usb.essentials # 每次重启后, 软件包都要重新update opkg update 安装 kmod-usb-uhci 或者 kmod-usb-ohci, 如果前者不能安装, 系统会有提示 opkg install kmod-usb-uh

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

整理了一下python 中文件的输入输出及主要介绍一些os模块中对文件系统的操作. 文件输入输出 1.内建函数open(file_name,文件打开模式,通用换行符支持),打开文件返回文件对象. 2.对打开文件进行读取时,readline()与readlines()的区别在于是否一次性的读取所有的内容,并将每行的信息作为列表中的一个子项. 例如:文件test.txt中 1,3,4 2,35,6 分别用readline与readlines对其进行读取 r=file_object.readline(

U-Boot中支持USB

转载: http://blog.csdn.net/qiurihuanghua/article/details/6234832 今天查看了一下在P4080DS板子的U-Boot中支持USB,主要是加入USB Host端驱动和相应设备端驱动来支持存储设备,这样就 可以将Kernel以及文件系统存放在U盘上,来通过U盘来启动. 跟其它接口一样,在U-Boot中,USB的支持也是通过放在相应板子上的几个宏定义来实现,对于P4080DS板,是在include/configs/corenet_ds.h定义:

解析Linux中的VFS文件系统之文件系统的来源与简介

最近挂载了N多的文件系统,大致了不同文件系统的相应特性及挂载方式,却还是对Linux的文件系统没有从源码方面去了解.不求甚解确实不好不好. 于是借鉴一些大牛的博客及自己的理解,总结了博客系列: 一.VFS是什么: VFS是Linux中的一个虚拟文件文件系统,也称为虚拟文件系统交换层(Virtual Filesystem Switch),是一种软件机制.它为应用程序员提供一层抽象,屏蔽底层各种文件系统的差异.如下图所示: 引入文件系统的目的是:为了屏蔽各种文件系统的差异 (1)VFS对实际文件系统

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

一.磁盘与文件系统管理 1.分区与文件系统分区:记录每一个分区的开始柱面和结束柱面主引导区(master boot recorder):记录分区的数据,记录硬盘里所有的分区信息分区划分好后,要将分区格式化为系统可以识别的文件系统磁盘的最小物理存储单位是:扇区分区时格式化文件系统的最小存储单位:逻辑块,以扇区为基础,大小为2的n次方,但是一个块只能容纳一个文件linux的ext2文件系统每个文件内容分为两部分:存储文件的属性(放在inode中),文件的内容(放在块中) 例: 读取文件系统的信息:

Unix_文件系统高级操作_0

这是<UNIX初级教程>_第8章 UNIX文件系统高级操作的内容 感觉这一章的内容还是挺多的:(注:其间的下划线“_”是把命令与其它文字隔开,它不是命令的一部分) 1 读文件:只读版本view命令.读文件pg命令(MaoBook Os的命令中没有它,略过) 2 shell重定向:输出重定向,输入重定向 3 增强的文件打印功能_略过 4 文件操作命令:复制文件_cp命令.移动文件_mv命令.链接文件_ln命令.计算数字_wc命令. 5 文件名替换:?元字符|*元字符|[ ]元字符.元字符与隐藏文

linux中dd相关命令骚操作

一.dd如何快速将磁盘写满 方法一: dd if=/dev/zero of=/tmp/file bs=1G count=10 # 参数解释 1. if=文件名:输入文件名,缺省为标准输入.即指定源文件.< if=input file > 2. of=文件名:输出文件名,缺省为标准输出.即指定目的件.< of=outputfile > 3. ibs=bytes:一次读入bytes个字节,即指定一个块大小为bytes个字节. obs=bytes:一次输出bytes个字节,即指定一个块大

django 中连接mysql数据库的操作步骤

django中连接mysql数据库的操作步骤: 1 settings配置文件中 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'orm02', # 库的名字 'USER':'root', # 数据库的用户名 'PASSWORD':'666', # 数据库的密码 'HOST':'127.0.0.1', 'PORT':3306, } } 2 项目文件夹下的init文件中写上下面内容,用pymysql替

Linux系统中常见的文件系统有哪些?

Linux系统是现在非常受欢迎的操作系统,在Linux之中,一切都是文件,因为有很多操作都是依靠文件系统才可以完成的,而且文件系统可以满足用户正常的使用,那么Linux中常见的文件系统有哪些?老为大家介绍一下. 总体来说,在Linux之中,系统能够支持的文件系统要比Windows系统多很多,达到数十种,所以说Linux系统也是非常出色的操作系统.Linux中常见的文件系统介绍: 1.Ext3:是一款日志文件系统,能够在系统异常的情况下避免文件系统资料丢失,并且能够修复数据的不一致以及错误,同时,