dd用于复制,从if读出,写到of。if=/dev/zero不产生IO,因此可以用来测试纯写速度。同理of=/dev/null不产生IO,可以用来测试纯读速度。bs是每次读或写 的大小,即一个块的大小,count是读写块的数量。
指定出读取,写入文件到硬盘的速度
1.测/目录所在磁盘的纯写速度:
[root@base-dmz1 /]#dd if=/dev/zero bs=1024 count=1000000 of=1Gb.file
1000000+0 records in
1000000+0 records out
1024000000 bytes (1.0 GB) copied, 2.57314 seconds, 398 MB/s
2.测/目录所在磁盘的纯读速度:
dd if=1Gb.file bs=1024 of=/dev/null
382860+0 records in
382860+0 records out
3136389120 bytes (3.1 GB) copied, 68.38 seconds, 45.9 MB/s
dd if=1Gb.file of=1Gb2.file bs=1024
5025+0 records in
5024+0 records out
329261056 bytes (329 MB) copied, 23.8813 seconds, 13.8 MB/s
注:理论上复制量越大测试越准确。