You are not logged in.

#1 2013-03-06 18:17:11

From: Europe
Registered: 2012-12-28
Posts: 73

[SOLVED]: APM changes 'off' to '128' after suspend/hibernation

Well, here I'am again experiencing weird behaviour of the HDDs APM setting:

On first boot after fresh install everything was fine:

#smartctl -x /dev/sdb | grep APM
APM level is:     disabled

That is (or was?) the default setting until now.
# in fact, it itn't. The APM default, if the settings persist or if they are restored to default after power on depends on the manufacturer.

Because sometimes, without further reason on reboot or restart or sometimes just after a while working suddenly I start hearing this annoying 'klack'-'klack'-'klack', Load_Cycle_Count starts rising per second (yes, it's a WD3200BEVT)  and APM suddenly is set back to 128 (minimum power consumption without standby).

No entrys according to a change to apm in any log files and I didn't cange anything about this!
There is no power management installed, no laptop-mode-tools, nothing that could change apm settings! It's a clean and fresh install.

Edit I: 'Solved' this by complete reinstallation. Now APM stays off.
Seems like if you ever had hdparm on your system installed, APM default changes from 'off' to '128'. #nonsense
Edit Ia: It's a WD thing! Neither my Hitachi nor my Samsung HDDs show such behaviour!

Edit II: Cheered too soon! Problem persists!
Also with tested and proper working udev rule which sets APM to 255 at boot APM value switches always back to 128 after suspend/hibernation.
How can I stop this weird behaviour?  # look downwards
What is responsible for changing APM level? # WD-Firmware
How can I even prevent APM level change after standby? (of course, it switches always back to 128...)  # look downwards

Drive Information:

Model Family:     Western Digital Scorpio Blue Serial ATA
Device Model:     WDC WD3200BEVT-24A
Firmware Version: 01.01A02
User Capacity:    320.072.933.376 bytes [320 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    5400 rpm
ATA Version is:   ATA8-ACS (minor revision not indicated)
SATA Version is:  SATA 2.6, 3.0 Gb/s
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
AAM level is:     128 (quiet), recommended: 128
APM feature is:   Disabled # but will soon change...
Rd look-ahead is: Enabled
Write cache is:   Enabled
ATA Security is:  Disabled, frozen [SEC2]

Edit III:
Also there is a bug report for changing any values by systemd without notice respectively not restoring them on wakeup.
I disagree for it is definitive a WD firmware bug:
While the APM level is reset to 128 after every power on/off the AAM (hdparm -M) level setting keeps unchanged.
This is totally inconsistend behaviour.

Edit VI:
I found a solution by myself!
A real 'kiss' one without necessary to install sth. or study udev rules:

# man systemd-suspend.service says:

Immediately before entering system suspend and/or hibernation systemd-suspend.service (and the other mentioned units, respectively)
will run all executables in /usr/lib/systemd/system-sleep/ and pass two arguments to them...
Immediately after leaving system suspend and/or hibernation the same executables are run...

so I just created:

# vi /usr/lib/systemd/system-sleep/hdparm_set

hdparm -B255 /dev/sda

# chmod +x /usr/lib/systemd/system-sleep/hdparm_set

and APM after wakeup from suspend is off!

Last edited by renegat (2013-03-10 02:06:38)


#2 2013-05-06 08:48:17

Registered: 2010-05-18
Posts: 38

Re: [SOLVED]: APM changes 'off' to '128' after suspend/hibernation

Thank you, it works perfectly!


#3 2016-04-03 14:07:40

Registered: 2016-04-03
Posts: 1

Re: [SOLVED]: APM changes 'off' to '128' after suspend/hibernation

[Pardon my thread necromancy, feel free to delete]

Fast-forward to 2016. Hitachi Travelstar 7K1000 (HTS721010A9E630) doing exactly same thing, that is resetting APM level to default (128) on resume.

Renegat, thanks for the systemd information, extremely useful!

I have expanded the solution a little so it may operate on multiple drives and also handles drives that don't support APM level of 255 (but do support level 254).

Here it is, in case anyone's interested:

# place in /usr/lib/systemd/system-sleep/; make sure to chmod +x !

# device list, add more if desired

# to perform action on all scsi_disk class device, uncomment the line below
#DEVICES="$(find /sys/class/scsi_disk/*/device/block/ -mindepth 1 -maxdepth 1 -printf %f\\n)"

# pause duration in seconds;
# this is to accommodate potentially flaky firmware that would go south
# when two APM sets are done back-to-back

# run only when resuming
[ "$1" != "post" ] && exit 0


for DEV in $DEVICES ; do

	# get current value	
	T=$($HDPARM -B $DEVPATH | tail -1)
	echo $DEV: $APM

	# don't run if already off/255 or not supported
	[ "$APM" = "off" -o "$APM" = "255" -o  "$APM" = "not supported" ] && continue

	# some drives don't support 255 setting; try 254 first, then 255
	sleep $PAUSE
	sleep $PAUSE


#4 2016-04-03 16:32:00

From: Pasadena, CA
Registered: 2009-07-13
Posts: 14,869

Re: [SOLVED]: APM changes 'off' to '128' after suspend/hibernation

madamehelga wrote:

[Pardon my thread necromancy, feel free to delete]

Welcome to Arch Linux.
There are exceptions to every rule, including this one tongue
Your post brings a better solution and is version agnostic so it meets the criteria.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
How to Ask Questions the Smart Way


Board footer

Powered by FluxBB