3
# This script adjusts hard drive APM settings using hdparm. The hardware
4
# defaults (usually hdparm -B 128) cause excessive head load/unload cycles
5
# on many modern hard drives. We therefore set hdparm -B 254 while on AC
6
# power. On battery we set hdparm -B 128, because the head parking is
7
# very useful for shock protection.
10
. /usr/share/acpi-support/power-funcs
13
if [ -e /usr/sbin/laptop_mode ] ; then
14
LMT_CONTROL_HD_POWERMGMT=$(. /etc/laptop-mode/laptop-mode.conf && echo "$CONTROL_HD_POWERMGMT")
15
if [ "$LMT_CONTROL_HD_POWERMGMT" != 0 ] \
16
&& [ -e /var/run/laptop-mode-tools/enabled ]
18
# Laptop mode controls hdparm -B settings, we don't.
23
if [ "$DO_HDPARM" = y ] ; then
24
# Get the power state into STATE
27
for dev in /dev/sd? /dev/hd? ; do
29
# Check for APM support; discard errors since not all drives
30
# support HDIO_GET_IDENTITY (-i).
31
if hdparm -i $dev 2> /dev/null | grep -q 'AdvancedPM=yes' ; then
32
if [ "$STATE" = "BATTERY" ] ; then