summaryrefslogtreecommitdiff
path: root/pm/power.d/harddrive
diff options
context:
space:
mode:
Diffstat (limited to 'pm/power.d/harddrive')
-rw-r--r--pm/power.d/harddrive77
1 files changed, 73 insertions, 4 deletions
diff --git a/pm/power.d/harddrive b/pm/power.d/harddrive
index 604f2ca..4bad394 100644
--- a/pm/power.d/harddrive
+++ b/pm/power.d/harddrive
@@ -2,24 +2,93 @@
[ -x /sbin/hdparm ] || exit $NA
+# Default values on AC
+DRIVE_SPINDOWN_VALUE_AC="${DRIVE_SPINDOWN_VALUE_AC:-0}"
+DRIVE_WRITE_CACHE_AC="${DRIVE_WRITE_CACHE_AC:-1}"
+DRIVE_POWER_MGMT_AC="${DRIVE_POWER_MGMT_AC:-254}"
+DRIVE_ACOUSTIC_MGMT_AC="${DRIVE_ACOUSTIC_MGMT_AC:-0}"
+
+# Default values on battery
+DRIVE_SPINDOWN_VALUE_BAT="${DRIVE_SPINDOWN_VALUE_BAT:-6}"
+DRIVE_WRITE_CACHE_BAT="${DRIVE_WRITE_CACHE_BAT:-0}"
+DRIVE_POWER_MGMT_BAT="${DRIVE_POWER_MGMT_BAT:-1}"
+DRIVE_ACOUSTIC_MGMT_BAT="${DRIVE_ACOUSTIC_MGMT_BAT:-254}"
+
+# Default devices to operate on
+DRIVE_LIST="/dev/[hs]d[a-z]"
+
+help() {
+cat <<EOF
+Hard drive Parameters we support tweaking:
+
+Drive spindown:
+DRIVE_SPINDOWN_VALUE_AC = time until a drive will spin down on AC
+Defaults to 0, which disables drive spindown.
+
+DRIVE_SPINDOWN_VALUE_BAT = time until a drive will spin down on battery
+Defaults to 6, which will spin the drive down after 30 seconds of inactivity.
+
+See the -S option on the hdparm manpage.
+
+Drive write caching:
+DRIVE_WRITE_CACHE_AC = 0 disables write cache, 1 enables it.
+Defaults to 1
+
+DRIVE_WRITE_CACHE_BAT = 0 disables write cache, 1 enables it.
+Defaults to 0
+
+See the -W option on the hdparm man page.
+
+Drive power management:
+DRIVE_POWER_MGMT_AC = Drive Advanced Power Management value on AC
+Defaults to 254 for max performance.
+
+DRIVE_POWER_MGMT_BAT = Drive Advanced Power Management value on battery
+Defaults to 1 for max power savings.
+
+See the -B option on the hdparm man page
+
+Drive acoustic management:
+DRIVE_ACOUSTIC_MGMT_AC = Drive Acoustic Management value on AC
+Defaults to 254 for max head speed.
+
+DRIVE_ACOUSTIC_MGMT_BAT = Drive Acoustic Management value on battery
+Defaults to 128 for max quietness.
+
+See the -M option on the hdparm man page.
+
+Drives to manage:
+DRIVE_LIST = the list of hard drives to manage.
+Defaults to "/dev/[hs]d[a-z]", which will manage up to the first 25 drives.
+
+EOF
+}
+
harddrive_ac () {
- for dev in /dev/[hs]d[a-z]; do
+ for dev in $DRIVE_LIST; do
# disable write caching, do not spin down the drive, disable APM
# and acoustic management, and sync everything to drive.
- hdparm -W 0 -S 0 -B 254 -M 254 -f -F $dev
+ hdparm -W $DRIVE_WRITE_CACHE_AC \
+ -S $DRIVE_SPINDOWN_VALUE_AC \
+ -B $DRIVE_POWER_MGMT_AC \
+ -M $DRIVE_ACOUSTIC_MGMT_AC $dev
done
}
harddrive_battery() {
- for dev in /dev/[hs]d[a-z]; do
+ for dev in $DRIVE_LIST; do
# disable write caching, enable acoustic management
- hdparm -W 0 -M 128 $dev
+ hdparm -W $DRIVE_WRITE_CACHE_BAT \
+ -S $DRIVE_SPINDOWN_VALUE_BAT \
+ -B $DRIVE_POWER_MGMT_BAT \
+ -M $DRIVE_ACOUSTIC_MGMT_BAT -F $dev
done
}
case $1 in
true) harddrive_battery ;;
false) harddrive_ac ;;
+ help) help;;
*) exit $NA ;;
esac