惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

梦荟楼的后花园

玩转OpenClaw(Moltbot)|启用webui-梦荟楼的后花园 玩转OpenClaw(Moltbot)|重生之我用ai自动考试-梦荟楼的后花园 银河麒麟CVE-2025-6019漏洞排查和修复-梦荟楼的后花园 国产系统(kylin、uos)维护工具推荐-梦荟楼的后花园 debian常用命令、配置文件位置及配置方式-梦荟楼的后花园 华为防火墙多wan口指定接口进行dns透明代理-梦荟楼的后花园 华为防火墙光电互斥口切换模式-梦荟楼的后花园 天融信防火墙设置双向地址转换-梦荟楼的后花园 1panel添加群晖webdav作为备份账号-梦荟楼的后花园 Windows映射文件夹-梦荟楼的后花园 linux下使用硬盘哨兵查看raid下硬盘健康状态-梦荟楼的后花园 Windows命令查看文件的MD5/SHA1/SHA256-梦荟楼的后花园 雷池最佳实践-梦荟楼的后花园 matomo设置使用cdn获取真实客户端IP-梦荟楼的后花园 Debian12配置静态ipv4和ipv6-梦荟楼的后花园 雷池专业版4.3.0测评💦-梦荟楼的后花园 长亭新春礼盒开箱-梦荟楼的后花园 盈高准入加密U盘或移动硬盘时一直提示正在等待Windows加载系统盘符-梦荟楼的后花园 华为交换机解决设备观察端口不足的问题-梦荟楼的后花园
Linux硬盘io测试-梦荟楼的后花园
梦荟楼 · 2024-05-13 · via 梦荟楼的后花园

环境介绍

系统:debian12

需求:使用fio进行硬盘io测试

安装fio

查看是否安装fio

输入命令 fio -v来查看是否安装了

image-xdpo.png

若安装了则会输出fio-版本,若未安装则会报错

image-yfui.png

安装fio

输入命令 apt install fio -y即可完成安装

image-prff.png

fio 用法

常用参数介绍

-filename=/dev/sdb		#要测试盘的名称,支持文件系统或者裸设备,/dev/sda2或/dev/sdb
-direct=1		 #测试过程绕过机器自带的buffer,使测试结果更真实(Linux在读写时,数据会先写到缓存,再在后台写到硬盘,读的时候也是优先从缓存中读,这样访问速度会加快,但是一旦掉电,缓存中数据就会清空,所有一种模式为DirectIO,可以跳过缓存,直接读写硬盘)
-ioengine=libaio		#定义使用什么io引擎去下发io请求,常用的一些 libaio:Linux本地异步I/O;rbd:通过librbd直接访问CEPH Rados 
-iodepth=16		 #队列的深度为16,在异步模式下,CPU不能一直无限的发命令到硬盘设备。比如SSD执行读写如果发生了卡顿,那有可能系统会一直不停的发命令,几千个,甚至几万个,这样一方面SSD扛不住,另一方面这么多命令会很占内存,系统也要挂掉了。这样,就带来一个参数叫做队列深度。
-bs=4k           #单次io的块文件大小为4k
-numjobs=10      #本次测试的线程数是10
-size=5G         #每个线程读写的数据量是5GB
-runtime=60      #测试时间为60秒,可以设置2m为两分钟。如果不配置此项,会将设置的size大小全部写入或者读取完为止
-rw=randread     #测试随机读的I/O
-rw=randwrite    #测试随机写的I/O
-rw=randrw       #测试随机混合写和读的I/O
-rw=read         #测试顺序读的I/O
-rw=write        #测试顺序写的I/O
-rw=rw           #测试顺序混合写和读的I/O
-thread          #使用pthread_create创建线程,另一种是fork创建进程。进程的开销比线程要大,一般都采用thread测试
rwmixwrite=30    #在混合读写的模式下,写占30%(即rwmixread读为70%,单独配置这样的一个参数即可)
-group_reporting     #关于显示结果的,汇总每个进程的信息
-name="TDSQL_4KB_read_test"     #定义测试任务名称
扩展
-lockmem=1g       #只使用1g内存进行测试
-zero_buffers     #用全0初始化缓冲区,默认是用随机数据填充缓冲区
-random_distribution=random    #默认情况下,fio 会在询问时使用完全均匀的随机分布,有需要的话可以自定义访问区域,zipf、pareto、normal、zoned
-nrfiles=8        #每个进程生成文件的数量

随机读

fio -filename=/var/test.file -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest

顺序读

fio -filename=/var/test.file -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=16k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest

随机写

fio -filename=/var/test.file -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=16k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest

顺序写

fio -filename=/var/test.file -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=16k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest

混合读写

70%随机读,30%随机写,5G大小,4k块文件
fio -filename=/var/test.file -direct=1 -ioengine=libaio -bs=4k -size=5G -numjobs=10 -iodepth=16 -runtime=60 -thread -rw=randrw -rwmixread=70 -group_reporting -name="TDSQL_4KB_randread70-write_test"
70%顺序读,30%随机写,5G大小,4k块文件
fio -filename=/var/test.file -direct=1 -ioengine=libaio -bs=4k -size=5G -numjobs=10 -iodepth=16 -runtime=60 -thread -rw=rw -rwmixread=70 -group_reporting -name="TDSQL_4KB_read70-write_test"

参考

Linux下磁盘IO读写测试工具-FIO详解

【LINUX】FIO磁盘随机读取性能分析