LinuxMCE Forums

General => Users => Topic started by: jamo on June 22, 2012, 09:51:16 am

Title: MD wake on Lan not working
Post by: jamo on June 22, 2012, 09:51:16 am
After sorting out the shutdown on my other two MDs, I'm now trying to sort out the wake-on-lan for my HP compaq 6710b notebook. It has definitely worked before and definitely has the capability (hardware) but at the moment is not working.

What I've done so far-

* Tried the "power on"  from other orbiters and that doesn't work.
* Tried running /sbin/WakeMD.sh (or something similar) with --dev and --mac options, no dice.
* Tried using ethtool -g to check that wake-on-lan is configured when the MD is up and that looks correct.

Hmmm... will probably have to do a bit more digging to find how wake-on-lan works at a lower level and see if I can do it with a crescent wrench... then if that works I will try to figure out how/why that is not happening via the normal channels! Any suggsetions/troubleshooting tips welcome.

It is a bit of a pain not being able to start this puppy remotely.
Title: Re: MD wake on Lan not working
Post by: sambuca on June 22, 2012, 10:00:23 am
From memory, this is what is required for wake-on-lan to work:
* It must be enabled in the BIOS
* The network card must have been enabled (by ethtool)
* The system must have wake-up enabled
   - This is done in /proc/acpi/wakeup iirc, see if there is some entries there that match your network card, or a generic PCI entry. Some googling may be required to figure this one out (I don't recall the exact command at the moment)
* The driver must support wake-on-lan. What LMCE version are you using 810 or 1004? In 810 there was some network drivers that did not set the wake-up flag correctly, and wouldn't wake-on-lan. I think it is fixed in the kernel used in 1004 but still...

br,
sambuca
Title: Re: MD wake on Lan not working
Post by: jamo on June 22, 2012, 11:14:48 am
* It must be enabled in the BIOS [TICK]
* The network card must have been enabled (by ethtool) [TICK]
* The system must have wake-up enabled
   - This is done in /proc/acpi/wakeup iirc, see if there is some entries there that match your network card, or a generic PCI entry. Some googling may be required to figure this one out (I don't recall the exact command at the moment)
* The driver must support wake-on-lan. What LMCE version are you using 810 or 1004? In 810 there was some network drivers that did not set the wake-up flag correctly, and wouldn't wake-on-lan. I think it is fixed in the kernel used in 1004 but still...

Ta, that sounds right. I think the first two are OK. I will have a look at the third (/proc/acpi/wakeup iirc or whatever) and then the fact that the driver supports it...
I'm using 1004.
My one thought is that I have deleted and recreated this media director device out of webadmin and, obviously, the same MAC address would be used as the previous (now deleted) device so I thought there might have been some config somewhere that wasn't properly purged and the system is still trying to wake the "old" device or something...
Title: Re: MD wake on Lan not working
Post by: sambuca on June 22, 2012, 11:43:04 am
If you use /usr/pluto/bin/WakeMD.sh --mac xxxx then it should work anyway. You could also play around with /usr/sbin/etherwake which is used in WakeMD.sh to try and wake the MD.
Using WakeMD.sh --dev will look up the MAC address from the web-admin for the MD.

I haven't heard of any problems with the drivers in 1004, but one time have to be the first  ;)

br,
sambuca
Title: Re: MD wake on Lan not working
Post by: Marie.O on June 22, 2012, 11:47:29 am
And the MD must have been shutdown using LinuxMCE. I've seen cases where powering down the MD using other means causes the WOL to no longer work.
Title: Re: MD wake on Lan not working
Post by: DragonK on June 22, 2012, 12:07:29 pm
My wake on lan works.... Kinda....
What possy says makes sense.

If my core was swithced of due to long term powerfailure or maintenance,
 and I switch it back on again, then my Md's also boot. But when using the Power on button
In the orbiter it doesnt work.

Karel
Title: Re: MD wake on Lan not working
Post by: sambuca on June 22, 2012, 12:28:24 pm
One more thing that occurred to me. It seems that there are a slight difference between when you suspend a MD and when you shut it down. When shutting it down, it needs to set NETDOWN=no in /etc/default/halt to keep the network alive. Afaict, this is not required when doing suspend.

br,
sambuca
Title: Re: MD wake on Lan not working
Post by: JaseP on June 22, 2012, 02:53:15 pm
Has anyone tried this on an MD when the bios is set to wake after a power loss? Some bios-es support this function. I'd actually like to use the wake on LAN to conserve power at some point in the future.

Second, semi-related question... I have an APC UPS,... Does LinuxMCE have a routine for controlled shutdown when it catches a signal from an UPS?
Title: Re: MD wake on Lan not working
Post by: Marie.O on June 22, 2012, 03:07:40 pm
JaseP,

please create a new topic for the UPS question.
Title: Re: MD wake on Lan not working
Post by: jamo on June 26, 2012, 08:17:17 am
Just to add to this... I haven't got to the bottom of it yet but I have certainly tried many things - confirmed bios is enabled, confirmed via ethtool that WOL is setup for NIC. Where I am at the moment is possibly at a bug in ubuntu somewhere.... because here's what is possible-

If mains power is removed for a few seconds after shutdown and then re-connected, after *that* I can wake on lan the MD. I got that from a bug report somewhere... I think some people had some success removing networkmanager or some similar package but I made a mess of my MD trying some stuff and had to rebuild the image.

Will keep digging.
Title: Re: MD wake on Lan not working
Post by: _if_ on June 26, 2012, 11:37:40 am
JaseP, just install and configure apcupsd. It's working for me very well for long time now.
Title: Re: MD wake on Lan not working
Post by: JaseP on June 26, 2012, 02:56:06 pm
Thanks,... to both Jamo on on the Answ. to the power on Quest. and to _if_ re: the ups stuff...
Title: Re: MD wake on Lan not working
Post by: jamo on June 28, 2012, 09:53:03 am
Some more tinkering last night. The problem certainly seems related to how the machine is shutdown - it seems the NIC needs to be left in a state that allows WOL to work. This can be forcecd by physically removing power from the machine but obviously I don't want to do that every time... I may as well power it on manually.

The "halt"  (/etc/init.d/halt) script which is the last that is called in the shutdown sequence, as I understand it, has a setting at the beginning "NETDOWN=yes" which then, if "yes" passes a "-i" parameter the /sbin/halt executable to, presumably, shut down the network device.

Now there doesn't seem to be clarity as to whether the NIC must be shutdown (similar to
Code: [Select]
ifconfig eth0 down) or not for WOL to work but regardless of this, halt doesn't seem to do the right thing. I have tried "NETDOWN=no" as well as yes.

Some of the bugfixes/workarounds out there advise shutting down the NIC explicitly by creating a script that is executed right at the end of the shutdown process that does a
Code: [Select]
ifconfig eth0 down
immediately before powering off.

I tried hacking the halt script to include this code prior to the /sbin/halt command but the system then moaned about something being active. I presume this is to do with the NFS being mounted. Of course that is going to be a problem. It makes sense that you can't bring down a network card that is still being used for the filesystem....

Here's what I'm thinking at the moment. The problem is either due to
a) My NIC driver which is not allowing the NIC to be moved to a state that will accept WOL when the /sbin/halt command is executed with the "-i" parameter.
OR
b) Some other problem in the shutdown of this particular MD that is causing other things (NFS, NBD?) not to be stopped properly which is preventing the network being brought down properly.

I'll start with b) because there are definitely a few "faileds" being thrown on shoutdown of this MD. I'll compare to the working ones and see if I'm having a problem somewhere that doesn't exist on the others and try to fix. Otherwise I'll tinker wtih the NIC driver. Maybe.
Title: Re: MD wake on Lan not working
Post by: mkbrown69 on June 28, 2012, 06:18:40 pm
Jamo,

Generally, the interface has to be configured to support/Listen for the WOL packet.  This is generally done by

Code: [Select]
ethtool -s eth0 wol g
It could be done via an init script, like below, or in rc.local

Code: [Select]
sudo cat << EOF >> /etc/init.d/wake-on-lan
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: wake-on-lan
# Required-Start: \$network
# Required-Stop: \$local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Enable Wake-On-Lan
### END INIT INFO
#
. /lib/lsb/init-functions
 
do_start() {
    ethtool -s eth0 wol g
    exit
}
 
do_stop() {
    ethtool -s eth0 wol d
    exit
}
 
case "\$1" in
  start )
        do_start
        ;;
  restart|reload|force-reload )
        echo "Error: argument '\$1' not supported" >&2
        exit 3
        ;;
  stop )
        do_stop
        ;;
  * )
        echo "Usage: \$0 start|stop" >&2
        exit 3
        ;;
esac
EOF
sudo chmod 755 /etc/init.d/wake-on-lan

Code: [Select]
sudo update-rc.d wake-on-lan defaults

Now, if this solves your problem, then it should probably be added to the MD generation scripts.  If not, then there's something else at play, possibly power management.

HTH!

/Mike
Title: Re: MD wake on Lan not working
Post by: tschak909 on June 28, 2012, 06:35:54 pm
Morning,

If any of you actually BOTHERED to look at our code, you'll see there is code already in the boot scripts to do this.

Damn it guys, actually grab the code and look!

http://svn.linuxmce.org/svn/branches/LinuxMCE-1004/src/BootScripts

*Picard-style-hmm*

-Thom
Title: Re: MD wake on Lan not working
Post by: jamo on June 28, 2012, 07:20:58 pm
Mike

Thanks for the tips. I have been there, though and, I think, eliminated that as the problem as per my comments higher up in the thread regarding WOL being enabled both in BIOS and on the NIC via ethtool.

Thom

I know it chews up the devs' time when we seem to rehash things on the forum but it still (generally) helps in my opinion because the forum then becomes an awesome knowledgebase for people searching on keywords and having similar issues. That's why I post these things that I'm working through and I do try to do so without putting too many red herrings in and after I've done a fair bit of digging myself first.

Misguided, often, but good intentions at least... ;-)
Title: Re: MD wake on Lan not working
Post by: jamo on August 22, 2012, 08:48:38 am
Bump

Still struggling with this WOL issue. It really is a pain, see, because the MD is a laptop that I want to keep closed to keep out dust and muck and ultimately I actually want to hide it in a cabinet or something so getting to the power switch is a no-no.

Progress-

Since WOL works fine with my other MDs I'm certain it has something to do with the Broadcom BCM5787M NIC, the tg3 driver which controls it or a combination of these. Most posts on the web state that the NIC has to be properly shut down in the poweroff sequence and because this isn't happening, it can't react to WOL packets. That makes sense because when I remove mains power (after shutting down) and then plug it back in, WOl works! So it seems that on shutdown the NIC is left in some state that is not right and when power is removed, the NIC is forceably closed or dropped to the appropriate state.

So I tried a couple of things-
1. I tried upgrading the tg3 driver to the latest in case this was fixed. Doesn't seem to have made a difference although I must confirm that I *am* using the latest (just be sure I created the correct initramfs etc)
2. I tried purging network-manager which worked for some people. Didn't help me.
3. I tried adding a patch to the /etc/init.d/halt script that forcibly does an
Code: [Select]
ifconfig eth0 down but this just causes the system to hang on shutdown. I suspected this was because the root file system was still mounted on NFS and therefore the system wouldn't take the NIC down? The reason I suspected NFS still mounted was because there are some messages on shutdown like
Code: [Select]
/ still busy.
4. Based on 3 above I thought perhaps the shutdown scripts were incorrectly ordered (I came across a post somewhere that suggested this was possibly the case) so I modded that to make NBD shutdown come earlier (as per advice in the post) but that doesn't seem to have improved things.

Next steps:
1. Confirm I am actually using the new tg3 driver (perhaps replace tg3.ko whcih I think I'm using with a nonsense file, rebuild initramfs and confirm that the system doesn't work!!).
2. Use live ubuntu CDs for 8.10, 10.04 and 12.xx to confirm that the WOL problem exists for 10.04 only. Then, possibly force the NIC driver from 8.10 or 12.xx in? Sounds like a major hack but who knows? Is it possible to use an alternative, *generic* driver to TG3 that might work?
3. Stick an X-10 controller on the mains source so I can forcibly pull the plug and then re-power the machine each time I shut it down!!!
Title: Re: MD wake on Lan not working
Post by: sambuca on August 22, 2012, 11:49:24 am
3. The nic is shut down when you do "ifconfig eth0 down". The reason your system hung is that NFS is trying to communicate with the core, and it can't as the network is gone.

Do you suspend the MD or do you shut it down?

br,
sambuca
Title: Re: MD wake on Lan not working
Post by: jamo on August 22, 2012, 02:07:26 pm
3. The nic is shut down when you do "ifconfig eth0 down". The reason your system hung is that NFS is trying to communicate with the core, and it can't as the network is gone.
Makes sense... but how do I fix that? Should NFS not be shut down by this time if the halt script is the last to run in the shutdown sequence?
I'm thinking I need to get onto one of the working MDs and put a whole lot of verbose logging to screen and some log file into the scripts so I can see what's happening, then do the same on the problem child and compare the two. Of course the tricky part is that the logging is happening to an NFS share so as soon as NFS or ETH goes down, that's the end of it... but I guess the screen logging could still be visible.

Quote
Do you suspend the MD or do you shut it down?
At the moment I'm shutting it down. I've tinkered briefly with suspend, not had any more luck with suspend than shutdown but ultimately I'd like to get shutdown sorted. I think when I tried suspend it didn't seem to show much difference either in terms of startup time or in terms of WOL response. Which probably means it's not really suspending. But that's a battle for another day. If I get thoroughly whipped with this one, I'll rebuild the image and start from scratch with suspend as an option.
Title: Re: MD wake on Lan not working
Post by: jamo on November 26, 2012, 02:08:50 pm
Had another stab at this now that my system is arising, phoenix-like from the ashes of the lightning strike. I still have a veritable dance of laptops available to me thanks to my work colleagues damaging their equipment and I'm very loathe to abandon these otherwise excellent media directors - HP6410b notebooks.

Next steps:
1. Confirm I am actually using the new tg3 driver (perhaps replace tg3.ko whcih I think I'm using with a nonsense file, rebuild initramfs and confirm that the system doesn't work!!).
2. Use live ubuntu CDs for 8.10, 10.04 and 12.xx to confirm that the WOL problem exists for 10.04 only. Then, possibly force the NIC driver from 8.10 or 12.xx in? Sounds like a major hack but who knows? Is it possible to use an alternative, *generic* driver to TG3 that might work?
3. Stick an X-10 controller on the mains source so I can forcibly pull the plug and then re-power the machine each time I shut it down!!!

Regarding step 1-
Code: [Select]
modinfo tg3
reveals that the latest tg3 driver is being used but still no dice. So my assumption is that it is not just the driver but some combination of kernel/driver interaction that causes this.

Considering step 2-> apparently this is fixed in ubuntu 12.xx so would it be possible to upgrade my media director to 12 while the rest run 10.04?
Title: Re: MD wake on Lan not working
Post by: jamo on November 27, 2012, 10:11:10 am
Pretty much given up on this one.

Definitely got the latest tg3 driver working but it doesn't change anything.

Tore apart the rc.0 scripts last night and came to the following conclusions-

The problem with the Broadcom BC5787m NIC is, as discussed on many LTS forums, that it won't respond to WOL packets unless it is shut down properly (a-la ifdown eth0) or if the power is completely removed from the NIC for a few seconds.

Most who've had issues with this have managed to ensure the NIC is shut down cleanly during the power off sequence by either creating a shutdown script with the above command, or hacking one of the other scripts. However, because we have completely diskless clients, we can't shut down the NIC until the very last moment because NFS is still mounted (the root file system).

When I've tried this at any point short of the last command that is called (/sbin/halt) the system hangs, apparently due to NFS being busy.

The final command, /sbin/halt is part of the upstart package and accepts the parameter "-i" which is supposed to shutdown all network interfaces but, at least in this version, simply doesn't. It just accepts the parameter for compatability's sake. I've seen the code.

So.... blah. Run out of ideas. Going to mark these devices (the laptops) and NICs (BCM5787s) as working with caveats under 10.04.

If anyone has any other suggestions, please shoot.