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/harddrive25
1 files changed, 25 insertions, 0 deletions
diff --git a/pm/power.d/harddrive b/pm/power.d/harddrive
new file mode 100644
index 0000000..cdfa637
--- /dev/null
+++ b/pm/power.d/harddrive
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+[ -x /sbin/hdparm ] || exit $NA
+
+harddrive_ac () {
+ for dev in /dev/[hs]d[a-z]; do
+ #enable write caching, do not spin down the drive.
+ hdparm -W 1 -S 0 $dev
+ done
+}
+
+harddrive_battery() {
+ for dev in /dev/[hs]d[a-z]; do
+ # disable write caching, spin down after 30 seconds
+ hdparm -W 0 -S 6 $dev
+ done
+}
+
+case $1 in
+ true) harddrive_battery ;;
+ false) harddrive_ac ;;
+ *) exit $NA ;;
+esac
+
+exit 0