Configure Wake on Lan when not available in the BIOS

· 2 min read
Configure Wake on Lan when not available in the BIOS
Photo by Bayarkhuu Battulga / Unsplash

The latest (cheap) mini pc with the N5105 CPU in it has low power consumption and enough grunt for running plex but does have a couple of issues. The BIOS options are minimal, essentially configuring secure boot and whether or not it can boot off the network and that's about it. This was a little disappointing as the one thing I really wanted was to be able to set the auto power on in case of an interruption to the power at home (I know, I should get a UPS).

Failing that, I would have set the Wake on LAN option as I could power it on remotley once the router had come back online, but that's not available in the BIOS either even though the network card supports it.

However, it can be set from the OS so I configured it as follows

First off, determine the name of the NIC at the OS

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 84:47:09:14:37:57 brd ff:ff:ff:ff:ff:ff
<rest of output suppressed>

From this we can see that the NIC is called enp2s0
Now run ethtool (as root) and see what the Wake on LAN capabilities are.

$ sudo ethtool enp2s0
[sudo] password for steve: 
Settings for enp2s0:
	Supported ports: [ TP	 MII ]
	Supported link modes:   10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/Full
	Supported pause frame use: Symmetric Receive-only
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/Full
	Advertised pause frame use: Symmetric Receive-only
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Link partner advertised link modes:  10baseT/Half 10baseT/Full
	                                     100baseT/Half 100baseT/Full
	                                     1000baseT/Full
	Link partner advertised pause frame use: No
	Link partner advertised auto-negotiation: Yes
	Link partner advertised FEC modes: Not reported
	Speed: 1000Mb/s
	Duplex: Full
	Auto-negotiation: on
	master-slave cfg: preferred slave
	master-slave status: slave
	Port: Twisted Pair
	PHYAD: 0
	Transceiver: external
	MDI-X: Unknown
	Supports Wake-on: pumbg
	Wake-on: d
	Link detected: yes

The important part here is the 'g' in the Wake-on support as that means that it can respond to a "Magic Packet"

Run the following command

sudo ethtool --change enp2s0 wol g

The check the settings and it should show

    Supports Wake-on: pumbg
	Wake-on: g

Test by shutting down ubuntu and then using your Wake on LAN tool to wake it up (I use the one built into the router) and hey presto, your PC wakes up.

This command is a one off setting though, if it powers down now, the wake on lan won't work again so to ensure that it's set at every boot I built a systemd sevice to set it to enabled at every boot

Find out where the ethtool command lives

steve@plex:~$ which ethtool
/usr/sbin/ethtool
steve@plex:~$

The create a systemd unit

vi /etc/systemd/system/wol.service

Add the following into the file

[Unit]
Description=Enable Wake On Lan

[Service]
Type=oneshot
ExecStart = /usr/sbin/ethtool --change enp2s0 wol g

[Install]
WantedBy=basic.target

Update systemd

sudo systemctl daemon-reload
sudo systemctl enable wol.service

Now whenever you power down the server you can use the Wake on Lan tool to wake it up again