I need to ensure the following is run when my Raspberry Pi 4 is rebooted.
/sbin/ethtool --change eth0 advertise 0x008
Following various bits of advice, I added a last line to if-pre-up.d/ethtool
as follows:
root@raspberrypipurple:/home/pi# more /etc/network/if-pre-up.d/ethtool
#!/bin/sh
ETHTOOL=/sbin/ethtool
test -x $ETHTOOL || exit 0
[ "$IFACE" != "lo" ] || exit 0
# Gather together the mixed bag of settings applied with -s/--change
SETTINGS="\
${IF_ETHERNET_PORT:+ port $IF_ETHERNET_PORT}\
${IF_DRIVER_MESSAGE_LEVEL:+ msglvl $IF_DRIVER_MESSAGE_LEVEL}\
"
[ -z "$SETTINGS" ] || $ETHTOOL --change "$IFACE" $SETTINGS
# - force interface to negotiate 100MB and not 1000MB
# to allow POE etc to hog some of the Cat5 pairs
$ETHTOOL --change eth0 advertise 0x008
Running the script at the CLI worked and changed the "Advertised link modes" as reported by ethtool
root@raspberrypipurple:/home/pi# /sbin/ifup -a -v
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/ethtool
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
/bin/run-parts --exit-on-error --verbose /etc/network/if-up.d
run-parts: executing /etc/network/if-up.d/000resolvconf
run-parts: executing /etc/network/if-up.d/ethtool
run-parts: executing /etc/network/if-up.d/wpasupplicant
However, after the reboot my interface speed was wrong and the same if-pre-up.d/ethtool script appeared to have failed...
root@raspberrypipurple:/etc# systemctl status networking
● networking.service - Raise network interfaces
Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2023-05-11 13:05:25 BST; 9h ago
Docs: man:interfaces(5)
Process: 354 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
Main PID: 354 (code=exited, status=1/FAILURE)
CPU: 31ms
May 11 13:05:25 raspberrypipurple systemd[1]: Starting Raise network interfaces...
May 11 13:05:25 raspberrypipurple ifup[364]: netlink error: failed to retrieve link settings
May 11 13:05:25 raspberrypipurple ifup[364]: netlink error: Invalid argument
May 11 13:05:25 raspberrypipurple ifup[359]: run-parts: /etc/network/if-pre-up.d/ethtool exited with return code 1
May 11 13:05:25 raspberrypipurple ifup[354]: ifup: pre-up script failed
May 11 13:05:25 raspberrypipurple systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
May 11 13:05:25 raspberrypipurple systemd[1]: networking.service: Failed with result 'exit-code'.
May 11 13:05:25 raspberrypipurple systemd[1]: Failed to start Raise network interfaces.
Anybody able to point out where I am going wrong?
systemctl is-active 'networking'
which repliesinactive
. You might have more success if you enable networking, but I would just use a simpler service e.g.crontab
to run on startup.