case "$1" in
true)
echo "**enabled pm for harddisk"
for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do
${DEVICES_DISK_PM_POWERSAVE_ON} ${DISK_NAME}
done ;;
false)
echo "**disabled pm for harddisk"
for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do
${DEVICES_DISK_PM_POWERSAVE_OFF} ${DISK_NAME}
done ;;
esac
$ sudo chmod +x disk
3) 在sleep.d中加入脚本,目的是在休眠/待机之后唤醒的时候重新设定hdparm的参数:
$ cd /etc/pm/sleep.d/
$ sudo vi disk
#!/bin/bash
. /usr/lib/pm-utils/functions
. /etc/pm/config.d/disk
if test -z ${DEVICES_DISK_PM_NAMES}; then
exit 1
fi
case "$1" in
thaw|resume)
/usr/bin/on_ac_power;
if [ "$?" -eq 0 ]; then
echo "**disabled PM for harddisk"
for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do
${DEVICES_DISK_PM_POWERSAVE_OFF} ${DISK_NAME}
done
elif [ "$?" -eq 1 ]; then
echo "**enabled PM for harddisk"
for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do
${DEVICES_DISK_PM_POWERSAVE_ON} ${DISK_NAME}
done
fi
;;
esac
$ sudo chmod +x disk
***注意最后一定要为disk脚本添加执行权限。否则pm.tuils不会自动执行这段脚本
4) 如果你没有启用laptop mode (默认是不启用的),可以跳过这部分了。
由于Ubuntu中acpi和pm.utils是共存的,所以如果你启用了laptop mode,那么在改变电源状态(指电池->AC电源或者反之)的时候,acpi会在启用/停用laptop mode的同时设置hdparm参数,会覆盖掉pm-utils所做的设置。
所以如果你启用了laptop mode的话,需要做如下修改:
1′ $ sudo vi /etc/default/acpi-support
将最后的
SPINDOWN_TIME=12
修改为
SPINDOWN_TIME=241
2′ $ sudo vi /etc/acpi/power.sh
将function laptop_mode_enable部分的
$HDPARM -B 1 /dev/$drive 2>/dev/null
修改成
$HDPARM -B 192 /dev/$drive 2>/dev/null
上述的解决方案在Dell Inspiron 700m + Ubuntu 8.04.1上测试通过。在待机唤醒之后参数会重新被设置,但是由于我的机器上休眠有问题,所以没有办法测试休眠。但理论上来也是可以的。
3. 我想定期检测Load_Cycle_Count,怎么办?
好办,这里是一个脚本,具体用法在注释里面粗体标明了。(不好意思…注释好像比代码都长)
#!/bin/bash
#
# @Description:
#
# check_lcc v0.2
#
# Check Load_Cycle_Count from S.M.A.R.T info of your hard drive
# when power on and off and Save them to $FILE in following format:
#
# LCC TIME
# ON 110044 18:05:00 2008-09-08
# OFF 110044 18:10:03 2008-09-08
#
# "ON" indicates POWER ON while "OFF" indicates POWER OFF, LCC is
# exactly Load_Cycle_Count of your hard drive at TIME.
#
# @Usages:
#
# 1. sudo vi /etc/init.d/check_lcc
# 2. copy all the contents of this script to it
# *** Note that u need to modify "FILE" as what u want.
# save and quit.
# 3. sudo chmod +x /etc/init.d/check_lcc
# 4. sudo update-rc.d check_lcc start 1 2 . stop 99 0 6 .
# 5. Have fun.
#
# This script was tested under Ubuntu 8.04.1.
#
# @Author:
#
# breaddawson@gmail.com
# 2008/09/07
FILE="/home/bread/lcc_report.txt"
STAT=`smartctl -a /dev/sda | grep 193 | sed -nr "s/.*[[:space:]]([[:digit:]]{1,})$/\1/p"`"\t "`date +’%T %F’`