dd命令测试硬盘性能

上周买了vps,网上有一键测试vps性能的脚本,跑了下,发现有些看不懂,所以就单独只测试我想要的硬盘读写性能.

首先man dd一下,可以看到dd命令的作用是convert and copy a file,转换并复制数据块.

参数:
– if=文件名:输入文件名,缺省为标准输入。即指定源文件
– of=文件名:输出文件名,缺省为标准输出。即指定目的文件
– bs=bytes:同时设置读入/输出的块大小为bytes个字节
– cbs=bytes:一次转换bytes个字节,即指定转换缓冲区大小
– ibs=bytes:一次读入bytes个字节,即指定一个块大小为bytes个字节
– obs=bytes:一次输出bytes个字节,即指定一个块大小为bytes个字节
– skip=blocks:从输入文件开头跳过blocks个块后再开始复制
– seek=blocks:从输出文件开头跳过blocks个块后再开始复制
– count=blocks:仅拷贝blocks个块,块大小等于ibs指定的字节数
– conv=conversion:用指定的参数转换文件,可用参数如下(哥英语菜就不翻译了):

ascii from EBCDIC to ASCII
ebcdic from ASCII to EBCDIC
ibm from ASCII to alternate EBCDIC
block pad newline-terminated records with spaces to cbs-size
unblock replace trailing spaces in cbs-size records with newline
lcase change upper case to lower case
ucase change lower case to upper case
sparse try to seek rather than write the output for NUL input blocks
swab swap every pair of input bytes
sync pad every input block with NULs to ibs-size; when used with block or unblock, pad with
spaces rather than NULs
excl fail if the output file already exists
nocreat do not create the output file
notrunc do not truncate the output file
noerror continue after read errors
fdatasync physically write output file data before finishing
fsync likewise, but also write metadat


废话不多说.开始测试.

#先测试写入性能,向硬盘协议4G的数据
[root@centos ~]# time dd if=/dev/zero of=/tmp/zero.out bs=4k count=1000k
1024000+0 records in
1024000+0 records out
4194304000 bytes (4.2 GB) copied, 9.80381 s, 428 MB/s

real    0m9.914s
user    0m0.473s
sys 0m6.139s

#然后测试读取性能,把刚生产的数据,写入/dev/null,这样不会产生性能损耗.
[root@centos ~]# time dd if=/tmp/zero.out of=/dev/null bs=8k
512000+0 records in
512000+0 records out
4194304000 bytes (4.2 GB) copied, 10.2132 s, 411 MB/s

real    0m10.216s
user    0m0.210s
sys 0m4.034s

卧槽,这性能是要爆炸啊,莫不是用上了传说中的固态?

仔细想想应该不大可能,估计是用10 Raid,并且阵列卡有大容量的缓存,再加上与我同台服务器上的邻居应该都没占用磁盘的缘故.