Looking for better ideas how how to sleep/suspend my unraid box


Recommended Posts

I noticed even with my hard drives all spun down, my box dissipates a good 30-40 watts of power.  Fortunately, I've finally got my unRaid box correctly going into S3 suspend mode and waking back up with a WOL magic packet.  Wooohoo!

 

However, I haven't figured out a good way to actually put it to sleep yet - currently I telnet in and do the "echo 3 >/proc/acpi/sleep", but thats somewhat cumbersome.

 

1> Hit a URL that makes the machine go to sleep.  Is it possible to have the built-in web server run scripts?

 

2> Have a cron job or background script that periodically sleeps the machine.  Unfortunately, I don't know how to detect whether the machine is idle.  Is the a way from the command line to detect if all disks are spun down?

 

3>  Other suggestions?

 

 

I did a bit of searching but couldn't find any posts that looked relevant.  Apologies in advance if this is actually a FAQ.

 

 

 

Link to comment

Figured this out on my own - hadn't realized hdparm had a spindown test command. So its a simple matter of a crontab calling something like this:

 

#!/bin/bash

hdparm -C /dev/hda /dev/hdb /dev/sda /dev/sdb | grep -q active

if [ $? -eq 1 ]

then echo 3 >/proc/acpi/sleep

fi

 

 

 

Link to comment

Great that it is working with s3 suspend mode..

 

Did you ever tell us what motherboard you are using?  (Others might want to know one that has proven to work with s3 mode)

 

Your script will work.  Drop a copy of it in the /etc/cron.hourly folder and your server will go to s3 suspend mode within an hour of the drives all going to sleep.

 

You can put your script on the flash drive and then put a line in the "config/go" script to copy it to /etc/cron.hourly folder every time you reboot.

 

Or, invoke it with your own entry to the crontab if you want it to be checked more frequently.

 

Joe L.   

Link to comment

I'm using a shuttle FN95 motherboard - SN25P box, which is a old socket 939 combo.  I suspect there's not many (any?) other who use this, but it does require getting the very latest bios to get sleep to work.  Previously it would sleep, but not wake up properly.

 

The script does work, but it has some deficiencies.  The worst is that there's a possibly of immediate sleep after the hard drives all spin down if cron happens to fire it off at that time.  I'm going to rework this to instead have the script do a while loop, check every minute, and do a countdown to prevent the immediate sleep/spindown.  Also need to figure out a more generic way of iterating the hard drives instead of hard coding it.  And probably put it hooks so it will auto execute scripts right before sleep and right after wakeup.

 

 

Magic-packet generation will probably be the biggest headache for most users.  My OSX boxes have a handy WOL widget, but its not obvious how you'd do this from a TiVo or other media box.

Link to comment

I'm using a shuttle FN95 motherboard - SN25P box, which is a old socket 939 combo.  I suspect there's not many (any?) other who use this, but it does require getting the very latest bios to get sleep to work.  Previously it would sleep, but not wake up properly.

 

The script does work, but it has some deficiencies.  The worst is that there's a possibly of immediate sleep after the hard drives all spin down if cron happens to fire it off at that time.  I'm going to rework this to instead have the script do a while loop, check every minute, and do a countdown to prevent the immediate sleep/spindown.  Also need to figure out a more generic way of iterating the hard drives instead of hard coding it.  And probably put it hooks so it will auto execute scripts right before sleep and right after wakeup.

 

 

Magic-packet generation will probably be the biggest headache for most users.  My OSX boxes have a handy WOL widget, but its not obvious how you'd do this from a TiVo or other media box.

Unless you spin down the drives, they will not spin down on their own unless they have been idle for whatever time-out you configured.  I don't see there being much of an issue with disks spinning down and the server shutting down un-unexpectedly when you are using it unless you press the spin-down button.

 

 

Link to comment

Here's an updated version -- this one you'd have to background from the go script rather than cron-launch.  It has a 15 minute (programmable) countdown from spindown to sleep.

 

While the old one wouldn't corrupt anything, I feel its control mechanism is pretty clutzy - you could get weird cases where upon wakeup it might immediately re-sleep if the drives didn't spin up.  Or you hit the spindown button on the gui and shortly after the whole thing shuts down.  Now the time intervals are tightly tied together and more predictable for the user:

 

EDIT:  Threw in a dchp lease-renewal - my router box seems to forget about the lease (expires) and it doesn't seem like I'm getting an immediate renewal upon wakeup if the lease expired.  This rectifies the situation

 

#!/bin/bash

drives="/dev/hda /dev/hdb /dev/sda /dev/sdb"
timeout=15


count=15
while [ 1 ]
do
  hdparm -C $drives | grep -q active
  if [ $? -eq 1 ]
  then
    count=$[$count-1]
  else
    count=$timeout
  fi
  if [ $count -le 0 ]
  then
    # Do pre-sleep activities
    sleep 5

    # Go to sleep
    echo 3 > /proc/acpi/sleep

    # Do post-sleep activities
    # Force a DHCP renewal (shouldn't be used for static-ip boxes)
    /sbin/dhcpcd -n
    sleep 5

    count=$timeout
  fi
  # Wait a minute
  echo COUNT $count
  sleep 60
done

 

Link to comment
  • 1 month later...

Hi all,

 

I'm having some trouble getting my motherboard to shutdown and keep the NIC alive.

 

I have a P5B-VM (not DO) motherboard with the latest non-Beta BIOS (901).

 

I have set the options in the BIOS to wake up on PME (PCI event) -- in fact, I have it set to wake up on everything except PS/2 keyboard.

 

I have set eth0 as follows:

 

# disable all wakeup

ethtool -s eth0 wol d

 

#enable wakeup

ethtool -s eth0 wol umbg

 

(disable then enable shouldn't be needed, but just in case)

 

I then shut down either with the web interface or to S3 standby with a  echo 3 > /proc/acpi/sleep and the machine powers down, but the NIC lights are both off, so it will not respond to a magic packet.

 

Does anyone have any ideas how I can get the NIC to stay alive after shutdown or standby?

 

Thanks for your help,

 

Neil.

Link to comment

Hi all,

unfortunately, I am not very good in programming or scripting - thus a question to you people:

Is there any possibility to create some sort of script in the windows client ("keepalive") that prevents S3 sleep whenever the htpc is running but still allows the unraid box to fall to S3 if all htpcs are switched off?

It sould also include the sending of the magic packet to wakre unraid box if htpc comes from S3 - via scheduler?

 

There is something similar for the windows home server (which I do not have/use) called "lightsOut".

 

As a result, Unraid machine would only be running, if a minimum of one htpc is running, otherwise S3.

 

Thanks, Guzzi

Link to comment

Hi all,

unfortunately, I am not very good in programming or scripting - thus a question to you people:

Is there any possibility to create some sort of script in the windows client ("keepalive") that prevents S3 sleep whenever the htpc is running but still allows the unraid box to fall to S3 if all htpcs are switched off?

It sould also include the sending of the magic packet to wakre unraid box if htpc comes from S3 - via scheduler?

 

There is something similar for the windows home server (which I do not have/use) called "lightsOut".

 

As a result, Unraid machine would only be running, if a minimum of one htpc is running, otherwise S3.

 

Thanks, Guzzi

Hi Neil,

did you find a solution for your problem? Asking, because I am facing the same problem - although enabled in the BIOS and setting driver to wake on magic packet, NIC link goes down thus not being able to wake the machine ....

regards, Guzzi

Link to comment

Hi Neil,

did you find a solution for your problem? Asking, because I am facing the same problem - although enabled in the BIOS and setting driver to wake on magic packet, NIC link goes down thus not being able to wake the machine ....

regards, Guzzi

Same here. The system goes to sleep, and I can see that the LAN light is still on for the NIC, but it just will not wake from a magic packet. Frustrating.
Link to comment
Does anyone have any ideas how I can get the NIC to stay alive after shutdown or standby?

 

In some cases, you have to use Windows to force the registers on the NIC.  Boot Windows, and then go to driver options for the NIC, and select all the options there.

 

Also go to power management in the NIC, and make sure that "allow this device to bring the computer out of standby" is enabled, and disable "allow the computer to turn off this device to save power." 

 

I know that should make a bit of difference, but some NIC drivers in Linux have some bugs when it comes to setting registers for things like WOL.... but it you do them first in Windows they will stick.

 

Also, go to the latest unRAID beta... the .29 kernel has a number of s3 suspend improvements.  My bench machine does not suspend with unRAID 4.4.2 but does splendidly with 4.5-Beta6.

Link to comment

Does anyone have any ideas how I can get the NIC to stay alive after shutdown or standby?

 

In some cases, you have to use Windows to force the registers on the NIC.  Boot Windows, and then go to driver options for the NIC, and select all the options there.

 

Also go to power management in the NIC, and make sure that "allow this device to bring the computer out of standby" is enabled, and disable "allow the computer to turn off this device to save power." 

 

I know that should make a bit of difference, but some NIC drivers in Linux have some bugs when it comes to setting registers for things like WOL.... but it you do them first in Windows they will stick.

 

Also, go to the latest unRAID beta... the .29 kernel has a number of s3 suspend improvements.  My bench machine does not suspend with unRAID 4.4.2 but does splendidly with 4.5-Beta6.

Great Tips. I'll try the new beta first, then see if the windows tricks do any good. With the new beta, does one still have to do all tweaks to turn it on and set the card?
Link to comment

Does anyone have any ideas how I can get the NIC to stay alive after shutdown or standby?

 

In some cases, you have to use Windows to force the registers on the NIC.  Boot Windows, and then go to driver options for the NIC, and select all the options there.

 

Also go to power management in the NIC, and make sure that "allow this device to bring the computer out of standby" is enabled, and disable "allow the computer to turn off this device to save power." 

 

I know that should make a bit of difference, but some NIC drivers in Linux have some bugs when it comes to setting registers for things like WOL.... but it you do them first in Windows they will stick.

 

Also, go to the latest unRAID beta... the .29 kernel has a number of s3 suspend improvements.  My bench machine does not suspend with unRAID 4.4.2 but does splendidly with 4.5-Beta6.

 

I'm on 4.5Beta6.

 

I have a P5B-VM motherboard. This should be a well documented board as it's close to the official board of late?

Does the official board require the Windows settings?

 

And does the NIC store these settings in flash or other non-volatile storage? I used to have this board waking up with WOL when it was in a Windows machine.

 

I'd rather not set up Windows again just for this, as I recently erased the hard drive with Windows that was in this machine, but I will if I have to.

Link to comment

I don't know what the reason is... I just know it has worked in some instances in the past.  My P5B-Deluxe was that way.

 

You always need to run ethtool to check the WOL setting.  Set it to "g" and that's all.  If you use the others, like any directed packet, it will wake up on it's own in a few seconds when any other system checks on it.

Link to comment

Does anyone have any ideas how I can get the NIC to stay alive after shutdown or standby?

 

In some cases, you have to use Windows to force the registers on the NIC.  Boot Windows, and then go to driver options for the NIC, and select all the options there.

 

Also go to power management in the NIC, and make sure that "allow this device to bring the computer out of standby" is enabled, and disable "allow the computer to turn off this device to save power." 

 

I know that should make a bit of difference, but some NIC drivers in Linux have some bugs when it comes to setting registers for things like WOL.... but it you do them first in Windows they will stick.

 

Also, go to the latest unRAID beta... the .29 kernel has a number of s3 suspend improvements.  My bench machine does not suspend with unRAID 4.4.2 but does splendidly with 4.5-Beta6.

Great Tips. I'll try the new beta first, then see if the windows tricks do any good. With the new beta, does one still have to do all tweaks to turn it on and set the card?

 

Hi BubbaQ,

I did some more Tests - funny, as you said, on exactly the same machine, it's working perfect under windows, but NOT under Linux/Unraid. Windows goes to standby (S3) and wakes up by MagicPacket. Unraid goes to standby (S3), but does NOT wake up.

I used the latest beta6 for the tests.

It seems there is some problems with the NIC driver for the realtek onboard chip - found somewhere on the web that there "might be issues" with WOL & r8169 and the recommendation to use r8168 driver instead - too hard for me, no idea how to do that...

 

I used ethtool to set the NIC, works fine:

Settings for eth0:

        Supported ports: [ TP MII ]

        Supported link modes:  10baseT/Half 10baseT/Full

                                100baseT/Half 100baseT/Full

                                1000baseT/Half 1000baseT/Full

        Supports auto-negotiation: Yes

        Advertised link modes:  10baseT/Half 10baseT/Full

                                100baseT/Half 100baseT/Full

                                1000baseT/Half 1000baseT/Full

        Advertised auto-negotiation: Yes

        Speed: 1000Mb/s

        Duplex: Full

        Port: MII

        PHYAD: 0

        Transceiver: internal

        Auto-negotiation: on

        Supports Wake-on: pumbg

        Wake-on: g

        Current message level: 0x00000033 (51)

        Link detected: yes

 

I also tried "modprobe r8169 enable_wol=1"

 

All didn't help - going to S3 works fine, but no wakeup via WOL.

 

Any further hints how to troubleshoot the problem?

 

Will try 2 other mainboards later if I find the time ...

 

Link to comment
...

 

I'd rather not set up Windows again just for this, as I recently erased the hard drive with Windows that was in this machine, but I will if I have to.

I was assuming one could use something like a Bart's PE or such to set the card from windows without having to actually install windows.
Link to comment
I did some more Tests - funny, as you said, on exactly the same machine, it's working perfect under windows, but NOT under Linux/Unraid. Windows goes to standby (S3) and wakes up by MagicPacket. Unraid goes to standby (S3), but does NOT wake up.

 

I have EXACTLY the same behavior on my test box -- a K8NE running unRAID.

Link to comment

I did some more Tests - funny, as you said, on exactly the same machine, it's working perfect under windows, but NOT under Linux/Unraid. Windows goes to standby (S3) and wakes up by MagicPacket. Unraid goes to standby (S3), but does NOT wake up.

 

I have EXACTLY the same behavior on my test box -- a K8NE running unRAID.

 

Did some more reading and found some interesting infos: h++p://www.vdr-wiki.de/wiki/index.php/WAKE_ON_LAN

Did not check this stuff yet. Further I have read, that with the latest kernel release there should be some improvements with regard to powermanagement - so with a little luck we might get improvement as soon as Tom integrates latest Kernel in the unraid distribution ...

Anyhow, I am still happy for help...

 

Link to comment

Did some more reading and found some interesting infos: h++p://www.vdr-wiki.de/wiki/index.php/WAKE_ON_LAN

My German is way too rusty to follow that page...care to summarizes the key bits?

 

Actually, it's just giving several hints and some descriptions, where known problems can be found and how to solve them. There is also a linux specific part.

I think you find the same info by searching the weg on other pages too.

The most important for me from the article I have already written above - tried those with my boards as good as I ca, but since I am not so erperienced in Linux, I don't know where exactely I find certain things in the unraid distribution. And e.g. changing the Realtek-driver is way too hard for me also...

I hope that we will get some improvement with next kernel release.

for the time now, I will order another mainboard - cause I tried WOL with my htpc and this worked fine even with unraid. Will order today the same board for my unraid server ....

Link to comment

I don't think I'm sending my system to sleep mode properly anymore. I send it the command "echo 3 > /proc/acpi/sleep" and it goes off. My NIC lights is off, but I can see that my ATI USB remote is getting power (it has a red LED that is lit up). When I press a key on the leyboard it does come on, but it looks like a full reboot. I see the BIOS post and then the normal boot to unRAID sequence. Am I sending the wrong command for sleep?

Link to comment

You can put a ping command in the script, and ping each HTPC to see if it is running.

 

 

Thanks for the hint; could you kindly send me an example for a script, that I could integrate in the script of omv to check ip in addition of drive spin? I am not good at all in scripting....

 

@all: I now bought a new motherboard, that properly supports wol - especially the wakeup via magicpacket. Did a testinstalltion and works fine so far, but before migrating my unraidbox I have one issue left: After the box went to S3 and waking up via magoc packet, I do not get the screen back; this means: the box is alive, I can telnet to it, but the physical monitor does not show the console anymore. Any hints how to solve this?

thanks and regards,

Guzzi

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.