歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux使用dd命令測試硬盤讀寫速度

Linux使用dd命令測試硬盤讀寫速度

日期:2017/2/28 15:29:03   编辑:Linux教程

Linux服務器裝好系統之後,想要知道硬盤的讀寫是否能滿足服務的需要,如果不滿足硬盤的IO就是服務的一個瓶頸。所以我們需要測試硬盤的讀寫速度,測試的方法很多,下面是使用Linux 自帶的dd命令測試硬盤的讀寫速度。

time有計時作用,dd用於復制,從if讀出,寫到of。if=/dev/zero不產生IO,因此可以用來測試純寫速度。同理of=/dev/null不產生IO,可以用來測試純讀速度。bs是每次讀或寫的大小,即一個塊的大小,count是讀寫塊的數量。

測/data目錄所在磁盤的純寫速度:

[root@nagios ~]# time dd if=/dev/zero of=/var/test bs=8k count=1000000
1000000+0 records in
1000000+0 records out
8192000000 bytes (8.2 GB) copied, 52.5749 seconds, 156 MB/s

real 0m55.841s
user 0m0.507s
sys 0m15.706s

##紅色部分是因為使用了time命令才顯示的,因此需要time命令來計算復制的時間。

測/data目錄所在磁盤的純讀速度:

[root@nagios ~]# time dd if=/var/test of=/dev/null bs=8k
1000000+0 records in
1000000+0 records out
8192000000 bytes (8.2 GB) copied, 49.0088 seconds, 167 MB/s

real 0m49.025s
user 0m0.559s
sys 0m6.383s

測讀寫速度:

[root@nagios ~]# time dd if=/var/test of=/tmp/test bs=64k
125000+0 records in
125000+0 records out
8192000000 bytes (8.2 GB) copied, 129.239 seconds, 63.4 MB/s

real 2m9.251s
user 0m0.114s
sys 0m21.494s

看來這個測試結果還不錯,嘿嘿

備注:理論上測試復制量越大測試結果越准確。

正常測試的時候可能不止測試一邊,可能會需要很多遍求取平均值,這個測試結果在普通的重定向是沒有效果的 之後 google 了一下 用下面的方式重定向到一個文件

dd if=/dev/zero of=/var/test bs=8k count=1000000 2>> info

這樣測試的結果就到info文件裡面了

Copyright © Linux教程網 All Rights Reserved