Custom systemd service not being picked up at boot

I am new to Linux. I am using Fedora 37 with KDE. My rig is a MSI Delta 15 AMD.
I need to apply some control on my GPU. Created a 2 liner script and a service unit to go with it for automation at boot. Below script on service unit.
Both work like a charm after boot using a terminal but are never picked from a cold boot or a restart.

I am stuck. Any ideas is much appreciated.

sudo sh -c "echo manual > /sys/class/drm/card0/device/power_dpm_force_performance_level"
sudo sh -c "echo 2 > /sys/class/drm/card0/device/pp_power_profile_mode"
[Unit]
Description=Change GPU profile to powersave 
   
[Service]
Type=oneshot
ExecStart=/bin/bash /usr/bin/gpu
   
[Install]
WantedBy=multi-user.target

I don’t run Fedora but here is my first guess:

The files that you are echoing into are owned by root; hence the requirement of sudo which then requires a password to grant permission to write into the file. My guess is that the system doesn’t know to pause for the password input during the boot process. So, upon the boot, the command is denied access and because of that, fails.

One possible fix is make the file writable to all users with

sudo chmod 666 /path/to/your/file_name

and then run your command without the use of sudo.

I have never done this. I don’t know what the ramifications of this might be for the system. One great thing about linux is that if you have the sudo password, it will grant you permissions to break the system. But this might be relatively safe.

If it doesn’t work just change your permisssions back. I assume that they are currently “644” which is -rw-r--r--

Thanks for the reply. The script sets the GPU profile to PowerSave. Extremely safe. The MSI delta 15 suffers from bad thermals (fans ramping up for no reason). Fan curve is screwed up even in Windows.

I actually have a similar script to set a 0 for cpu turboboost. This script runs with no issue at boot.

The issue was indeed related to root. Did not think about that. Thank you for your help. Since root, I removed the ‘sudo sh -c’ and it seems to be working as expected.

Will leave the GPU profile at default for the moment. My goal is only to avoid the fan ramping up. There is not much difference from default profile to powersave. See screenshot.

Thanks again

1 Like