# Configure disk power management settings to ensure both # long disk life and good power management. # # Space delimited list of disk devices this affects. # DEVICES_DISK_PM_NAMES="/dev/sda" # # # Power management modes # # Powersave mode off # Set APM as 192 # Set spin-down for 30 minutes # DEVICES_DISK_PM_POWERSAVE_OFF="hdparm -q -B 192 -q -S 241 -q -M 128" # # Powersave mode on # Enable APM to conservative 192 and set spin-down for 21 minutes # DEVICES_DISK_PM_POWERSAVE_ON="hdparm -q -B 192 -q -S 252 -q -M 128"
2) 在power.d中加入Hook脚本,作用是在使用电池和AC电源的时候可以自动切换省电模式.
$ cd /etc/pm/power.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
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