You are not logged in.

#1 2022-03-12 13:19:15

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,687

[Solved] Custom systemd service disables after every kernel update

I was having a problem with the suspend to RAM function of my desktop. The computer doesn't wake up and runs to overdrive until I manually reboot. After further investigation, I solved the problem by enabling  via /proc/acpi/wakeup, my disabled nvme drive:

echo PXSX > /proc/acpi/wakeup

so I created a systemd service file /etc/systemd/system/wakeup-nvme.service:

[Unit]
Description=Wakeup nvme drives from sleep
Before=sleep.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c "echo PXSX > /proc/acpi/wakeup"

[Install]
WantedBy=sleep.target

I enable the service and it solves my problem of suspend to RAM.
I discovered however that after every kernel update, the service disables on reboot.
My question is should I run a pacman hook after every kernel update to fix this so it remains enabled? Or is it possible to fix this via the service file?

Last edited by d_fajardo (2022-03-14 20:51:27)

Offline

#2 2022-03-12 13:34:34

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [Solved] Custom systemd service disables after every kernel update

enabling a service just creates a symlink in /etc/systemd/system/. There's no way a kernel update deletes it unless you have a strange hook somewhere to do it specifically.

Last edited by Scimmia (2022-03-12 13:34:52)

Offline

#3 2022-03-12 14:44:23

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,687

Re: [Solved] Custom systemd service disables after every kernel update

The actual symlink resides in /etc/systemd/system/sleep.target.wants and not in  /etc/systemd/system since the actual service file resides there. But I would'nt think this directory situation has any bearing to the problem? I don't see any hook that might disrupt.

Offline

#4 2022-03-12 15:31:33

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,275

Re: [Solved] Custom systemd service disables after every kernel update

Does the symlink actually get removed w/ kernel updates??

Offline

#5 2022-03-12 16:15:59

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,687

Re: [Solved] Custom systemd service disables after every kernel update

Does the symlink actually get removed w/ kernel updates??

That I failed to check and I've already reenable the service. I'll monitor it then till the next upgrade.

Offline

#6 2022-03-13 07:51:55

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,687

Re: [Solved] Custom systemd service disables after every kernel update

Does the symlink actually get removed w/ kernel updates??

I revised the title of my post because now I discovered update to systemd disables the service as well.
After the latest systemd upgrade, I rebooted and the drive is back to being disabled at /proc/acpi/wakeup. Checked systemctl status and the service is inactive.
However, the symlink in /etc/systemd/system/sleep.target.wants doesn't get removed.
Still not clear why the service gets disabled on certain updates and yet the symlink exists.

Offline

#7 2022-03-13 11:11:30

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [Solved] Custom systemd service disables after every kernel update

The service is not going to be active after a reboot until sleep.target is activated by suspend. Inactive doesn't mean disabled.

Offline

#8 2022-03-13 12:15:59

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,275

Re: [Solved] Custom systemd service disables after every kernel update

Maybe we start this from the other side: what makes you believe the service is disabled?

Offline

#9 2022-03-13 23:16:40

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,687

Re: [Solved] Custom systemd service disables after every kernel update

Maybe we start this from the other side: what makes you believe the service is disabled?

After the said upgrades, kernel or systemd, I reboot and then I check systemctl status wakeup-nvme.service and the service is not loaded but flags that the service does exist.
I also then check /proc/acpi/wakeup, the device meaning to be enabled is back to being disabled.
It surprises me why this is as the symlink continues to exists.
I tried implementing the wakeup call via udev with udev rule but somehow I can't manage to enable the wakeup via this rule. But that could also have been my rule was not good enough.

Offline

#10 2022-03-14 06:30:17

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,275

Re: [Solved] Custom systemd service disables after every kernel update

I reboot and then I check systemctl status wakeup-nvme.service and the service is not loaded

Raynman wrote:

The service is not going to be active after a reboot until sleep.target is activated by suspend. Inactive doesn't mean disabled.

I also then check /proc/acpi/wakeup, the device meaning to be enabled is back to being disabled.

Because procfs is a transient - it doesn't survive a reboot.

Offline

#11 2022-03-14 08:21:22

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,687

Re: [Solved] Custom systemd service disables after every kernel update

Because procfs is a transient - it doesn't survive a reboot.

Yes of course! That answers it.
What would be the best way to solve this in such a way that I can forget about it?
I'm just thinking of creating a startup script that starts  the service on every boot instead of just simply enabling it.

EDIT: It does survive the reboot as long as it's not after a system update. I assume the kernel or systemd resets the procfs on update.

Last edited by d_fajardo (2022-03-14 08:23:54)

Offline

#12 2022-03-14 08:22:26

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,275

Re: [Solved] Custom systemd service disables after every kernel update

Raynman wrote:

The service is not going to be active after a reboot until sleep.target is activated by suspend. Inactive doesn't mean disabled.

Offline

#13 2022-03-14 10:05:33

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,687

Re: [Solved] Custom systemd service disables after every kernel update

It is seeming more to me that a service file is not the best way to resolve this issue because what I really need is simply to run:

echo PXSX > /proc/acpi/wakeup

on boot.
I'll see if I can make it work with a script inside /etc/profile.d.

Last edited by d_fajardo (2022-03-14 10:06:41)

Offline

#14 2022-03-14 11:25:31

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,275

Re: [Solved] Custom systemd service disables after every kernel update

I'm not sure why you think that's required, but to re-iterate: your current service will only be executed when/right before you send the system to sleep.
If you want to execute it unconditionally, you'd have to move it to eg. the multi-user.target

Offline

#15 2022-03-14 20:50:17

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,687

Re: [Solved] Custom systemd service disables after every kernel update

Great!! Thanks for explaining. Fixed.

Offline

#16 2022-03-14 20:51:28

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,275

Re: [Solved] Custom systemd service disables after every kernel update

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Edit: blast.

Last edited by seth (2022-03-14 20:51:48)

Offline

Board footer

Powered by FluxBB