You are not logged in.

#1 2015-10-29 19:12:19

a2r
Member
Registered: 2013-07-16
Posts: 24

[solved] hdparm values are not set on boot and resume

Hey guys,

so basicly my problem is described in the subject.

I followed the wiki for setting hdparm values on boot and on resume after sleep. But every time I boot or resume from sleep the value is set back to 128.

I know it worked when i tried Arch a few years ago but now I don't know where to look.

Thanks for help in advance!

Last edited by a2r (2015-10-31 12:39:55)

Offline

#2 2015-10-30 02:44:14

Pingwinski
Member
From: Sweden
Registered: 2010-10-09
Posts: 15

Re: [solved] hdparm values are not set on boot and resume

Resume works with:
systemd 226-1
hdparm 9.48-1

Did you remember to make the script executable? If so, maybe check $ man systemd-suspend.service to see if anything has changed or make the script do something else for verification, like:

#!/bin/sh
date >> /tmp/resumed

Last edited by Pingwinski (2015-10-30 03:15:13)

Offline

#3 2015-10-30 13:02:25

a2r
Member
Registered: 2013-07-16
Posts: 24

Re: [solved] hdparm values are not set on boot and resume

Thanks for the reply.
I did make it executable, but why should this change the man page?

I did the check if the script gets run.
It does print the date to /tmp/resumed, once before sleep once after.
Then I put "hdparm -B255 /dev/sda" above the echo, the date still gets printed, the value for hdparm does not get set.
Is there maybe a place from where hdparm is getting called again AFTER the script in /usr/lib/systemd/system-sleep and thus sets it to 255 and then back to 128?

Offline

#4 2015-10-30 15:45:55

Pingwinski
Member
From: Sweden
Registered: 2010-10-09
Posts: 15

Re: [solved] hdparm values are not set on boot and resume

Since my systemd isn't the latest version I wanted to rule out any changes there.

If the hdparm command working manually (checked with $ hdparm -B <dev>) is copy-pasted to systemd files (to rule out mistypes) then I agree something else is happening here. The only service calling hdparm that I know of is laptop-mode-tools.

Sorry if I come off as mistrusting, just want to be thorough wink

You could create a proxy script for hdparm to log when it's executed:

# mv /usr/bin/hdparm /usr/bin/hdparm.orig
# vim /usr/bin/hdparm
#!/bin/sh
LOGFILE=/tmp/hdparm_executed

echo "$(date)
hdparm args: $@
" >> $LOGFILE

/usr/bin/hdparm.orig $@
# chmod +x /usr/bin/hdparm

After testing, don't forget to:

# mv /usr/bin/hdparm.orig /usr/bin/hdparm

Edit: fixed atomic output in the script

Last edited by Pingwinski (2015-10-30 17:10:43)

Offline

#5 2015-10-30 19:40:03

a2r
Member
Registered: 2013-07-16
Posts: 24

Re: [solved] hdparm values are not set on boot and resume

Okay, I did your next trick (btw. I'm learning some nifty tricks from you, thankss for that wink )

Here is the output:

hdparm_executed wrote:

Fr 30. Okt 20:31:48 CET 2015
hdparm args: -I /dev/sda

Fr 30. Okt 20:31:48 CET 2015
hdparm args: -B 254 /dev/sda

Fr 30. Okt 20:31:48 CET 2015
hdparm args: -B255 /dev/sda

Fr 30. Okt 20:31:48 CET 2015
hdparm args: -B255 /dev/sda

Fr 30. Okt 20:31:55 CET 2015
hdparm args: -B255 /dev/sda

Fr 30. Okt 20:31:55 CET 2015
hdparm args: -I /dev/sda

Fr 30. Okt 20:31:56 CET 2015
hdparm args: -B 128 /dev/sda

Fr 30. Okt 20:32:05 CET 2015
hdparm args: -B /dev/sda

One can see, that the value gets set before sleep a few times and then again AFTER  resume to 255 and a second later to 128. Is there a way to see who called that?

I also looked if laptop-mode-tools is installed, it's not.

Offline

#6 2015-10-30 23:36:12

Pingwinski
Member
From: Sweden
Registered: 2010-10-09
Posts: 15

Re: [solved] hdparm values are not set on boot and resume

I guess you can find the spooky actor in some systemd unit file. Before trying to get the calling process via scripting* (which might just turn out to be ''systemd", idk) try searching directories containing unit files and grep for "hdparm". Something like this:

$ find /etc/systemd/ /usr/lib/systemd/ -type f -exec grep hdparm '{}' + 2> /dev/null

If you find anything other than your own script please check what package(s) owns the file(s) with pacman:

$ pacman -Qo <files>

This command searches and passes findings to pacman directly:

$ find /etc/systemd/ /usr/lib/systemd/ -type f -exec grep hdparm '{}' + 2> /dev/null | cut -d':' -f1 | xargs pacman -Qo

Maybe there's a config file for the spooky actor, which could be a cleaner way of calling hdparm than having one's own script.

* If you want to try to get the parent process from the script maybe this'll work:
http://www.linuxquestions.org/questions … pt-526384/
http://stackoverflow.com/questions/3586 … using-bash

Good luck, don't forget to report back if solved!

Edit:
Just remembered something I read in the man page for systemd-suspend.service:
"If applications want to be notified of system suspend/hibernation and resume, there are much nicer interfaces available."
So the above approach might not yield if the spooky actor is something more sophisticated like a power management service (in gnome?).

Edit #2:
udisks can modify spin-down aswell:
https://bbs.archlinux.org/viewtopic.php?id=181977

Edit #3:
Gnome disk settings:
http://askubuntu.com/questions/39760/ho … 876#387876
This is why I'm on fluxbox tongue

Last edited by Pingwinski (2015-10-31 00:51:45)

Offline

#7 2015-10-31 01:10:06

a2r
Member
Registered: 2013-07-16
Posts: 24

Re: [solved] hdparm values are not set on boot and resume

DAAAAAAAAAAAAAAAAARGH!!!!
I found it. TLP set the values to 128. I changed them in /etc/default/tlp now everything works, I don't even need the systemd units and script anymore.
Your link in Edit #2 helped me find it.

Changed

DISK_APM_LEVEL_ON_AC="254 254"
DISK_APM_LEVEL_ON_BAT="128 128"

to

DISK_APM_LEVEL_ON_AC="254 254"
DISK_APM_LEVEL_ON_BAT="254 254"

Thanks alot for the help! How do I tag a thread as solved big_smile?

Offline

#8 2015-10-31 04:21:48

Pingwinski
Member
From: Sweden
Registered: 2010-10-09
Posts: 15

Re: [solved] hdparm values are not set on boot and resume

Nice to hear! big_smile
It sucks having to worry about drive health. Took me a couple of hundred thousand load cycles before I researched the weird behaviour and sounds. Spin-down time is either ~6 seconds or OFF on my ST1000LM024 HN-M101MBB!

As for marking as solved, I think manually editing the first post is the way to go.

Offline

#9 2015-10-31 12:39:39

a2r
Member
Registered: 2013-07-16
Posts: 24

Re: [solved] hdparm values are not set on boot and resume

For me, it was first a paranoia that my harddrive would die in a year if it spins down that fast. Now that harddrive is 5 years old and never complained about anything. That laptop is now just a secondary machine I take with me to work on when I'm not at home, so I don't care about the drive anymore (in fact, when it dies I put in an SSD, so I kind of want it to happen big_smile) but that clicking is really anoying me.
Again, thanks for the help. May the tux be with you!

Offline

Board footer

Powered by FluxBB