測試linux下磁盤的讀寫速率


1) 通過df -h命令查看磁盤情況

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda4             289G   61G  214G  23% /
tmpfs                 7.8G     0  7.8G   0% /dev/shm
/dev/sda2             969M   62M  857M   7% /boot
/dev/sda1             999M  268K  998M   1% /boot/efi
/dev/sda3             626G  8.0G  586G   2% /home


2)通過hdparm測試讀取速率

[root]# hdparm -t /dev/sda

/dev/sda:
 Timing buffered disk reads: 542 MB in  3.01 seconds = 180.09 MB/sec

從中可以看到,平均讀盤速率是180.09 MB/sec


linux下硬盤讀寫速度測試

1. 測試讀取速度

haparm -Tt /dev/xxx
1.1 獲取硬盤設備名稱:

    fdisk -l

    Disk /dev/xvdf: 365.0 GB, 365041287168 bytes

    255 heads, 63 sectors/track, 44380 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

1.2 測試硬盤讀取速度

    hdparm -tT /dev/xvdf

    /dev/xvdf:

    Timing buffered disk reads: 962 MB in 3.00 seconds = 320.56 MB/sec

1.3 硬盤讀取速度測試結果
1.3.1 台式物理機

  spec: 7200轉硬盤

    hdparm -tT /dev/sda

    /dev/sda:
    Timing cached reads: 7650 MB in 2.00 seconds = 3829.28 MB/sec
    Timing buffered disk reads: 296 MB in 3.02 seconds = 98.05 MB/sec

1.3.2 VmWare虛擬機

host spec: 7200轉硬盤

    hdparm -tT /dev/sda

    /dev/sda:
    Timing cached reads: 11396 MB in 2.00 seconds = 5704.37 MB/sec
    Timing buffered disk reads: 648 MB in 3.09 seconds = 209.45 MB/sec

1.3.3 amazon EC2上虛擬機

Instance type: m1.large

    hdparm -tT /dev/xvdf

    /dev/xvdf:
    Timing cached reads: 5830 MB in 1.99 seconds = 2923.38 MB/sec
    Timing buffered disk reads: 950 MB in 3.00 seconds = 316.61 MB/sec

2. 測試寫速度
2.1 測試方法

使用time命令和dd命令可以簡單測試硬盤的寫速率
2.2. 硬盤讀取速度測試結果
2.2.1 台式物理機

  spec: 7200轉硬盤

    time 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, 9.78201 s, 105 MB/s

    real 0m9.806s
    user 0m0.236s
    sys 0m3.120s

1.3.2 VmWare虛擬機

host spec: 7200轉硬盤

    time 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, 13.533 s, 75.7 MB/s

    real 0m13.605s
    user 0m0.113s
    sys 0m3.077s

1.3.3 amazon EC2上虛擬機

Instance type: m1.large

    time 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, 22.6497 s, 45.2 MB/s

    real 0m23.785s
    user 0m0.504s
    sys 0m5.888s

3. 總結
        物理機        VmWare虛擬機        Amazon虛擬機   
  讀速度       105     209.45     316.61
  寫速度     105     75.7     45.2

 

 

 

4. 附錄

    hdparm -h

    -a<快取分區> 設定讀取文件時,預先存入塊區的分區數,若不加上<快取分區>選項,則顯示目前的設定。

    -A<0或1> 啟動或關閉讀取文件時的快取功能。   
    -c<I/O模式> 設定IDE32位I/O模式。   
    -C 檢測IDE硬盤的電源管理模式。   
    -d<0或1> 設定磁盤的DMA模式。   
    -f 將內存緩沖區的數據寫入硬盤,並清楚緩沖區。   
    -g 顯示硬盤的磁軌,磁頭,磁區等參數。   
    -h 顯示幫助。   
    -i 顯示硬盤的硬件規格信息,這些信息是在開機時由硬盤本身所提供。   
    -I 直接讀取硬盤所提供的硬件規格信息。   
    -k<0或1> 重設硬盤時,保留-dmu參數的設定。   
    -K<0或1> 重設硬盤時,保留-APSWXZ參數的設定。   
    -m<磁區數> 設定硬盤多重分區存取的分區數。   
    -n<0或1> 忽略硬盤寫入時所發生的錯誤。   
    -p<PIO模式> 設定硬盤的PIO模式。   
    -P<磁區數> 設定硬盤內部快取的分區數。   
    -q 在執行后續的參數時,不在屏幕上顯示任何信息。   
    -r<0或1> 設定硬盤的讀寫模式。   
    -S<時間> 設定硬盤進入省電模式前的等待時間。   
    -t 評估硬盤的讀取效率。   -T 評估硬盤快取的讀取效率。   
    -u<0或1> 在硬盤存取時,允許其他中斷要求同時執行。   -v 顯示硬盤的相關設定。   
    -W<0或1> 設定硬盤的寫入快取。   -X<傳輸模式> 設定硬盤的傳輸模式。   
    -y 使IDE硬盤進入省電模式。   -Y 使IDE硬盤進入睡眠模式。   
    -Z 關閉某些Seagate硬盤的自動省電功能。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM