2

I'm working on Ubuntu 18.04, and I need to full disable my Ethernet Cart Power Saving.

I don't need to change any other System Power Saving settings, but only the Ethernet Card one.

Also, it would be great to maintain this new setting also after any reboot.

maxwatt
  • 508

2 Answers2

4

After some researches I found this:

What:       /sys/devices/.../power/control
Date:       January 2009
Contact:    Rafael J. Wysocki <rjw@rjwysocki.net>
Description:
        The /sys/devices/.../power/control attribute allows the user
        space to control the run-time power management of the device.

        All devices have one of the following two values for the
        power/control file:

        + "auto\n" to allow the device to be power managed at run time;
        + "on\n" to prevent the device from being power managed;

        The default for all devices is "auto", which means that they may
        be subject to automatic power management, depending on their
        drivers.  Changing this attribute to "on" prevents the driver
        from power managing the device at run time.  Doing that while
        the device is suspended causes it to be woken up.

Source documentation from: The Kernel Documentation

So the final solution I found is the following one:

sudo echo "on" > /sys/class/net/"$(ls /sys/class/net/ | grep -E '^e')"/power/control

The "$(ls /sys/class/net/ | grep -E '^e')" block is used to find the first 'e' device (Ethernet Device Card).

UPDATE: At the end, I managed how to run this script every 5 seconds as root, just add the following script as /etc/cron.d/ethernet-control

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""

* * * * * root for i in {1..12}; do (echo 'on' > /sys/class/net/"$(ls /sys/class/net/ | grep -E '^e')"/power/control) 2>/dev/null; sleep 5; done;
maxwatt
  • 508
1

For Kubuntu 22.04.1 (KDE 5.24.7) [kernel 5.15.0-60], I had to "Define a special behavior" to never let the computer sleep.

System Settings > Power Management > Activity Power Settings

Define a special behavior

[check] Never shut down computer or let it go to sleep

ADDITIONALLY, NetworkManager would not fully recover the LAN connection IF it automatically detected a cable disconnect and reconnect.

SO (eventually), I found that bringing the NIC down and up via the CLI worked consistently.

THUS, in /etc/network/if-up.d, I created a file 000-cycle-enp2s0-down-up with the following content:

#!/bin/bash
NIC_NAME="enp2s0"

if [[ "$IFACE" != "$NIC_NAME" ]] then exit 0 fi

/usr/sbin/ip link set $IFACE down /usr/sbin/ip link set $IFACE up

THEN, I made the file executable:

sudo chmod +x 000-cycle-enp2s0-down-up

AS a result, I now have a reliable SSH and HTTPS connection.

NOTE: 'enp2s0' is the name of my NIC. You must determine the name of yours. I used the following code and recognized the associated ip address with the NIC name.

ip a|grep "inet "