Disk Power Management
From openSUSE
Contents |
Introduction
Because bad things can happen [1][2][3] when your power-management disk parks or spins down too often, you may want to use the following scripts to manage the situation a little better.
The following HOWTO will take you through this step-by-step.
All of these steps will need have the appropriate sudo or su access.
Disk Power Management Configuration
Create a configuration file to management disk power management:
/etc/pm/config.d/disk
# 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 # Disable APM and spin-down # DEVICES_DISK_PM_POWERSAVE_OFF="hdparm -q -B 255 -q -S 0" # # Powersave mode on # Enable APM to conservative 200 and set spin-down for 21 minutes # DEVICES_DISK_PM_POWERSAVE_ON="hdparm -q -B 200 -q -S 252"
Note: Your laptop drive can get hot with no power management if you leave your laptop plugged in all the time. You may want to set DEVICES_DISK_PM_POWERSAVE_OFF to a large value, but not disabled completely. If you were going to do this, you might use something like: hdparm -q -B 254 -q -S 242
This means set the least power management, but not off, and spin down the disk after an hour.
Disk Power Management Script
Then create the power management script:
/etc/pm/power.d/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
Make the script executable.
chmod +x /etc/pm/power.d/disk
Test the script
You can then test the set up by using the following commands:
pm-powersave true hdparm -I /dev/sda | grep 'Advanced Power'
An asterisk next to 'Advanced Power Management feature set' means its enabled. Now try this:
pm-powersave false hdparm -I /dev/sda | grep 'Advanced Power'
No asterisk means it's disabled.
These settings are immediately accessible to kpowersave or gnome-power-manager and are used by default when plugging in your power adapter or removing it on a laptop.

