Linux command – hdparm

Loading

透過 hdparm 指令可以 讀取/設定 SATA/IDE 硬碟狀態與設備參數
-i : 顯示目前硬碟的資訊,但僅適合 kernel drivers (IDE, libata) 下的硬碟.
-I : 顯示的訊息會比參數 -i 較多.

[root@localhost ~]# hdparm -I /dev/sda
/dev/sda:

ATA device, with non-removable media
	Model Number:       GB0250EAFYK                             
	Serial Number:      WCAT18790408        
	Firmware Revision:  HPG0    
Transport: Serial, SATA 1.0a, SATA II Extensions, SATA Rev 2.5
Standards:
	Used: Reserved 
	Supported: 7 6 5 4 
Configuration:
	Logical		max	current
	cylinders	16383	16383
	heads		16	16
	sectors/track	63	63
	--
	CHS current addressable sectors:   16514064
	LBA    user addressable sectors:  268435455
	LBA48  user addressable sectors:  488397168
	device size with M = 1024*1024:      238475 MBytes
	device size with M = 1000*1000:      250059 MBytes (250 GB)
Capabilities:
	LBA, IORDY(can be disabled)
	Queue depth: 32
	Standby timer values: spec'd by Standard, with device specific minimum
	R/W multiple sector transfer: Max = 16	Current = 16
	DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
	     Cycle time: min=120ns recommended=120ns
	PIO: pio0 pio1 pio2 pio3 pio4 
	     Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
	Enabled Supported:
	*       SMART feature set
	*       Power Management feature set Write cache
	*       Look-ahead
	*       WRITE_BUFFER command
	*       READ_BUFFER command
	*       NOP cmd
	*       DOWNLOAD_MICROCODE Power-Up In Standby feature set
	*       SET_FEATURES required to spinup after power up
	*       48-bit Address feature set
	*       Mandatory FLUSH_CACHE
	*       FLUSH_CACHE_EXT
	*       SMART error logging
	*       SMART self-test
	*       General Purpose Logging feature set
	*       WRITE_{DMA|MULTIPLE}_FUA_EXT
	*       64-bit World wide name
	*       IDLE_IMMEDIATE with UNLOAD
	*       WRITE_UNCORRECTABLE command
	*       {READ,WRITE}_DMA_EXT_GPL commands
	*       Segmented DOWNLOAD_MICROCODE
	*       SATA-I signaling speed (1.5Gb/s)
	*       SATA-II signaling speed (3.0Gb/s)
	*       Native Command Queueing (NCQ)
	*       Phy event counter DMA Setup Auto-Activate optimization
	*       Software settings preservation
Checksum: correct

可以使用下面參數,針對硬碟來設定.
-a : Get/set sector count for filesystem (software) read-ahead.
-A : Get/set the IDE drive’s read-lookahead feature (usually ON by default).
-b : Get/set bus state.
-k : Get/set the keep_settings_over_reset flag for the drive.
-m : Get/set sector count for multiple sector I/O on the drive.
-M : Get/set Automatic Acoustic Management (AAM) setting.
-N : Get/set max visible number of sectors, also known as the Host Protected Area setting.
-r : Get/set read-only flag for the device.
-u : Get/set interrupt-unmask flag for the drive.
-W : Get/set the IDE/SATA drive’s write-caching feature.
-X : Set the IDE transfer mode for (E)IDE/ATA drives.

hdparm 除了設定硬碟參數外,他也是一個比較簡單的方式來看目前硬碟傳送的速度的工具,但只能測試循序讀取的方式 (sequential data reads).

如果真的需要詳細的測試方式,請使用 iometer https://benjr.tw/370 或是 Fio https://benjr.tw/34632 來測試硬碟的速度.

常用來測試的參數.
-T : 會使用到 cache 來測試硬碟速度.
-t : 不使用 cache 來測試硬碟速度,所得到的值較為標準.
–direct : 使用 Kernel 參數 O_DIRECT 來進行測試. Direct I/O 不使用系統提供的讀取和寫入 cache ,讓讀取和寫入都直接到存儲裝置.

[root@localhost ~]# hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 306 MB in 3.01 seconds = 101.50 MB/sec
[root@localhost ~]# hdparm -t --direct /dev/sda
/dev/sda:
Timing O_DIRECT disk reads: 306 MB in 3.01 seconds = 101.50 MB/sec

使用上 Cache 速度上會提升很多,所以不建議來當測試值.

[root@localhost ~]# hdparm -T /dev/sda
/dev/sda:
Timing cached reads: 15000 MB in 1.99 seconds = 7519.43 MB/sec

以下是大概的數值僅供參考,效能會依據不同 chipset 而有所變動,OS 是否能支援你的 chipset 也會影響到測試結果(這裡是用 INTEL server , OS 是 RedHat Enterprise Linux 5 Update2, SAS 卡 chipset 為 LSI1064 )

  1. SATA 7200 rpm H.D
    Timing buffered disk reads: 227 MB in 3.02 seconds = 75.21 MB/sec
  2. SAS 1000 rpm H.D
    Timing buffered disk reads: 277 MB in 3.01 seconds = 92.66 MB/sec

更多的參數應用請參考 https://benjr.tw/96289

沒有解決問題,試試搜尋本站其他內容

5 thoughts on “Linux command – hdparm

  1. 自動引用通知: Iometer | Benjr.tw

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料