iT邦幫忙

2024 iThome 鐵人賽

DAY 0
0
自我挑戰組

30 天homelab實做練習系列 第 7

Day-07-磁碟效能測試工具初探(一) - hdparm

  • 分享至 

  • xImage
  •  

前言

在前一篇接 USB複製 ISO檔看到的速度有疑惑,來找一些磁碟效能測試工具實測看看。

過去已有認知,有不同情境下的效能指標:

  • 讀/寫
  • 小檔/大檔
  • 連續/隨機
    檔案系統、架構設計也會有影響。

先把範圍定在試試幾個 Linux 下的磁碟效能測試工具,
簡略測測看這台小主機的 SSD、USB 讀寫效能。
看看手上消費級產品的效能。

Proxmox 就這樣先被當 Linux主機玩

hdparm

起手先安裝

apt-get install hdparm

先看 hdparm -h 注意到測讀取為主,其它功能見 manpage

  • https://manpages.debian.org/bookworm/manpages-zh/hdparm.8.zh_TW.html
  • 常見用來測試的參數
  • -t Perform device read timings
  • -T Perform cache read timings
  • --direct
    Use the kernel´s "O_DIRECT" flag when performing a -t timing test. This bypasses the page cache, causing
    the reads to go directly from the drive into hdparm's buffers, using so-called "raw" I/O. In many cases,
    this can produce results that appear much faster than the usual page cache method, giving a better indica‐
    tion of raw device and driver performance.

不用掛載磁碟,接上後即可測 (可在 dmesg -T 看到是否有偵測到)

  • M2 SSD
~# hdparm -tT /dev/nvme0n1

/dev/nvme0n1:
 Timing cached reads:   19640 MB in  2.00 seconds = 9832.56 MB/sec
 Timing buffered disk reads: 4312 MB in  3.00 seconds = 1437.17 MB/sec
 

~# hdparm -tT --direct /dev/nvme0n1

/dev/nvme0n1:

 Timing O_DIRECT cached reads:   2858 MB in  2.00 seconds = 1429.07 MB/sec
 Timing O_DIRECT disk reads: 4474 MB in  3.00 seconds = 1490.89 MB/sec

  • SATA 介面的 2.5" SSD
~# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   19250 MB in  2.00 seconds = 9637.01 MB/sec
 Timing buffered disk reads: 1590 MB in  3.00 seconds = 529.71 MB/sec
 
~# hdparm -tT --direct /dev/sda

/dev/sda:
 Timing O_DIRECT cached reads:   962 MB in  2.00 seconds = 480.85 MB/sec
 Timing O_DIRECT disk reads: 1458 MB in  3.00 seconds = 485.55 MB/sec
  • USB隨身碟(G牌),接在 USB3.0 接口
~# hdparm -tT  /dev/sdb

/dev/sdb:
 Timing cached reads:   19438 MB in  2.00 seconds = 9732.02 MB/sec
 Timing buffered disk reads: 310 MB in  3.02 seconds = 102.68 MB/sec


~# hdparm -tT --direct /dev/sdb

/dev/sdb:
 Timing O_DIRECT cached reads:   204 MB in  2.02 seconds = 101.05 MB/sec
 Timing O_DIRECT disk reads: 304 MB in  3.02 seconds = 100.79 MB/sec

  • USB隨身碟(G牌),接在 USB2.0 接口
~# hdparm -tT /dev/sdb

/dev/sdb:
 Timing cached reads:   18248 MB in  2.00 seconds = 9134.54 MB/sec
 Timing buffered disk reads: 126 MB in  3.01 seconds =  41.93 MB/sec


~# hdparm -tT --direct /dev/sdb

/dev/sdb:
 Timing O_DIRECT cached reads:    80 MB in  2.04 seconds =  39.17 MB/sec
 Timing O_DIRECT disk reads: 120 MB in  3.00 seconds =  39.99 MB/sec

  • 注意到沒使用 --direct 時, Timing cached reads 數字都漂亮到誇張…

有個有點妙的 -H

  • -H Read temperature from drive (Hitachi only)
    剛好手上有顆外接的 2.5吋硬碟,真的只對這家有效
~ $ hdparm -H /dev/sdb

/dev/sdb:
 drive temperature (celsius) is:  35
 drive temperature in range:  yes

不同家的讀不到正常數據

~ $ hdparm -H /dev/sda

/dev/sda:
SG_IO: bad/missing sense data, sb[]:  70 00 0b 00 00 00 00 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 drive temperature (celsius) is:  under -20
 drive temperature in range:  yes

  • 看硬碟資訊的

  • -i Display drive identification

  • -I Detailed/current information directly from drive

    • 另外查看硬碟訊息個人常用 smartctl
  • M2 SSD 另外要裝 nvme-clinvme smart-log /dev/nvme0n1
    歪樓不在效能測試的主題,又有點零散,先這樣。


另外

  • 傳統硬碟常見硬碟前後段速度會有差異 (等角速度下,內外圈磁錄密度)。
  • SSD 情況略有不同,儲存跟資料讀寫的技術也會影響效能,亦有的設計會在儲存空間低於一定比例後打折。
    近年各式新的儲存技術對效能的影響也是個可以試的題材…

參考資料


上一篇
Day-06-Proxmox VE 試試建一台虛擬機
下一篇
Day-08-磁碟效能測試工具初探(二) - fio
系列文
30 天homelab實做練習16
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言