I need to ensure one of the following is run when my Raspberry Pi 4 is rebooted.
/usr/sbin/ethtool --change eth0 advertise 0x008
/usr/sbin/ethtool –-change eth0 speed 100 duplex full autoneg off
I have four situations I wish the PI to handle.
1 - Connected with 4pairs direct to a ubiqity edgemaster POE port
2 - Connected with 4pairs direct to a apple airport extreme
3 - Connected with 2pairs via a ls-poe-b0525 POE spliter to a ubiqity edgemaster POE port
4 - Connected with 2pairs direct to a ubiqity edgemaster port
This should be trivial, but dealing with the current obstacle course of networking utilities made it difficult. The system is apparently using dhcpcd for most networking config, but dhcpcd only seems to cater for basic cases. It is confusing in that all the ifconfip, ip and NetworkManager systems are also in place.
So starting with a new-ish image
- reference 2023-02-21
- wifi configured as well but switched off
- updated and upgraded to the latest
- boots to CLI
After hours of messing around, I discovered that adding the following to the end of /etc/network/if-pre-up.d/ethtool
solved the problem.
sleep 10
/usr/sbin/ethtool --change eth0 advertise 0x008
Adding the same two lines to /etc/rc.local
also worked.
The key element in this solution is the sleep command. Without the sleep, ethtool appears to do its thing too soon and has no effect. I am not sure what is causing ethtool to fail without the sleeps. I suspect the half-wired cabling is causing something to retry and take longer to initialise. Even with sleeps I suspect your mileage may vary depending on boot media speed, remote hub, DHCP server response, etc. However, initially setting sleep to 60secs should cater for the worst case. Once working you can reduce the sleep time in steps till you are happy.