So I wrote a systemd service file for Manjaro Linux to run two shell commands to set some kernel parameters at runtime to enable custom power saving actions.
BTW: This was a tip by a german computer magazine.
Originally I should place the shell commands in the
/etc/rc.local file but I want to make it with a systemd service.
rc.local is considered as deprecated and I want to learn something new.
Below you see my service file saved as
Because there are two
ExecStart directives I have chosen
[Unit] Description=Enable custom power saving actions provided by c't magazine # Quelle(n): c't 25/2016, S. 77 # c't 26/2016, S. 12 [Service] Type=oneshot # SATA Link Power Management aktivieren ExecStart=/usr/bin/sh -c 'for I in /sys/class/scsi_host/host?/link_power_management_policy; do echo min_power > $I; done' # Energieverwaltung für den Audiocodec aktivieren ExecStart=/usr/bin/sh -c 'echo 1 > /sys/module/snd_hda_intel/parameters/power_save' [Install] WantedBy=multi-user.target
I verified the service file with:
$ sudo systemd-analyze verify /etc/systemd/system/power-savings.service
Then I reloaded the daemon with:
$ sudo systemctl daemon-reload
I enabled it with:
$ sudo systemctl enable power-savings.service
Then I have run the service with:
$ sudo systemctl start power-savings.service
And it worked! The kernel parameters have been set.
But then, after rebooting my system the service seems not to have any effect. Although, the service status said success...
$ systemctl status power-savings.service Process: 412 ExecStart=/usr/bin/bash -c echo 1 > /sys/module/snd_hda_intel/parameters/power_save (code=exited, status=0/SUCCESS) Process: 404 ExecStart=/usr/bin/bash -c for I in /sys/class/scsi_host/host?/link_power_management_policy; do echo min_power > $I; done (code=exited, status=0/SUCCESS) Main PID: 412 (code=exited, status=0/SUCCESS)
But the kernel parameter were not set. So my service works during a user session, only. Unfortunately not during system boot up as it was intended to work.
Is there something I might have missed?
Do I need some of those
How am I able to debug what really happens with the