Jump to content

omv

Members
  • Posts

    26
  • Joined

  • Last visited

Posts posted by omv

  1. 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
    

     

  2. 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.

  3. 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.

     

     

     

×
×
  • Create New...