Installed pm-utils and had it working for a long time. Suddenly it stopped being executed:
erlangen:~ # ll /var/log/pm-suspend.log
-rw-r--r-- 1 root root 8643 Dec 18 05:44 /var/log/pm-suspend.log
erlangen:~ #
Installed pm-utils and had it working for a long time. Suddenly it stopped being executed:
erlangen:~ # ll /var/log/pm-suspend.log
-rw-r--r-- 1 root root 8643 Dec 18 05:44 /var/log/pm-suspend.log
erlangen:~ #
Just trying to get a handle on this…
pm-suspend
and does that then write to pm-suspend.log?
This works perfectly, machine is suspended upon issuing the command and resumes when the power button is pressed. A log is written displaying that the payload added by me long ago gets executed:
/etc/pm/sleep.d/wakeup suspend suspend: success.
Thu Jan 14 15:16:27 CET 2016: performing suspend
Thu Jan 14 15:17:01 CET 2016: Awake.
Thu Jan 14 15:17:01 CET 2016: Running hooks for resume
Running hook /etc/pm/sleep.d/wakeup resume suspend:
/dev/sdb:
setting standby to 60 (5 minutes)
/etc/pm/sleep.d/wakeup resume suspend: success.
Running hook /usr/lib/pm-utils/sleep.d/99video resume suspend:
- Is there any particular reason that you are still using pm-utils?
No. What I want to have is /dev/sdb being only activated when accessed through Samba or rsync performing a backup. With the current configuration it gets activated upon boot and resume anyway and is deactivated by issuing* hdparm -S 60 /dev/sdb.*
Ok, now we have a better picture of what you’re trying to do. The best idea is to remove pm-utils, unless you really need it. Systemd can do the same anyway using a custom service file. For example, create /etc/systemd/system/hdparm.service
[Unit]
Description=Local system resume actions
After=sleep.target
[Service]
Type=simple
ExecStart=/usr/bin/hdparm -S 60 /dev/sdb
[Install]
WantedBy=sleep.target
Then enable and start it
systemctl enable hdparm.service
systemctl start hdparm.service
An alternative is to add a small script in /usr/lib/systemd/system-sleep/, but that is considered a hack apparently.
Some good references here:
https://wiki.archlinux.org/index.php/Power_management#Sleep_hooks
https://wiki.archlinux.org/index.php/hdparm#APM_level_reset_after_suspend
Pasted everything as is and got an error. Fixed path /usr/sbin/hdparm and retried:
Jan 14 21:13:23 erlangen.home hdparm[25715]: /dev/sdb:
Jan 14 21:13:23 erlangen.home hdparm[25715]: setting standby to 60 (5 minutes)
lines 10319-10394/10394 (END)
Some good references here:
Power management - ArchWiki
hdparm - ArchWiki
Thanks for pointing to archlinux wiki.
So, it’s working as desired now?
I thought so. However having a closer look I found the invocation of hdparm to occur when sending to sleep:
Jan 14 21:33:24 erlangen.home NetworkManager[685]: <info> sleep requested (sleeping: no enabled: yes)
Jan 14 21:33:24 erlangen.home NetworkManager[685]: <info> sleeping...
Jan 14 21:33:24 erlangen.home NetworkManager[685]: <info> NetworkManager state is now ASLEEP
Jan 14 21:33:24 erlangen.home hdparm[26453]: /dev/sdb:
Jan 14 21:33:24 erlangen.home hdparm[26453]: setting standby to 60 (5 minutes)
Jan 14 21:33:56 erlangen.home kernel: PM: Syncing filesystems ... done.
Jan 14 21:33:56 erlangen.home kernel: PM: Preparing system for mem sleep
Jan 14 21:33:56 erlangen.home kernel: Freezing user space processes ... (elapsed 0.002 seconds) done.
Jan 14 21:33:56 erlangen.home kernel: Freezing remaining freezable tasks ... (elapsed 0.000 seconds) done.
Jan 14 21:33:56 erlangen.home kernel: PM: Entering mem sleep
Perhaps try…
[Unit]
Description=Local system resume actions
After=suspend.target
[Service]
Type=simple
ExecStart=/usr/bin/hdparm -S 60 /dev/sdb
[Install]
WantedBy=suspend.target
The above indeed works. I double checked:
erlangen:/etc/systemd/system # cat /etc/systemd/system/hdparm.service
[Unit]
Description=Local system resume actions
After=suspend.target
[Service]
Type=simple
ExecStart=/usr/sbin/hdparm -S 60 /dev/sdb
[Install]
WantedBy=suspend.target
erlangen:/etc/systemd/system # journalctl -b -u hdparm
-- Logs begin at Fri 2015-01-23 09:13:09 CET, end at Fri 2016-01-15 08:00:01 CET. --
...
Jan 15 07:43:26 erlangen.home hdparm[29445]: /dev/sdb:
Jan 15 07:43:26 erlangen.home hdparm[29445]: setting standby to 60 (5 minutes)
erlangen:/etc/systemd/system #
That’s good to know