Keeping the Homelab Alive

One of the challenges that comes from getting yourself an enterprise minicomputer is the configuration set by the selling company. For my case, it was the BIOS lock - a toggle that inhibited my ability to have continuous uptime.
For this specific series, I had the following options to reset this:
Unplug and plug back in the CMOS battery, effectively resetting the BIOS lock.
Removing the PCMOS plug, holding the reset option and placing it back in.
Flushing the BIOS and installing a new one.
With option 1 and 2 not working for my particular use case and option 3 being out of my reach at that said time, I chose a fourth option. The workaround that came to mind was using wake on LAN. I figured, even if I lost power and it came back up, I should be able to power up the computer using another device on the same network.
Considerations
What happens should I restart my homelab? Would it remember my configuration to wake up on LAN on command?
How would I connect to it within my home network?
Approach
Create a daemon to autostart wake on LAN for the homelab
I connected my setup to my router via ethernet as I would always be assured that that was on. Figuring the interface with which it connected to the home network was as simple as using ip
:
ip link
From this, I would then pick the connection with <BROADCAST,MULTICAST>
to check its support. In my case, eno1
.
sudo ethtool eno1
# output contained
Supports Wake-on: pumbg
Wake-on: g
Great, wake on LAN is supported (wake-on: g
) and it can support multiple triggers(Wake-on: pumbg
). Should it have been (Wake-on: d
) for not supported, I would have enabled it with:
sudo ethtool -s eno1 wol g
Because the NIC of the system will be reset to (d
- disabled) on each restart, I needed to enable this on reboot. I created an internal service for this as:
nano /etc/systemd/system/wol.service
[Unit]
Description=Enable Wake-on-LAN
After=network.target
[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s eno1 wol g
[Install]
WantedBy=multi-user.target
Then I recognize and enable it with:
sudo systemctl daemon-reload
sudo systemctl enable wol.service
systemct start wol.service
Pinging the homelab from other devices in the same home network:
Since the system is already on the home network with ethernet and always plugged in, I can call wake on lan using its MAC address. I would just need to install wake on LAN on my laptop or other device. On Arch:
yay wakeonlan
On my android devices, I chose to install a ready made solution. I was not going to start building again Wake On Lan
I then retrieved the MAC address using the same ip
command from earlier.
Now, waking my computer from a power outage should work as simple as:
wakeonlan <mac-address>
A step further
I took it a step further and updated my aliases. In this case, creating a bash script that would ping my home server when called and only stop after 30 minutes of failure or when it got its first successful response. For reference:
#!/bin/bash
# wake-on-lan-script
MAC_ADDRESS="mac-address"
HOSTNAME="homelab-hostname"
SERVER_IP="homelab-ip"
echo "Waking up $HOSTNAME ($MAC_ADDRESS)..."
wakeonlan "$MAC_ADDRESS"
sleep 45
echo "Checking if $HOSTNAME is up (will timeout after 30 minutes)..."
START_TIME=$(date +%s)
TIMEOUT=$((30 * 60)) # 30 minutes in seconds
while true; do
if ping -c 1 -W 1 "$SERVER_IP" &> /dev/null; then
echo "$HOSTNAME is now online."
break
fi
NOW=$(date +%s)
ELAPSED=$((NOW - START_TIME))
if [ "$ELAPSED" -ge "$TIMEOUT" ]; then
echo "Timeout reached. $HOSTNAME did not come online within 30 minutes."
break
fi
sleep 5
done
I would then update my ~/.zshrc
with my alias call. I just called it home
alias home="path-to-wake-on-lan-script"
That was pretty much it.
The Future
My current setup works as I expect. I do, however, foresee a scenario where I would like to wake the system when not connected to my home network. I could either use wireguard with a rasberry pi or setup an ESP32 that would always try to ping it when plugged in.
Subscribe to my newsletter
Read articles from Marvin Kweyu directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Marvin Kweyu
Marvin Kweyu
Lover of espressos. I code, read and stay exceptionally weird.