0

OS: Nobara Linux 41 (up to date)

I have scoured the forums for possible solutions to this issue, however I still cannot seem to make it work.

I have a user created service that I am attempting to run on startup, however it is not executing on boot. The service runs fine when ran manually.

This is the service:

[Unit]
Description=CPU Performance Mode

[Service]
Type=oneshot
ExecStart=bash -c 'cpupower -c all frequency-set -g performance'
Restart=on-failure

[Install]
WantedBy=default.target

The goal of this service is to set my CPU cores to performance mode with cpupower.

When running systemctl status cpuperformance.service (the name of the service), I get:

     Loaded: loaded (/etc/systemd/system/cpuperformance.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf, 50-keep-warm.conf
     Active: inactive (dead) since Sun 2025-03-09 22:38:28 CDT; 12min ago
 Invocation: 7c187bdfd07c49c48fd6e94ccc34a0e3
   Main PID: 1442 (code=exited, status=0/SUCCESS)
   Mem peak: 1.3M
        CPU: 6ms

Mar 09 22:38:28 HynixPC bash[1442]: Setting cpu: 16
Mar 09 22:38:28 HynixPC bash[1442]: Setting cpu: 17
Mar 09 22:38:28 HynixPC bash[1442]: Setting cpu: 18
Mar 09 22:38:28 HynixPC bash[1442]: Setting cpu: 19
Mar 09 22:38:28 HynixPC bash[1442]: Setting cpu: 20
Mar 09 22:38:28 HynixPC bash[1442]: Setting cpu: 21
Mar 09 22:38:28 HynixPC bash[1442]: Setting cpu: 22
Mar 09 22:38:28 HynixPC bash[1442]: Setting cpu: 23
Mar 09 22:38:28 HynixPC systemd[1]: cpuperformance.service: Deactivated successfully.
Mar 09 22:38:28 HynixPC systemd[1]: Finished cpuperformance.service - CPU Performance Mode.

This looks like it ran the service successfully on boot-up, however if I cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor, I get:

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave

This shows that the CPU cores are using the powersave governor and not the performance governor like they should be after boot-up with this service.

I have tested different "WantedBy" targets, including basic.target and multi-user.target. Both of these have the same issue. Everytime I make a change to the service, I run sudo systemctl disable cpuperformance.service -> sudo systemctl daemon-reload -> sudo systemctl enable cpuperformance.service.

The output of enabling the service is Created symlink '/etc/systemd/system/default.target.wants/cpuperformance.service' → '/etc/systemd/system/cpuperformance.service'. After this, the service still fails to start on boot.

I found one clue that may show why this is not working. Running systemctl --user list-dependencies default.target, I get the following output:

default.target
○ ├─drkonqi-coredump-cleanup.service
● ├─drkonqi-sentry-postman.path
● ├─unity-gtk-module.service
● └─basic.target
●   ├─systemd-tmpfiles-setup.service
●   ├─paths.target
●   ├─sockets.target
●   │ ├─dbus.socket
●   │ ├─drkonqi-coredump-launcher.socket
●   │ ├─pipewire-pulse.socket
●   │ └─pipewire.socket
●   └─timers.target
○     ├─drkonqi-coredump-cleanup.timer
○     ├─drkonqi-sentry-postman.timer
●     ├─grub-boot-success.timer
●     └─systemd-tmpfiles-clean.timer

This shows that my custom cpuperformance.service is not wanted by default.target, which I don't understand since my service specifically has that listed.

Anyone have any ideas on this? I have been racking my brain on this for hours. Any help is appreciated!

0

2 Answers 2

1

After trying multiple things to get this service to apply correctly on boot; including making a new service under user instead of system (sudo systemctl edit --full --force --user cpuperformance2.service) and setting that up the same, adding After= and Requires= to the service, and other smaller changes, I decided to approach this issue differently since nothing was working out for me.

Instead, I ended up using rc-local-generator (see man systemd-rc-local-generator). Long story short, you can put in your own bash script into a service that gets called once all the other Linux services have launched.

If you are from the future and having this same issue, I would highly recommend following the tutorial written by Vivek Gite to use rc-local-generator as well.

My /etc/rc.d/rc.local ended up looking like:

#!/bin/sh
cpupower -c all frequency-set -g performance
exit 0

Upon the next reboot and running cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor, I am correctly seeing all of my CPU cores in performance governor instead of powersaving governor.

I have read that using rc-local-generator is not good practice since each service should be unique and individual, however at this point this is the only thing that works for me.

2
  • Then it might be enough to add After=default.target to the [Unit] block of cpuperformance.service Commented Mar 10 at 19:32
  • Unfortunately that did not help (for whatever reason, logically it should). However, I was able to get the initial cpuperformance.service running on boot by adding '[Service] ExecStartPre=/bin/sleep 30'. A simple 30sec sleep was all that was needed. Commented Mar 10 at 21:57
0

There is a mix-up between system and user services:

systemctl --user list-dependencies default.target

checks the systemd user configuration but

/etc/systemd/system/cpuperformance.service

is a system service.

The service obviously runs. I guess the problem is that the settings are changed (by whatever) after the service runs. You can check this by adding a second ExecStart (after the first one)

ExecStart=bash -c 'cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/root/scaling_governor'

and checking the file content afterwards.

1
  • 1
    Thanks for the response. I see the problem with my systemctl command and removed the --user from it. Running it now, I can properly see the service as a dependency under default.target. I added the additional ExecStart line that you recommended and looked at the file after boot-up. It lists "performance" in the log, showing that you are right about another service (or something) overwriting my custom service. Now I just need to find what that thing is... Commented Mar 10 at 17:25

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.