帮助与文档

当前位置: 主页 > 系统相关 > 正文

Linux使用DD命令测试硬盘读写速度

时间:2024/4/25 8:49:50   来源:米安网络   作者:云主机配置专家   点击:16次

1.这不是一个专业的测试工具,不过如果对于测试结果的要求不是很苛刻的话,平时可以使用来对磁盘的读写速度作一个简单的评估.另外由于这是一个免费软件,基本上linux系统上都有安装。

style="margin-bottom: 0in; font-variant: normal; letter-spacing: normal; font-style: normal; font-weight: normal; line-height: 150%; page-break-inside: auto; page-break-before: auto; page-break-after: auto;">

2.DD命令常用参数有

bs=n,block size,每次读取 n bytes 写入,可与 count 联用;
ibs=n,一次读入 bytes 个字节 (default is 512);
obs=n,一次性写 n bytes 个字节 (default is 512);
bs 可以同时设置上边两个参数;
cbs=n,一次转换 n 个 bytes,即转换缓冲区大小。;
count=n, bs 操作的次数,仅拷贝 n 个块,如 dvd: bs=1M count=4430;
skip=n,指 if 后面的原文件跳过 n bytes 再开始读取;
seek=n,指 of 后面的目标文件跳过 n bytes 再开始写入;   
style="margin-bottom: 0in; font-variant: normal; letter-spacing: normal; font-style: normal; font-weight: normal; line-height: 150%; page-break-inside: auto; page-break-before: auto; page-break-after: auto;">

style="margin-bottom: 0in; font-variant: normal; letter-spacing: normal; font-style: normal; font-weight: normal; line-height: 150%; page-break-inside: auto; page-break-before: auto; page-break-after: auto;">

3.首先了解两个特殊设备

/dev/null 伪设备,回收站.写该文件不会产生IO
/dev/zero 伪设备,会产生空字符流,对它不会产生IO

style="margin-bottom: 0in; font-variant: normal; letter-spacing: normal; font-style: normal; font-weight: normal; line-height: 150%; page-break-inside: auto; page-break-before: auto; page-break-after: auto;">

1.测试方法:
a.测试磁盘的IO写速度

time dd if=/dev/zero of=test.dbf bs=8k count=300000

如果要测试实际速度 还要在末尾加上 oflag=direct测到的才是真实的IO速度

b.测试磁盘的IO读速度

dd if=test.dbf bs=8k count=300000 of=/dev/null

表示 每次写入/读取8k的数据,执行300000次

c.测试IO同时读和写的速度

time dd if=/dev/sda1 of=test.dbf bs=8k count=300000

同时测试读写速度时生成一个 test.dbf文件

所有测试的数据量较小,仅作为参考。

版权保护: 本文「Linux使用DD命令测试硬盘读写速度」由 云主机配置专家 原创,转载请保留链接: https://www.miandns.com/docs/system/860.html

联系客服

0312-5535754

微信公众号