wake on lan and sysconfig

Hi.

I have a asus MN4A77TD motherboard. I enabled “power on from S5 by PME” in the BIOS to activate WOL, but when I sent the magic packet it didn’t work. I thought WOL was a hardware feature… and it is, but it has to be activated by software, so, here it is what I have found.

I found here and here a way to enable WOL, it tells the network card to keep alive when you do a shutdown.

**andromeda:~ #** ethtool -s eth0 wol g

It worked. After running this command, I shut down the computer, sent it the magic packet and the computer booted. Then I shut it down again, sent the magic packet and… nothing, so I checked that it is not a permanent activation. I guess that including the command ethtool in halt.local should work although I find a better approach to add the configuration in sysconfig as it is said in the second link, but I searched for ifcfg in sysconfig in yast and i found nothing about ifcfg-eth0 (both links are old ones… maybe as old as my mobo)

Searching a bit more I find this post which says you can create the ifcfg-ethX file in /etc/sysconfig/network-scripts/ it will be something like

DEVICE=eth0
BOOTPROTO=static
IPADDR=your_IP
NETMASK=your_network_mask
HWADDR=NIC_MAC_address
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
IPV6INIT=no

As the link is from a centos forum, I don’t want to mess up something, so I continue searching for something recent and opensuse related, and there is something in the leap 15.2 network guide, chapter 13.6.2.5

I have found this file

**andromeda:~ #** cat /etc/sysconfig/network/ifcfg-eth0 
BOOTPROTO='none' 
IPADDR='0.0.0.0' 
NAME='RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller' 
NETWORK='' 
STARTMODE='auto' 
**andromeda:~ #**

I don’t think the system is using this file as my IP is static and it is 192.168.2.3 (using wicked).

In the same document in opensuse it says “wicked reads these files if you specify the compat: prefix. According to the openSUSE Leap default configuration in /etc/wicked/client.xml, wicked tries these files before the XML configuration files in /etc/wicked/ifconfig.”

In my system /etc/wicked/ifconfig is a empty directory.

and I’m stuck.

any help? thanks.

You are meddling with ifconfig files and also mention that you read that it is used by Wicked. That is correct, but do you use Wicked? I read nowhere in your post that you do.

Then I see you mentioning halt.local. But that is old stuff belonging to SysVinit. openSUSE uses systemd already for a long time. Also, when you need this to be set before a shutdown, why not set it at boot? Then it is there regardless of the way the system is stopped. And there are several examples on how to make a systemd unit to run at start here on the forums (I can copy down one here in a post if you need it).

See if this helps…
https://wiki.archlinux.org/index.php/Wake-on-LAN#systemd_service

1 Like

This could be one (all done as root of course):

Create a systemd-File with the name setwol.service in /etc/systemd/system/ with:

[Unit}
Description=Enable WOL before the system stops
After=network.target

[Service]
Type=forking
ExecStart=/usr/sbin/ethtool-s eth0 wol g

[Install]
WantedBy=multi-user.target

That is all.
To enable the systemd unit so that it starts at each boot:


systemctl enable setwol.service

And to run it at that moment in tine:
Start:


systemctl start setwol.service

You can always ask for the status of thus unit:


systemctl status setwol.service

Of course the name “setwol” as used above is chosen by me. You can go for a nicer name.
I have used the After=network.target to be sure that the setting is not lost during network initialisation. It might not be needed, but that should then be the subject of testing.

1 Like

Same publishing time ;).

But the Requires= is a nice addition.

Yes I do, I’m using static IP 192.168.2.3 using wicked

I created the file /etc/systemd/system/setwol.service as you said (copy-paste) and it returned an error, but no information about the error. Then I saw that all files in /etc/systemd/system/ are soft links to /usr/lib/systemd/system/ files, so I moved the file to [FONT=monospace] /usr/lib/systemd/system/ and create a symbolic link to it from /etc/systemd/system/ but It made no difference, then I tried to activate the service from yast, it failed but it gave me information

[/FONT]

● setwol.service - Enable WOL before the system stops    Loaded: loaded (/usr/lib/systemd/system/setwol.service; enabled; vendor preset: disabled)    Active: inactive (dead) 
Dec 14 11:34:29 andromeda systemd[1]: /usr/lib/systemd/system/setwol.service:1: Invalid section header '[Unit}' Dec 14 11:34:58 andromeda systemd[1]: /usr/lib/systemd/system/setwol.service:1: Invalid section header '[Unit}'

[FONT=monospace]
[/FONT]

yeah!, I did not check the status before :frowning: … just a typo error.
I corrected the typo and

**andromeda:~ #** systemctl enable setwol.service                                                  
Created symlink /etc/systemd/system/multi-user.target.wants/setwol.service → /usr/lib/systemd/system/setwol.service. 
**andromeda:~ #**

It creates a link, and it seems to work but It does not… it again complains about the typo but I have corrected it!!

**andromeda:~ #** cat /usr/lib/systemd/system/setwol.service 
[Unit] 
Description=Enable WOL before the system stops 
After=network.target 

[Service] 
Type=forking 
ExecStart=/usr/sbin/ethtool-s eth0 wol g 

[Install] 
WantedBy=multi-user.target 
**andromeda:~ #** systemctl stop setwol.service              
**andromeda:~ #** systemctl status setwol.service            
● setwol.service - Enable WOL before the system stops 
   Loaded: loaded (/usr/lib/systemd/system/setwol.service; enabled; vendor preset: disabled) 
   Active: inactive (dead) 

Dec 14 11:34:29 andromeda systemd[1]: **/usr/lib/systemd/system/setwol.service:1: Invalid section header '[Unit}'[/b]
Dec 14 11:34:58 andromeda systemd[1]: **/usr/lib/systemd/system/setwol.service:1: Invalid section header '[Unit}'[/b]
**andromeda:~ #**** systemctl start setwol.service             
Job for setwol.service failed because the control process exited with error code. 
See "systemctl  status setwol.service" and "journalctl  -xe" for details. 
**andromeda:~ #**

I can’t understand the error now.


# journalctl  -xe

Dec 14 11:45:39 andromeda systemd[1]: Starting Enable WOL before the system stops... 
-- Subject: Unit setwol.service has begun start-up 
-- Defined-By: systemd 
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel 
--  
-- Unit setwol.service has begun starting up. 
Dec 14 11:45:39 andromeda systemd[16524]: **setwol.service: Failed to execute command: No such file or directory**
Dec 14 11:45:39 andromeda systemd[16524]: **setwol.service: Failed at step EXEC spawning /usr/sbin/ethtool-s: No such file or directory**
-- Subject: Process /usr/sbin/ethtool-s could not be executed 
-- Defined-By: systemd 
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel 
--  
-- The process /usr/sbin/ethtool-s could not be executed and failed. 
--  
-- The error number returned by this process is 2. 
Dec 14 11:45:39 andromeda systemd[1]: **setwol.service: Control process exited, code=exited status=203**
Dec 14 11:45:39 andromeda systemd[1]: **Failed to start Enable WOL before the system stops.**
-- Subject: Unit setwol.service has failed 
-- Defined-By: systemd 
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel 
--  
-- Unit setwol.service has failed. 
--  
-- The result is failed. 
Dec 14 11:45:39 andromeda systemd[1]: **setwol.service: Unit entered failed state.**
Dec 14 11:45:39 andromeda systemd[1]: **setwol.service: Failed with result 'exit-code'.**

#


Another typo I haven’t noticed, the -s have no blank space. Once corrected it returned the same error, but I’m pretty sure it is all correct, this is the file content.

[Unit] 
Description=Enable WOL before the system stops 
After=network.target 

[Service] 
Type=forking 
ExecStart=/usr/sbin/ethtool -s eth0 wol g 

[Install] 
WantedBy=multi-user.target



It seems that service files are cached and I have to force it to be reloaded.

**andromeda:~ #** systemctl daemon-reload 
**andromeda:~ #** systemctl stop setwol.service              
**andromeda:~ #** systemctl start setwol.service 
**andromeda:~ #** systemctl status setwol.service 
● setwol.service - Enable WOL before the system stops 
   Loaded: loaded (/usr/lib/systemd/system/setwol.service; enabled; vendor preset: disabled) 
   Active: inactive (dead) since Mon 2020-12-14 11:51:57 CET; 5s ago 
  Process: 16692 ExecStart=/usr/sbin/ethtool -s eth0 wol g (code=exited, status=0/SUCCESS) 

Dec 14 11:51:57 andromeda systemd[1]: Starting Enable WOL before the system stops... 
Dec 14 11:51:57 andromeda systemd[1]: Started Enable WOL before the system stops. 
**andromeda:~ #**

I think the “Active: inactive (dead)” is because it is not really a daemon so it run and exited, but is OK, right?

best regards

**

That is wrong. You, as system manager should not change things in /usr/lib/systemd at all. That can be overwritten by next install (update) of the product.

So please undo that link, undo all you did in /usr/lib/systemd, to restore to a stable situation.

And let us then start to debuf the situation from where things belong.

so I must create the file in [FONT=monospace]/etc/systemd/system/ instead of [FONT=monospace][FONT=monospace] /usr/lib/systemd ?[/FONT][/FONT][/FONT]

Yes, that is the place. Please, please, undo all the things you did in /usr/lib/systemd/.

ok, done and working

**andromeda:~ #** systemctl daemon-reload                                       
**andromeda:~ #** systemctl status setwol.service 
● setwol.service - Enable WOL before the system stops 
   Loaded: loaded (/etc/systemd/system/setwol.service; enabled; vendor preset: disabled) 
   Active: inactive (dead) since Mon 2020-12-14 12:10:23 CET; 3h 14min ago 
    Tasks: 0 
   CGroup: /system.slice/setwol.service 

Dec 14 12:10:22 andromeda systemd[1]: Starting Enable WOL before the system stops... 
Dec 14 12:10:23 andromeda systemd[1]: Started Enable WOL before the system stops. 
**andromeda:~ #** systemctl stop setwol.service   
**andromeda:~ #** systemctl disable setwol.service 
Removed /etc/systemd/system/multi-user.target.wants/setwol.service. 
**andromeda:~ #** systemctl status setwol.service    
● setwol.service - Enable WOL before the system stops 
   Loaded: loaded (/etc/systemd/system/setwol.service; disabled; vendor preset: disabled) 
   Active: inactive (dead) 

Dec 14 12:10:22 andromeda systemd[1]: Starting Enable WOL before the system stops... 
Dec 14 12:10:23 andromeda systemd[1]: Started Enable WOL before the system stops. 
**andromeda:~ #** systemctl enable setwol.service    
Created symlink /etc/systemd/system/multi-user.target.wants/setwol.service → /etc/systemd/system/setwol.service. 
**andromeda:~ #** systemctl start setwol.service  
**andromeda:~ #** 

Many people post their problems as something “not working”. That expression does not provide much information.

The same is true when you say “working”.
I see that you can enable/disable/start/stop it, but the goal was to have a system that boots on WO, also after a reboot. Is that now doing as you want it?

Sorry. Working for me means taht it works like expected.
I halted the computer and sent the magic packet and the computer woke up, then I waited until grub apeared and I switched off the computer with the power button, then I sent the magic packet again and again it booted. Then I let opensuse boot completely, and then halted it, sent the magic packet again and it booted again. So it works.

best regards

Success! Nice you got it working. WOL is always a bit of a trick. Not all systems support it.

I’m using another possibility.

In the LAN module of YaST you can find a field ethtool-options in the hardware settings of your network card. Here you are able to set ‘-s eth0 wol g’.

Ethtool will set WOL with ifup. If someone changes the settings before shutdown, you can’t use WOL.

I never had problems with WOL since the update to openSUSE 15.2 on two computers. Two other computers, with new installations, don’t need any extra settings. No matter why.

Best regards

Hello and welcome here.

One of the reasons people prefer showing things in the CLI rather then in the GUI is that it is rather difficult to explain what to do and see in a GUI application. A good chance that one looses one’s audience somewhere halfway.

As I am unaware of a YaST “Lan Module”, I tried to find out what you mean.

I assume you mean YaST > System > Network Settings; then select the network card and click Edit below; then choose the Hardware tab where you indeed find Ethtool Options.

Does this not depend on the use of Wicked or Network Manager or Systemd-network? Setting it as shown in the thread is in any case independent of that.

BTW I tried to gather the information from this thread and others in an unreviewed HowTo: https://forums.opensuse.org/showthread.php/549615-Wake-on-LAN-a-working-case

Not available with NetworkManager service, only with Wicked.

I use Wicked, but maybe you can edit the sysconfig despite NetworkManager:

YAST > Sysconfig Editor > Hardware > Network > eth0 > ETHTOOL_OPTIONS variable: “-s eth0 wol g”.

(openSUSE 15.3)

Greetings

More: Wake-on-LAN - ArchWiki