0

While investigating why my hard drive load cycle count was increasing, I observed my APM level gets reset each time I come out of Suspend on my Debian Jessie laptop running MATE:

$ sudo smartctl --get=apm /dev/sda
...
APM feature is:   Disabled
$ sudo hdparm -I /dev/sda | grep level
    Advanced power management level: disabled
$ sudo hdparm -B /dev/sda

/dev/sda:
 APM_level  = off

After putting the laptop into Suspend and then taking it out of Suspend, I have the following:

$ sudo hdparm -I /dev/sda | grep level
    Advanced power management level: 128
$ sudo smartctl --get=apm /dev/sda
...
APM level is:     128 (minimum power consumption without standby)
$ sudo hdparm -B /dev/sda

/dev/sda:
 APM_level  = 128

I tried enabling the APM options in /etc/hdparm.conf, but it didn't seem to help:

...
# -B apm setting
#apm = 255
apm = 255
# -B apm setting when on battery
#apm_battery = 127
apm_battery = 255
...

Then:

$ sudo /etc/init.d/hdparm restart

After putting the hard drive into Suspend and bringing it back out, I noticed the APM level is back to 128.

1
  • I don't know MATE at all so it's a long shot: it may have its own power management settings and they interfere. Something like this where there is a 'disks' entry on the left (yet it's from 2012, rather old). I believe this screenshot is from mateconf-editor. Commented Jun 11, 2017 at 7:43

2 Answers 2

2

Do you use an SSD drive? In my case the acoustic level management for HDD set by default in /etc/hdparm.conf was the culprit.

These settings eventually did the trick for me:

# quiet # this should be commented out

/dev/disk/by-id/<YOUR_DISK_UUID> {
        acoustic = 128
        keep_features_over_reset = on
}

After this my SSD drive stopped changing APM level on suspend/resume, as well as this fixed an SG_IO error, probably related to the same issue.

More on finding your disk UUID and hdparm configuration can be found here: http://forum.havetheknowhow.com/viewtopic.php?t=479

Hope that helps!

1
  • For new folks, it would help to mention this will require restarting /etc/init.d/hdparm for changes to take effect. I'm afraid this didn't work for me. For my drive, hdparm -M reports acoustic is not supported, and if I put in the "acoustic = 128" setting, my /var/log/syslog shows hdparm didn't like that setting. Without it, the effect is unchanged.
    – jia103
    Commented Dec 21, 2017 at 3:36
0

I never figured out the underlying cause, but I was able to work around this by adding the following to a new /etc/systemd/system/tweak_hdparm_apm-resume.service file:

[Unit]
Description=Sets APM value to 254
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target

[Service]
User=root
Type=oneshot
ExecStart=/path/to/tweak_hdparm_apm.sh

TimeoutSec=0
StandardOutput=syslog

[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target

and then the following for my tweak_hdparm_apm.sh to run on each wake-up:

#!/bin/sh
#
# Something on my Debian laptop keeps setting the APM level to 128 every
# time it comes out of sleep. This script sets the value to 254 for best
# performance and least aggressive APM to conserve the life of the hard
# drive.

# --- Running hdparm -B to get current value
oldvalue=$(/sbin/hdparm -B /dev/sda)

# --- Running hdparm to set new -B value to 254 (APM best/highest I/O performance and least aggressive APM)
/sbin/hdparm -B 254 /dev/sda

newvalue=$(/sbin/hdparm -B /dev/sda)

echo "$(date) Args: ${*} Oldvalue: ${oldvalue} Newvalue: ${newvalue}" >> tweak_hdparm_apm.log

exit ${?}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .