LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Possibly wrong comments in 'harddrive' pm-utils script (https://www.linuxquestions.org/questions/slackware-14/possibly-wrong-comments-in-harddrive-pm-utils-script-4175461312/)

sanjioh 05-09-2013 12:29 PM

Possibly wrong comments in 'harddrive' pm-utils script
 
Hi everybody,

digging inside pm-utils on Slackware64 14 I found some possibly wrong comments in this file:

/usr/lib64/pm-utils/power.d/harddrive

Look at the ones inside functions harddrive_ac() and harddrive_battery(); to be clear, the descriptions of the hdparm commands that come immediately before the commands themselves.

Not a big deal, of course :)

Bye

sanjioh 05-10-2013 06:03 PM

Hi,

I'll try to better explain what I've noticed (sorry, didn't have the time when I posted this).

Code:

#!/bin/sh

[ -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:-128}"
DRIVE_ACOUSTIC_MGMT_BAT="${DRIVE_ACOUSTIC_MGMT_BAT:-254}"

# Default devices to operate on
DRIVE_LIST="/dev/[hs]d[a-z]"

help() {
cat <<EOF
--------
$0: Control hard drive spindown, write caching,
    power management and acoustic management.

This hook has 8 tuneable parameters:
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 for more information.

DRIVE_WRITE_CACHE_AC = Whether the drive caches writes on AC
Defaults to 1, which means that the drive will cache writes internally.
DRIVE_WRITE_CACHE_BAT = Whether the drive caches writes on battery.
Defaults to 0 which means that the drive will not cache writes internally.

See the -W option on the hdparm man page for more information.

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. # defaults to 128

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. # defaults to 0 -> AAM off
DRIVE_ACOUSTIC_MGMT_BAT = Drive Acoustic Management value on battery
Defaults to 128 for max quietness. # defaults to 254 -> actually max loudness, according to manpages

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 $DRIVE_LIST; do
        # disable write caching, do not spin down the drive, disable APM    < caching is enabled
        # and acoustic management, and sync everything to drive.            < there's no syncing

        printf "Disabling hard drive power management for %s..." "$dev"
        hdparm -W $DRIVE_WRITE_CACHE_AC \
            -S $DRIVE_SPINDOWN_VALUE_AC \
            -B $DRIVE_POWER_MGMT_AC \
            -M $DRIVE_ACOUSTIC_MGMT_AC $dev >/dev/null 2>&1 \
            && echo Done. || echo Failed.
    done
}

harddrive_battery() {
    for dev in $DRIVE_LIST; do
        # disable write caching, enable acoustic management    < syncing goes here; missing descriptions
        printf "Enabling power management for %s..." "$dev"
        hdparm -W $DRIVE_WRITE_CACHE_BAT \
            -S $DRIVE_SPINDOWN_VALUE_BAT \
            -B $DRIVE_POWER_MGMT_BAT \
            -M $DRIVE_ACOUSTIC_MGMT_BAT -F $dev >/dev/null 2>&1 \
            && echo Done. || echo Failed.
    done
}

case $1 in
    true) harddrive_battery ;;
    false) harddrive_ac ;;
    help) help;;
    *) exit $NA ;;
esac

exit 0


Maybe this script should be checked :\
Please correct me if my understanding is somehow wrong.

bye!

sanjioh 05-11-2013 04:48 AM

Plus: DRIVE_POWER_MGMT_BAT at 128 is in conflict with DRIVE_SPINDOWN_VALUE_BAT at 6, because hdparm -B permits spindowns for values from 1 through 127 only.
related reference: https://bugs.archlinux.org/task/20699


All times are GMT -5. The time now is 05:25 AM.