Thursday, October 20, 2011

hdparm spin down problem (自旋停止) 设置


Documented here
To prevent your laptop hard drive from spinning down too often (result of too aggressive APM defaults) do the following:
Add the following to /etc/rc.local
hdparm -B 254 /dev/sdX where X is your hard drive device
You can also set it to 255 to completely disable spinning down. You may wish to set a lower value if you move your laptop around as lower values park the heads more often and reduce the chance of damage to your hard disk while it is being moved. If you do not move your laptop at all when you are using it, then 255 or 254 is probably best. If you do, then you might want to try a lower value. A value like 128 might be a good middle-ground.
Add the following to /etc/pm/sleep.d/50-hdparm_pm
#!/bin/sh
 
if [ -n "$1" ] && ([ "$1" = "resume" ] || [ "$1" = "thaw" ]); then
 hdparm -B 254 /dev/your-hard-drive > /dev/null
fi
and run chmod +x /etc/pm/sleep.d/50-hdparm_pm to make sure it resets after suspend. Again, you can change the value 254 as you see fit.
Now the APM level should be set for your hard drive.
For some laptops, the option -S to hdparm can also be relevant (sets the spindown time for the drive). Note that all these options can also be configured using the laptop-mode tools. This will allow you to set a high value when on AC and a lower value when you are running on battery power.t

 运行一下命令
# smartctl -d ata -a /dev/sda | grep "Load_Cycle"; hdparm -B 180 /dev/sda; sleep 600;\
smartctl -d ata -a /dev/sda | grep "Load_Cycle"; hdparm -B 255 /dev/sda

可以看到 当 设置 180的时候,10分钟就 增加了很多 Load_Cycle计数,所以最好设置为
 254
这个问题的出现 可以使用2种解决办法, 1是 写 /etc/rc.local,2 是在lapbot-mode tools中设置


我采用的办法是使用 laptop-mode tools设置,

# vim /etc/laptop-mode/laptop-mode.conf


参考阅读 arch wiki Laptop#Hard_drive_spin_down_problem
                 Hard drive advanced power management level can kill your laptop drive?
                High frequency of load/unload cycles on some hard disks may shorten lifetime

No comments: