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


Recommended Posts

I have compiled s2ram (from the suspend-0.8 source).

 

Note, you will have to first install libx86 for it to run.

 

Both are in the attached zip file.

 

If you lose your video when you resume, or have trouble getting your machine to go into or wake up from s3 sleep, you may benefit from using  s2ram instead of writing the state directly to /sys/power/state.  s2ram is cleaner, and does some "preparation" of the system before entering s3 suspend.

 

suspend-utils.zip

Link to comment

Thanks bubbaQ. This script works well as I tried it fully last night. It monitors my MediaPC (via ping) and when my media pc goes to sleep (ie I go to sleep :D), my unRAID box goes to standby.

 

When my media pc is awoken, it wakes up the unRAID box via wakeonlan.

 

How to wake up your unRAID box from an Ubuntu pc

 

1. Install wakeonlan (one time only)

 

sudo apt-get install wakeonlan

 

2. create a script called 50wakeupserver.sh

 

#!/bin/bash

## --- Local nodes ----------------------- ##
## Modify this to put your own MAC 
## address below. The format is:
## "xx:xx:xx:xx:xx:xx", where "xx:xx..." is
## the MAC address of your unRAID server the 
## magic packet is going to be sent to. 

case $1 in
    thaw)
        echo "Bringing up Server..."
        wakeonlan xx:xx:xx:xx:xx:xx
        ;;
    resume)
        echo "Bringing up Server..."
        wakeonlan xx:xx:xx:xx:xx:xx
        ;;
    *)  echo ""
        ;;
esac

 

3. make script executable

 

chmod +x 50wakeupserver.sh

 

4. Place script in /etc/pm/sleep.d

 

 

Now when your Ubuntu PC is woken up it will automatically wake up your unRAID server :)

 

Link to comment

I have compiled s2ram (from the suspend-0.8 source).

 

Note, you will have to first install libx86 for it to run.

 

Both are in the attached zip file.

 

If you lose your video when you resume, or have trouble getting your machine to go into or wake up from s3 sleep, you may benefit from using  s2ram instead of writing the state directly to /sys/power/state.  s2ram is cleaner, and does some "preparation" of the system before entering s3 suspend.

 

 

So my unRaid box just will not WOL. I can set eth0 to wake on g. But every time it sleeps and I wake it via the power button, eth0 has been reset to wake on d. My guess is this is happening on its way to sleeping. Will this s2ram be of any use to me? Or since my NIC is always getting set to wake on d, am I just SOL?
Link to comment
  • 2 weeks later...

Salutations to all.... I am new to the forum and to unRAID...

 

I am currently able to put my unRAID 5.0beta2 test server to sleep and also wake it up. I will be introducing the boot script ASAP to enable some intelligence and power management. I am testing the Free Lic with only one drive (Maxtor 200GB) on an ASUS Crosshair board ( I am using this board for its quality ) with 4GB RAM. If all goes well, I will start putting in drives and will move to the Plus or Pro License.

 

Currently, my server is running 91Watts active and 86 with Spin Down... I have a CoolerMaster 700Watt PSU... The video card is a PCI Nvidia Vanta 16MB. The point is: Any ideas on how to bring down power consumption or is it that this board is very power hungry...?

 

Thanks to all and will keep posting my progress...   ;D

 

EDIT: Forgot to mention... The CPU is a AMD Athlon64 X2 5000 BE stock...

Link to comment
  • 2 weeks later...

I have compiled s2ram (from the suspend-0.8 source).

 

Note, you will have to first install libx86 for it to run.

 

Both are in the attached zip file.

 

If you lose your video when you resume, or have trouble getting your machine to go into or wake up from s3 sleep, you may benefit from using  s2ram instead of writing the state directly to /sys/power/state.  s2ram is cleaner, and does some "preparation" of the system before entering s3 suspend.

 

 

 

How do I install libx86?

 

Link to comment

Hi,

 

I've tried to use this script but it seems that each time all my drives are spun down, the system is preparing to go to sleep but then immediately spins up all my drives.

 

When i look in the system log i can find this :

 

Aug 30 19:38:08 tower kernel: r8169: eth0: link down

Aug 30 19:38:09 tower ifplugd(eth0)[1322]: Link beat lost.

Aug 30 19:38:10 tower kernel: r8169: eth0: link up

Aug 30 19:38:10 tower ifplugd(eth0)[1322]: Link beat detected.

 

Any ideas?

Link to comment

What other power savings settings do you have enabled in BIOS? Perhaps you have USB Resume enabled, which is almost always going to prevent the box from sleeping?

 

I have no other power saving settings enabled as far as i can see. However since i'm getting errors when using S3 i was thinking to change the script so that my unRAID shuts down (via powerdown-script) once all drives spin down and the htpc is down. Is this possible?

Link to comment

Check your NIC settings that only wakeup on magic packet WOL is enabled and not on ARP requests. ethtool should only tell you the "g" option and not "a", this would explain why it goes up again (after the next broadcast happens in your network).

 

Ethtool only tells me the g option is activated. My NIC doesn't even support a.

 

 

Link to comment
  • 2 weeks later...

Hi,

 

For some time now i use the s3.sh script from the wiki. I have no problems with this script. I want to disable the s3.sh script at certain hours. Chanders direct me to this thread. I tried the script from ReneV, but for some reason it is not working for me. The unRAID server never goes to sleep.

 

I also read something about the cache drive. You have to change something in the s3.sh script? At the moment i don't use a cache drive.

 

I will past my s3.sh file and my go file. Any help appreciated. 

 

 

s3.sh file:

 

#!/bin/bash
# constants
yes="yes"
no="no"


# [CONFIGURATION]

# before going to sleep
intrnlTimeoutTicks=30	# ticks after HDD spindown before checking for external activity
extrnlTimeoutTicks=1	# ticks of no external activity before sleep; only after spindown+internal countdown

# control of internal timeout
checkHDDs=$yes		# check if all HDDs are parked before counting down towards sleep
noCountdownHours=""	# only countdown towards sleep outside these hours
			# example: <noCountdownHours="07 08 19 20">
			# always countdown: <noCountdownHours="">

# control of external timeout 
checkTCP=$no		# check for TCP activity

pingIPs="" 		# do not sleep if <$pingsIPs> are pingable
			# example: <pingIPs="192.168.1.4 192.168.1.5">
			# no ping-check: <pingIPs="">

# after waking up from sleep
doDhcpRenewal=$no	# <$no> for servers w/static IP address
forceGb=$yes		# might not be needed; probably always safe

# [/CONFIGURATION]


# implementation stuff
ticklengthSecs=60		# probe hardware + count down every minute/60secs, aka a tick
noTCP='0.00'			# what constitutes absence of TCP activity
flash=/dev/`ls -l /dev/disk/by-label| grep UNRAID | cut -d"/" -f3 | cut -c 1-3` # automatic id of flash drive
check_hour() {
echo $(date +%H)
}
check_HDD_activity() {
if [ $checkHDDs = $yes ]
then
	# probe the flash drive at your peril
	HDDs=$((for d in $(ls /dev/[hs]d? | grep -v "$flash"); do hdparm -C $d | grep active ; done) | wc -l)
else
	HDDs=0
fi
echo $HDDs
}
check_TCP_activity() {
if [ "$checkTCP" = $yes ]
then 
	TCP=$(bwm-ng -o csv -c 1 -d 0 -T avg | grep eth0 | cut -d";" -f5)
else
	TCP="$noTCP"
fi
echo "$TCP"
}
check_IP_status() {
mp_online=$no  # initialize to "no" until we learn otherwise
        # ping each of the media servers to determine if online
        for i in "$pingIPs"
        do
        	# ping the media server; if it answers, it is online
            	out=`ping -q -c 1 $i 2>/dev/null`
            	rec_count=`echo "$out" | grep received | cut -d " " -f4`
            	if [ "$rec_count" -eq 1 ]
            	then
                	mp_online=$yes
                	# if one is online, we do not need to ping
                	# any others, break out of the "for" loop.
                	break;
            	fi
        done
        echo $mp_online
}
pre_sleep_activity() {
echo DONE
}
post_sleep_activity() {
# Force NIC to use gigabit networking
if [ "$forceGb" = $yes ]
then 
	ethtool -s eth0 speed 1000
fi

# Force a DHCP renewal (shouldn't be used for static-ip boxes)
if [ "$doDhcpRenewal" = $yes ]
then 
	/sbin/dhcpcd -n
fi

echo DONE
}


# main
intrnlCountdown=$intrnlTimeoutTicks
extrnlCountdown=$extrnlTimeoutTicks
while [ 1 ]
do
# do not countdown during certain hours
	hour=`check_hour`
hourMatch=$(echo "$noCountdownHours" | grep "$hour" | wc -l)
if [ $hourMatch -eq 0 ]
then
	# count number of HDDs that are not parked
	HDDact=`check_HDD_activity`
 	if [ "$HDDact" -eq 0 ]
 	then
		# tick-tock for time since last spindown
		if [ $intrnlCountdown -gt 0 ]
  		then
  			intrnlCountdown=$[$intrnlCountdown-1]
		fi
 	else
		# reset countdown, following HDD activity
  		intrnlCountdown=$intrnlTimeoutTicks
  			extrnlCountdown=$extrnlTimeoutTicks
 	fi

	if [ $intrnlCountdown -le 0 ]
 	then
		# check for persistent external activity
 		TCPact=`check_TCP_activity`
 		IPping=`check_IP_status`
 		if [ "$TCPact" = $noTCP -a "$IPping" = $no ]
		then
			if [ $extrnlCountdown -le 0 ]
 			then
	  		# Do pre-sleep activities
				pre_sleep_activity
	  			sleep 5
	  		
			# Go to sleep
	  			echo 3 > /proc/acpi/sleep

	  		# Do post-sleep activities
				post_sleep_activity
	  			sleep 5
	  			intrnlCountdown=$intrnlTimeoutTicks
	  			extrnlCountdown=$extrnlTimeoutTicks
			else
				# tick-tock for persistent external activity
				if [ $extrnlCountdown -gt 0 ]
		  		then
		  			extrnlCountdown=$[$extrnlCountdown-1]
				fi
			fi
		else
			# reset countdown, following external activity
			extrnlCountdown=$extrnlTimeoutTicks
		fi
 	fi
fi

 # Wait a tick
	sleep $ticklengthSecs
done

 

 

go file:

#!/bin/bash
# Start the Management Utility
/usr/local/sbin/emhttp &
installpkg /boot/packages/bwm-ng-0.6-i486-2bj.tgz
cd /boot/custom/bin
nohup ./s3.sh &

 

Link to comment

Hmm, If i excute s3.sh i'll get this output:

 

root@Tower:/boot/custom/bin# ./s3.sh
-bash: ./s3.sh: /bin/bash^M: bad interpreter: No such file or directory

 

When i check with vi there is ^M after every row. How can edit this file so i can remove this ^M. eh, i hate vi. Any other editor available on unRAID?

Link to comment

Hmm, If i excute s3.sh i'll get this output:

 

root@Tower:/boot/custom/bin# ./s3.sh
-bash: ./s3.sh: /bin/bash^M: bad interpreter: No such file or directory

 

When i check with vi there is ^M after every row. How can edit this file so i can remove this ^M. eh, i hate vi. Any other editor available on unRAID?

 

Open the file in Windows with a text editor that is linux friendly.  Notepad++ and EditPad Lite are two that are free and work well. Once you open the file there should be a menu option to "Convert to linux" or something along those lines.

Link to comment

fromdos </boot/custom/bin/s3.sh >/boot/custom/bin/s3_fixed.sh
mv /boot/custom/bin/s3_fixed.sh /boot/custom/bin/s3.sh

 

 

Is this a other way to get te correct line endings?

 

 

 

When i start s3.sh manually i'll get this error:

 

SG_IO: bad/missing ATA_16 sense data::  f0 00 05 00 00 00 00 0a 00 aa 55 40 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

 

any idea?

Link to comment

Ok i did found the error:

 

SG_IO: bad/missing ATA_16 sense data::  f0 00 05 00 00 00 00 0a 00 aa 55 40 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

 

it was a card reader. It was still connected to the motherboard. I disconnected the cardreader. So the error is gone.

 

 

For some reason the unRAID server won't go to sleep. When i check with:

 

ps -Al

 

4 S     0  1466     1  0  80   0 - 13489 inet_c ?        00:00:00 emhttp
1 S     0  1583     2  0  80   0 -     0 md_thr ?        00:00:00 mdrecoveryd
5 S     0  1584     2  0  80   0 -     0 md_thr ?        00:00:00 spinupd
5 S     0  1585     2  0  80   0 -     0 md_thr ?        00:00:00 spinupd
5 S     0  1587     2  0  80   0 -     0 md_thr ?        00:00:00 spinupd
5 S     0  1589     2  0  80   0 -     0 md_thr ?        00:00:00 spinupd
4 S     0  1648     1  0  80   0 -   572 wait   ?        00:00:00 s3.sh
0 S     0  1649     1  0  80   0 -   408 n_tty_ tty1     00:00:00 agetty
0 S     0  1650     1  0  80   0 -   409 n_tty_ tty2     00:00:00 agetty
0 S     0  1651     1  0  80   0 -   409 n_tty_ tty3     00:00:00 agetty
0 S     0  1652     1  0  80   0 -   408 n_tty_ tty4     00:00:00 agetty
0 S     0  1653     1  0  80   0 -   408 n_tty_ tty5     00:00:00 agetty

 

The script is running.

 

 

I also lower the intrnlTimeoutTicks=30 parameter.

 

intrnlTimeoutTicks=2	# ticks after HDD spindown before checking for external activity

 

 

attached HDD:

root@Tower:/# fdisk -l

Disk /dev/sda: 2000.3 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xfd37fe98

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1      243202  1953513560    b  W95 FAT32

Disk /dev/sdb: 2000.3 GB, 2000398934016 bytes
1 heads, 63 sectors/track, 62016336 cylinders
Units = cylinders of 63 * 512 = 32256 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               2    62016336  1953514552+  83  Linux
Partition 1 does not end on cylinder boundary.

Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
1 heads, 63 sectors/track, 31008336 cylinders
Units = cylinders of 63 * 512 = 32256 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               2    31008336   976762552+  83  Linux
Partition 1 does not end on cylinder boundary.

Disk /dev/sdd: 4022 MB, 4022337024 bytes
255 heads, 63 sectors/track, 489 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *           1         488     3919841    6  FAT16

Disk /dev/sde: 1000.2 GB, 1000204886016 bytes
1 heads, 63 sectors/track, 31008336 cylinders
Units = cylinders of 63 * 512 = 32256 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               2    31008336   976762552+  83  Linux
Partition 1 does not end on cylinder boundary.

Disk /dev/sdf: 1000.2 GB, 1000204886016 bytes
1 heads, 63 sectors/track, 31008336 cylinders
Units = cylinders of 63 * 512 = 32256 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               2    31008336   976762552+  83  Linux
Partition 1 does not end on cylinder boundary.

Disk /dev/sdg: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x7951ce34

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1   *           1        2611    20972826    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sdg2            2612      121602   955787112    7  HPFS/NTFS
Partition 2 does not end on cylinder boundary.

 

 

Anyone a clue whats going on?

Link to comment

Yes, it is working now!  ;D

 

Oeps i forgot something. I didn't assigned my parity drive yet, because i still had to move some data. So when i spin down all drive the parity drive stays active. You guess the unRAID server will never go to sleep. Yes i admit that was stupid  :-[

 

Positive thing i learn some new stuff today!  :)  

 

 

Yes. That will correct the line endings on an running unRAID system. It's what Limetech uses for their 'go' script. Have a look at /etc/rc.d/rc.local

 

Thanks BRiT.

Link to comment
  • 1 month later...

I am new at using UnRaid but I have a few suggestions...

 

On this part of the script:

 

# control of external timeout

checkTCP=$no # check for TCP activity

 

pingIPs="" # do not sleep if <$pingsIPs> are pingable

# example: <pingIPs="192.168.1.4 192.168.1.5">

# no ping-check: <pingIPs="">

 

I see that you are not checking for TCP activity. I do. This tells the UnRaid server to verify if any of your HT(appliances) is ON or NOT. If no appliance is ON then it would start a counter to shut off.

 

I you were to use this option, simply change the NO for YES and, under "pingIPs=" list the IP's of your appliances inside the quotes...

 

Good Luck...

Link to comment
  • 1 month later...

Is there a way to automate the "Go to S3 Sleep" button found in the unMenu plugin? What I would like to have happen is an automatic shutdown after a period of inactivity. I currently use a wireless remote to turn the server on and off, but would find it convenient to have an auto shutdown.

 

I have read this thread and found it useful. However, I am also running the AirVideo plugin and do not know how its startup and shutdown would be effected. Currently, using my remote for start up and shutdown has not presented any problems

 

Thanks

 

 

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.