What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

How to make sure my VPN server restarts after a power outage?

NOTICE:
The above solution ONLY applies if the NUC has been shut down by removing power, like on a mains power outage.
But if the NUC has been shut down from the running state by executing:
Code:
sudo shutdown now
then it will not start upon power removal/reconnect!
In this case it needs the power button push....

Question:
Is there a way to set it up such that it always starts up when power is applied from a non-powered state irrespective of how it was previously shut down?
Like how a RaspberryPi device works....
 
Yes, with those settings my nuc restarts after a power outage or WoL signal.

S4 and S5 are particular levels of sleep states.

Thank you!
I have now restarted the server and entered the BIOS settings where you indicated (it looks a little different but not much on my device).
After modifying the settings you suggested and done an F10 Save/Restart I waited for it to reach the final running state.
Then I pulled the power plug and reinserted it after a minute or so.
Lo-and-behold!
Now my NUC13 boots up and is operational again by itself!
:cool::D
So again: Thank you very much!
 
To clarify:
I have tested the "power outage while running" scenario and that works fine. This was the main concern so I am OK with this.

However, when I tested to first shut down from within Ubuntu and then cycle the power line nothing at all happened...
So do I have to dig into WOL config in order to be able to make it start also in these circumstances?
I have tried WOL unsuccessfully earlier, but there might be some missing settings to enable that?
 
To clarify:
I have tested the "power outage while running" scenario and that works fine. This was the main concern so I am OK with this.

However, when I tested to first shut down from within Ubuntu and then cycle the power line nothing at all happened...
So do I have to dig into WOL config in order to be able to make it start also in these circumstances?
I have tried WOL unsuccessfully earlier, but there might be some missing settings to enable that?
What options do you have for S4/S5 and how are they set? Those will control the WoL behaviour.

Please post a screenshot.
 
I attach a camera shot of the screen (don't know how to make a screenshot while in BIOS..)
I pasted together the images in the wrong sequence, the top is the second...

1747575691239.png


WOL from S4/S5 = Power On/Normal Boot
 
Last edited:
Well your settings look essentially the same as mine. I can WoL my nuc by using the option in the router (Network Tools - Wake on LAN).
 
It seems like the WOL arming that is needed after every boot (why?) is not done properly.
When I checked the state after the power outage simulation when it started as expected I noted that the WOL was not armed.
I have a script that is run in crontab @boot as follows:
Code:
# Enable Wake-On-LAN after each reboot:
@reboot /home/bosse/bin/enable_wol > /dev/null 2>&1

The enable_wol script looks like this:
Code:
#!/bin/bash
#This script enables Wake-On-LAN and should be run when the system starts
#Adjust script depending on interface naming, enp86s0 or eth0
NIC="enp86s0"
DEL=$1  #Flag to activate start delay

if [ "$DEL" == "1" ]; then
  sleep 60 #To let the system stabilize
fi

# Re-enable the wake-on-lan since it is volatile
sudo /usr/sbin/ethtool -s "$NIC" wol g
check_wol
exit
And the check_wol script looks like this:
Code:
#!/bin/bash
NIC="enp86s0" #Define correct interface name here
#Check state of wol
sudo /usr/sbin/ethtool enp86s0 | grep Wake | tail -n 1

But even so the check_wol I did showed that wol was disabled, so I ran the enable_wol command manually and then it got armed....
Tomorrow I have a few hours to experiment again so I will test it and look at how the wol state is after a power outage recovery.
Could it be such that I have to activate the minute delay after boot before the enable_wol script is run?
 
I don't know why you have to manually set WoL on your nuc. On my nuc running Ubuntu 24.04.2 LTS it's enabled by default.
Code:
root@nuc:~# ethtool eno1 | grep Wake
        Supports Wake-on: pumbg
        Wake-on: g

If you run “Advanced Network Configuration” on your machine and then select the ethernet adapter, what do you see next to "Wake on LAN"?
Untitled.png
 
The "Advanced Network Configuration" menu item brings up a dialog titled "Network Connections" where there are no items at all shown and there is no way to do anything.
Note:
This is an Ubuntu 24.04 SERVER onto which I have added a Mate desktop just to be able to view certain GUI things like the GParted application I use for disk management. But apart from that it is essentially headless and all work is done on the SSH command line.

The wol re-enabling is needed as I found out when setting it all up. It is built into the way the WOL is handled apparently.
It is simply not persistent across boots so on every start it has to be "armed" again.
So that is why I have it in my crontab @reboot, but so far it had not worked so when doing the above testing I have manually enabled it before pulling power etc.

Today I found what I believe is the reason for WOL was not working when I used my RPi4 device to effectuate the WOL:
That RPi4 (like many of my other RPi:s) is connected by WiFi, which to me should not make a difference, but it seems to...
So I connected an Ethernet cable to the RPi4 and I also modified the wake command as follows:
Code:
#Wake up ubuntusrvnuc if it has fallen asleep
MAC="48:21:0b:6b:95:68"
sudo etherwake -i eth0 "$MAC"
where the MAC variable is set to the MAC of the NUC-13 ethernet adapter and "i eth0" forces the command out on the Ethernet line.

This made all the difference, now the NUC-13 wakes up when WOL is sent!

So back to the enabling part, I have now added the delay argument in crontab so the enabling is done 60 s after boot and that seems to work also.

So the solution:
1) Make sure to send the WOL via Ethernet by specifying the correct interface in the command.
2) Add a delay on boot (60 s seems to work) before using the enable command for wol.

Now working!
 
Today I found what I believe is the reason for WOL was not working when I used my RPi4 device to effectuate the WOL:
That RPi4 (like many of my other RPi:s) is connected by WiFi, which to me should not make a difference, but it seems to...
Which is why I suggested (three times) that you test WoL using the option in the router's Network Tools.
 
Which is why I suggested (three times) that you test WoL using the option in the router's Network Tools.
I thought you were talking about making an SSH connection into the routers cmd line interface and doing stuff there...
Since the device I need to get running is the VPN server for my network I can not reach the router when VPN is down and I am at my other home. That is why I was looking for ways to make the server come to life automatically after power outages and also if it for some reason had shut down with power still available WOL sent automatically would start it again.
I believe that this is now the case.
 
FINALLY...
So now the "Resume after power loss" works on the new server and also on the old server.
And WOL is also working to restart both systems if it has been shut down without power loss.
In the latter case I have one cron task for each server running on a RaspberryPi5B device which triggers 6-7 times an hour and checks if the server is on line or not. If not it sends a WOL package out on the wired ethernet line. This brings up the server from the shut down state.
So now I may be less worried about moving to the summer home this season. :)
 
Last edited:

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top