You are not logged in.

#1 2015-12-03 22:37:00

blackout23
Member
Registered: 2011-11-16
Posts: 781

[Solved] systemd unit file fails to exec command, works manually

Hello,

I'm using ethtool to set the Speed and Duplex Mode of a network interface to 10 Mbps and Full Duplex. Like this:

# ethtool -s eno1 speed 10 duplex full 

To do that automatically at boot I created an instatiated systemd unit file in /etc/systemd/system/ethtool@.service

[Unit]
Description=ethtool configuration for %i
After=network.target

[Service]
ExecStart=/usr/bin/ethtool -s %i speed 10 duplex full
Type=oneshot

[Install]
WantedBy=multi-user.target

I then enabled ethtool@eno1.service, but after reboot I see that it didn't execute properly when I check the status.

● ethtool@eno1.service - ethtool configuration for eno1
   Loaded: loaded (/etc/systemd/system/ethtool@.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Do 2015-12-03 23:28:04 CET; 17s ago
   Process: 359 ExecStart=/usr/bin/ethtool -s %i speed 10 duplex full (code=exited, status=0/SUCCESS)
   Main PID: 359 (code=exited, status=0/SUCCESS)

Dez 03 23:28:04 archlinux systemd[1]: Starting ethtool configuration for eno1...
Dez 03 23:28:04 archlinux ethtool[359]: Cannot get current device settings: No such device
Dez 03 23:28:04 archlinux ethtool[359]: not setting speed
Dez 03 23:28:04 archlinux ethtool[359]: not setting duplex
Dez 03 23:28:04 archlinux systemd[1]: Started ethtool configuration for eno1.

Why does ethtool complain, that the device doesn't exist? I tried starting the service later (multi-user.target) and tried to use %I instead of %i, but it doesn't work. When I execute the same command with the identifier replaced with eno1 it works without problems.

Last edited by blackout23 (2015-12-03 22:47:00)

Offline

#2 2015-12-03 22:39:29

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,679
Website

Re: [Solved] systemd unit file fails to exec command, works manually

Perhaps your unit file is called before the interface is re-named.

Try adding these lines to the [Unit] section:

Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

Offline

#3 2015-12-03 22:46:27

blackout23
Member
Registered: 2011-11-16
Posts: 781

Re: [Solved] systemd unit file fails to exec command, works manually

Head_on_a_Stick wrote:

Perhaps your unit file is called before the interface is re-named.

Try adding these lines to the [Unit] section:

Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

Well that worked! Thanks a lot!

Offline

Board footer

Powered by FluxBB