LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 05-09-2013, 01:29 PM   #1
sanjioh
Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 63

Rep: Reputation: Disabled
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
 
Old 05-10-2013, 07:03 PM   #2
sanjioh
Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 63

Original Poster
Rep: Reputation: Disabled
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!

Last edited by sanjioh; 05-10-2013 at 07:11 PM.
 
Old 05-11-2013, 05:48 AM   #3
sanjioh
Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 63

Original Poster
Rep: Reputation: Disabled
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

Last edited by sanjioh; 05-11-2013 at 05:52 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to correct possibly wrong directory entry ? jbenezech Linux - Server 2 07-29-2012 09:31 PM
Problems Installing Slackware 10.2/Wrong Harddrive Size Mach Won Linux - Software 5 05-23-2006 11:09 AM
Wrong HardDrive Space Being Reported wfernley Linux - Software 7 03-01-2006 02:01 PM
Sound issues with USB device, possibly because of Harddrive craigienz Linux - General 1 10-24-2004 06:30 AM
looking for script - strip out all # comments itsjustme Programming 3 03-11-2004 11:57 AM


All times are GMT -5. The time now is 01:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration