2008年4月28日

警惕 laptop-mode-tools 的 HD_IDLE_TIMEOUT 参数

之前讨论影响硬盘寿命的 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.
发表评论