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


Recommended Posts

I figured it out.  I was making it to complicated.  I just used the full path for the file in the echo command instead of trying to CD into each directory first.  Now everything is working fine.

 

Cliff

That would seem to indicate that the current directory is not part of the search path.  Therefore, even when "cd'ing" into the directory with the program, it was not found, since it was not in the search path.

 

You can probably fix that by adding two lines, somewhere above the lines for the add-ons:

PATH=$PATH:.

export PATH

Link to comment
  • 2 weeks later...

I was interested in this s3.sh script, see below:

 

#!/bin/bash

#http://lime-technology.com/wiki/index.php?title=Setup_Sleep_(S3)_and_Wake_on_Lan_(WOL)

drives="/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf dev/sdh"

timeout=5

count=5

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

    /bin/sync

    /boot/config/beep-down

    echo 3 > /proc/acpi/sleep

    # Do post-sleep activities

    ethtool -s eth0 speed 1000

    ethtool -s eth0 wol gp

    # Force a DHCP renewal (shouldn't be used for static-ip boxes)

    #/sbin/dhcpcd -n

    /boot/config/beep-up

    sleep 5

    count=$timeout

  fi

  # Wait a minute

  echo COUNT $count

  sleep 60

done

 

but when I try to run it, I get a "/boot/config/s3.sh: /bin/bash^M: bad interpreter: No such file or directory" error. The s3 file has full ugo+rwx access:

 

-rwxrwxrwx 1 root root  806 Mar  6 21:07 s3.sh*

 

I've tried to run it in the 'go' script and I get that message, if I evoke it in ./bin/bash /boot/config/s3.sh or if I run it like this ./boot/config/s3.sh. Any reason why it doesn't work? Thanks.

Link to comment

 

but when I try to run it, I get a "/boot/config/s3.sh: /bin/bash^M: bad interpreter: No such file or directory" error. The s3 file has full ugo+rwx access:

 

 

The ^M, indicates the file is saved in DOS format rather than Unix format.

Use an editor which allows you to save in Unix format, or use fromdos to convert to the Unix format.

Link to comment

Ok, I'll have to try that. What is better, using the s3.sh script or the the s2ram? I cannot determine what is best. My concern which one syncs the parity and data drives before suspending the system and which one is better for less power consumption? Also, is their a already compiled s2ram package for unraid? my aim is to have the server power on/off without any physical invention, use magic packet to power on and power off via script.Thanks.

Link to comment

My concern is syncing the disks and stopping the unraid server gracefully. I was recently trailing the "echo 3 > /proc/acpi/sleep" in a script to sleep the server and a magic packet wol wakes up my server, which works fine. I was able to power off my server using the "powerdown" command and use a wol magic packet to power it back on, but that feature has somehow stopped working. I would love to get that working again.

I worried that always using this "echo 3 > /proc/acpi/sleep" command to sleep the unit and the magic packet to wake it up would do harm to the disks/data/parity, It this correct? So your saying that the s2ram is far better for the concerns that I've raised? Can you suggest why I can't get the wol packet to power back on my server? I have S3 STR and WOL LAN enabled too, and verified that the "ethtool -s eth0 -g" is enabled, its baffling me that wol doesn't work no more. My NIC act/connect leds doesn't illuminate when it is off, but my switch detects it still have my servers NIC still connected. Thanks.

Link to comment

Ok, so now this is what I have in my s3.sh script:

 

#!/bin/bash

drives="/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg"

timeout=5

count=5

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

    /bin/sync

    /bin/config/beep-down

    echo 3 > /proc/acpi/sleep

    # Do post-sleep activities

    ethtool -s eth0 speed 1000

    ethtool -s eth0 wol gp

    /boot/config/been-up

    sleep 5

    count=$timeout

  fi

  # Wait a minute

  echo COUNT $count

  sleep 60

done

 

and my 'go' script below:

 

#!/bin/bash

# Start the Management Utility

/usr/local/sbin/emhttp &

sleep 30

for i in /dev/md*

do

    blockdev --setra 2048 $i

done

nohup awk -W re-interval -f listen.awk >/dev/null 2>&1 &

CTRLALTDEL=YES LOGSAVE=30 installpkg /boot/packages/powerdown-1.02-noarch-unRAID.tgz

sysctl -w kernel.poweroff_cmd="/sbin/powerdown"

#echo "powerdown" | at 23:59

ethtool -s eth0 wol g

/boot/config/s3.sh

 

Im assuming that the 'sleep 5' indicates that once all HDDs fall asleep, 5 minutes later the server sleeps? Also, the 'go' and s3.sh seem corrent for my requirements? Thanks.

Link to comment

"sleep 5" is simply a 5 second pause in the script at that point.  It has nothing to do with the server going to "sleep"

 

It has nothing to to with 5 minutes. The 5 minutes is "created" by looping 5 times in a loop with a 60 second pause in the script each time through the loop.

 

The basic logic is

initialize a timeout variable to 5  (timeout=5)

initialize a counter variable to 5  (count=5)

 

loop (forever)

  if none of the disk drives is active

     decrement the counter variable by 1.

  else one of more disk drives is spinning

     set the counter to the "timeout" value.

 

  if the counter has decremented to zero   (we've been through the loop 5 times, delaying 60 seconds each time, with all disks idle)

     pause for 5 seconds  (I've no idea why this is needed. probably is not needed at all)

     sync the disks

     invoke beep-down

     echo 3 >/proc/acpi/sleep

     At this point, the server goes to sleep and the script does not continue until it is awakened.

 

     time passes.....

 

     The sever is awakened

 

     Post sleep activities to set up ethernet speed, WOL

     invoke /boot/config/been-up       (should this be beep-up, instead of been-up?? )

     reset the counter to 5 once more.

     delay 5 seconds more  (again, not really needed)

 

  pause 60 seconds before looping and testing if all the drives are idle once more.

go back to the top of the loop.

Link to comment

Thanks for clearing up the logic behind the script. I'll have the been-up corrected to beep-up. I've been testing this new setup and it seems to work and the server is a lot faster to become ready than before as it just has to wake up and spin the disks, not do a full boot up, load up the image files from usb, etc. I'm still baffled why that wol was working from a powered off mode, but not anymore. Thanks for the tips, i like this new power on/off feature, but is their any suggestions on the wol if the server is off, not sleeping?  thanks again.

Link to comment

WOL will work from powered off mode only if you have powered off the server by software, i.e. issuing the poweroff command. If you have powered it off by any other means or have disconnected the power cable in between, the WOL magic packet would not power on your server.

Link to comment

I cannot put UNRAID to sleep using the script of ReneV. I would appreciate very much if somebody could help me please.

 

1. I have checked the S3 and WOL capability of the server using echo and WOL magic packet. The server goes to sleep and wakes up on WOL.

2. I have converted the name of the Renev's script to s3.sh and put it in the directory /boot/custom/

3. I did Chmod +x the s3.sh

4. I installed the bwm-ng  (/boot/packages/bwm-ng-0.6-i486-2bj.tgz)

5. I added the following to the go script (/boot/config/go)

    installpkg /boot/packages/bwm-ng-0.6-i486-2bj.tgz

    cd /boot/custom

    nohup ./s3.sh &

Nothing happens. And if I telnet and try to start the script manually, I get the following:

    nohup: ignoring input and appending output to `nohup.out'

    nohup: cannot run command `./s3.sh': No such file or directory

    [1]+  Exit 127                nohup ./s3.sh

 

What am I doing wrong?

 

 

 

 

Link to comment

    nohup: ignoring input and appending output to `nohup.out'

    nohup: cannot run command `./s3.sh': No such file or directory

    [1]+  Exit 127                nohup ./s3.sh

 

What am I doing wrong?

Type

ls -lq /boot/custom

and show us the output.

Link to comment

Why do you need to change directory, and then run the command? Can't you just run it with a fully qualified path?

nohup /boot/custom/s3.sh &

I tried that too before, I still get this:

root@MEDIACENTER:~# nohup /boot/custom/s3.sh &

[1] 1813

root@MEDIACENTER:~# nohup: ignoring input and appending output to `nohup.out'

nohup: cannot run command `/boot/custom/s3.sh': No such file or directory

 

[1]+  Exit 127                nohup /boot/custom/s3.sh

 

(I am running the UNRAID PRO version 4.5.3)

 

Link to comment

Sorry for re-posting. I sorted it out - the problem is solved. For some reason, I have edited the shell script using the text editor (for Os X), the script file was corrupted. I had to rewrite it with another application which could save it as a unix file. Then it started to function as it was meant to. Apologies for taking your time. Probably it could have worked at the first place if I executed it using "fromdos" command. I do not know. Nevertheless, the server goes to S3 and wakes-on-lan. Thank you for your time.

 

PS: For the novices like me, it would be very nice if one of the experts could kindly update the wiki and take into acccount all these useful modifications made after the original s3.sh script. The new changes to the final script should be addressed as well (like Joe's corrections and modifications like 1) "$pingIPs" => $pingIPs, 2) checkTCP=$yes (for default) and 3) move from cache driver before going to s3 => /usr/local/sbin/mover <-- new line to move files off of cache before the line # Go to sleep echo 3 > /proc/acpi/sleep).

Link to comment

Sorry for re-posting. I sorted it out - the problem is solved. For some reason, I have edited the shell script using the text editor (for Os X), the script file was corrupted. I had to rewrite it with another application which could save it as a unix file. Then it started to function as it was meant to. Apologies for taking your time. Probably it could have worked at the first place if I executed it using "fromdos" command. I do not know. Nevertheless, the server goes to S3 and wakes-on-lan. Thank you for your time.

 

PS: For the novices like me, it would be very nice if one of the experts could kindly update the wiki and take into acccount all these useful modifications made after the original s3.sh script. The new changes to the final script should be addressed as well (like Joe's corrections and modifications like 1) "$pingIPs" => $pingIPs, 2) checkTCP=$yes (for default) and 3) move from cache driver before going to s3 => /usr/local/sbin/mover <-- new line to move files off of cache before the line # Go to sleep echo 3 > /proc/acpi/sleep).

Perhaps you'll be willing to zip up a copy of your s3.sh script and attach it to this thread.  I can update the wiki.

 

Joe L.

Link to comment

I try to summarize here the steps for the beginners like me who would like to implement the sleep 3 state at their server including the very last modifications:

 

1. First check that your server is able to go to S3 and wake up via WOL according to this guideline:

http://lime-technology.com/wiki/index.php?title=Setup_Sleep_(S3)_and_Wake_on_Lan_(WOL) or you could do this via unMENU (http://lime-technology.com/forum/index.php?topic=5568.msg51814#msg51814) if you have already installed it.

 

2. Then download "bwm-ng-0.6-i486-2bj.tgz" package according to Joe's clear guidelines:

http://lime-technology.com/forum/index.php?topic=3657.msg41705#msg41705 or in a more convenient way using the unMENU add-on.

 

3. Then download the following script (s3.txt) by ReneV with the most recent modifications mentioned above (I have just added the changes mentioned in this thread after the script was uploaded - in addition for the sake of brevity I changed the name to s3.sh).

The modifications include:

- code correction ("$pingIPs" => $pingIPs)

- activated the TCP checking (default = no, here it is changed to yes => checkTCP=$yes)

- checks if the cache drive has data, moves that data to the data disks before going to sleep (added => /usr/local/sbin/mover)

If you want to configure the script, open it and change the IPs of your media players or client computers - I have added mine 192.168.0.10 and 192.168.0.100 here - if you don't want to add remove them from the appropriate line and leave it as <pingIPs="">. You don't need anything else.

 

4. After you have made your changes, save the attached s3.txt as s3.sh!

 

5. Upload the "s3.sh" script to your FLASH disk and save it e.g. /boot/custom/bin. (Create a directory at the root of your FLASH drive and call it custom/bin. So, the "custom" folder should be at the same level as your "bzimage" and "bzroot". Drop the s3.sh script within /custom/bin folder, so the final path should be "boot/custom/bin/s3.sh"). I have changed the location to /boot/custom/bin since it is the suggested path for user scripts and these scripts can be modified via unMENU!

 

6. REMEMBER to CHMOD your script! Go to the directory where your script is and type "chmod +x s3.sh" at the console.

 

7. Now, we need to INSTALL the bwm-ng package after reboot as well as to run the s3.sh script. For this, you need to get hold of your "go" file under /boot/config directory and add 3 lines to the very END of your "go" file like I did:

 

installpkg /boot/packages/bwm-ng-0.6-i486-2bj.tgz

cd /boot/custom/bin

nohup ./s3.sh &

 

The 1. line will install the bwm-ng package that you already have  (=> /boot/packages/)

The 2. line will change the directory to the folder where you have your script (=> /boot/custom/bin)

The 3. line will run the script at the background.

 

8. Now go to your server stop your array and reboot your server. Everything should be fine.

Hope that I did not miss anything :)

 

Added: Check also this if you don't want to do much hand work.

s3.txt

Link to comment

For the owners of MAC clients OS X, I attach here also an Applescript sample which will be able to WAKE your linux server by sending Magic packets. Open the text file attached with your "AppleScript Editor" REPLACE "YOURSERVERS_MAC_ADDRESS_HERE_INCLUDINGSEMICOLONS" with your server's MAC address, 17 characters including the semicolons (e.g 00:00:00:00:00:00) and save it as an application. Any time you run the script, your server will wake up :)

WOL_OSX.txt

Link to comment

The only way I power off my server is using the "poweroff" command. I don't power it off any other way. It present, i've set my server to sleep after the hard drives sleep. This works a treat for a wol magic packet, but about 2 month's ago, wol using the powerdown command stopped working. It's interesting it no longer works.I've done a full reboot, did a powerdown to power off the server, but wol no longer works.

 

 

WOL will work from powered off mode only if you have powered off the server by software, i.e. issuing the poweroff command. If you have powered it off by any other means or have disconnected the power cable in between, the WOL magic packet would not power on your server.

Link to comment

If anyone are interested using pm-utils to suspend your server so here are is link to latest version ->  ftp://distro.ibiblio.org/pub/linux/distributions/zenwalk/i486/snapshot/ap/pm-utils-1.2.6.1-i486-1.txz

 

Zenwalk is a derived from Slackware, just like unRAID is. We can get the pm-utils from the Slackware distribution:

ftp://slackware.osuosl.org/pub/slackware/slackware-current/slackware/ap/pm-utils-1.2.6.1-i486-1.txz

 

Link to comment

This seems interesting, so you just download the file, copy it into a location, evoke the install in the go script and replace the 'echo 3 >/proc/acpi/sleep' with this utility? What is the differences from using the s3.sh to this utility and how would you set it up to run once all HDD's go to sleep? Thanks.

 

If anyone are interested using pm-utils to suspend your server so here are is link to latest version ->  ftp://distro.ibiblio.org/pub/linux/distributions/zenwalk/i486/snapshot/ap/pm-utils-1.2.6.1-i486-1.txz

 

Zenwalk is a derived from Slackware, just like unRAID is. We can get the pm-utils from the Slackware distribution:

ftp://slackware.osuosl.org/pub/slackware/slackware-current/slackware/ap/pm-utils-1.2.6.1-i486-1.txz

 

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.