警惕 laptop-mode-tools 的 HD_IDLE_TIMEOUT 參數

http://lymanrb.blogspot.com/2008/04/laptop-mode-tools-hdidletimeout.html

之前討論影響硬盤壽命的 load/unload 的問題(見舊文一舊文二),都是集中於對 haprm -B 參數的調整。而這次要提醒大家注意的,是 hdparm -S 參數。

這裏是 man hdparm 的 -S 部分的說明。


Set the standby (spindown) timeout for the drive. This value is used by the drive to deter‐mine how long to wait (with no disk activity) before turning off the spindle motor to save power. Under such circumstances, the drive may take as long as 30 seconds to respond to a subsequent disk access, though most drives are much quicker. The encoding of the timeout value is somewhat peculiar. A value of zero means "timeouts are disabled": the device will not automatically enter standby mode. Values from 1 to 240 specify multiples of 5 seconds, yielding timeouts from 5 seconds to 20 minutes. Values from 241 to 251 specify from 1 to 11 units of 30 minutes, yielding timeouts from 30 minutes to 5.5 hours. A value of 252 signifies a timeout of 21 minutes. A value of 253 sets a vendor-defined timeout period between 8 and 12 hours, and the value 254 is reserved. 255 is interpreted as 21 minutes plus 15 seconds. Note that some older drives may have very different interpretations of these values.


看了之後冷汗直冒,實在是一個殺傷力很強的參數。如果有幸使用了 laptop-mode-tools,那麼可以看一下 /etc/laptop-mode/laptop-mode.conf 裏面,關於 -S 參數定義的部分。

#
# Should laptop mode tools control the hard drive idle timeout settings?
#
CONTROL_HD_IDLE_TIMEOUT=1

#
# Idle timeout values. (hdparm -S)
# Default is 2 hours on AC (NOLM_HD_IDLE_TIMEOUT_SECONDS=7200) and 20 seconds
# for battery and for AC with laptop mode on.
#
LM_AC_HD_IDLE_TIMEOUT_SECONDS=20
LM_BATT_HD_IDLE_TIMEOUT_SECONDS=20
NOLM_HD_IDLE_TIMEOUT_SECONDS=7200


我的 archlinux 上,laptop-mode-tools 使用的默認值僅僅是 20 秒!趕緊檢查了一下 Load Cycle Count 的值(可能需要 root 權限,請自行 sudo),

$ smartctl -a /dev/sda | grep 193
193 Load_Cycle_Count 0x0032 100 100 000 Old_age Always - 18556

如此高的數值,1 月份買的新機器,華麗地中招了 :(

預防辦法很簡單,將上述各 IDLE 值相應調大即可。不知道爲什麼 laptop-mode-tools 的默認設置會如此“有進取心的”(這裏還真沒想到用什麼詞比較貼切,英文可以用 aggressive)。或許對於這個問題,laptop-mode 的開發方並沒有給予太多關注。

Spinning down too many times may kill hard drives

Desktop hard drives are usually rated for only 40,000-50,000 spinups, and one spinup every 10 minutes will kill your 40,000-spinup HD in 277 days. So this is NOT recommended for server use, unless you increase the spinup interval dramatically, to say once every hour or two. Laptop hard drives are usually rated for around 300,000 spinups, so those will last about 2083 days or 6 years if you have them powered on 24-7.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章