Menu

#89 Honzik's: Spindown USB disks on Snake OS NAS

New
nobody
None
Medium
Defect
2013-03-11
2010-11-04
Anonymous
No

Originally created by: arq.nuno... (code.google.com)@gmail.com

Intro:

Honzizk has publish a "Spindown USB disks on Snake OS NAS" on February 14, 2010 using sg3-utils package (links below).
It works pretty well on my Iomega Select Desktop Hard Drive witch is really a USB2.0 Iomega casing for a Seagate 1TB disk.
All Seagate disks have no support for auto spindown in USB besides Seagate casing (didn't know that wen I bought it).

I'm not a programmer but the script seems well thought as it controls the idle time for executing the "sg_start --stop" (spindown) command sg3_utils is farly simple to be run without install (you can download the script and arm builds on a directory and run it).

As I said the script runs well as a script but wen I try to launch it at startup it just makes hard disk head to clutch and doesn't work.
The binarys and the chroot are located on a 4GB Kingston USB stick (out of the USB disk) and this happens even not using the chroot (has intended by the script)
I tried to run it from init.d and cron but i think that for anyone with programming skills the adaptation should be easy.

Has I read in the http://groups.google.com/group/dealextreme-nas-/web/feature-requests that early tests show no effect with "hd-idle" package this could be a good alternative as it actually works (also tried hd-idle with no results). Also installed Debian sg3-utils (0.55) from repository on the chroot and it works.

Can anybody make an adaptation for boot launching of the script or as a service?

USING:
snakeos-V1.2.0-20100621-from-original
Debian-Lenny 5.0.3 Llimi 2.7.1-4 para WLX652 y NS-K330 chroot on a 4GB Kingston USB stick
Iomega Select Desktop Hard Drive (USB2.0 Iomega casing for a Seagate 1TB disk)

LINKS:
Honzik's: Spindown USB disks on Snake OS NAS:
http://xhonzik.blogspot.com/2010/02/spindown-usb-disks-on-snake-os-nas.html
The  Linux sg3_utils package:
http://sg.danny.cz/sg/sg3_utils.html#mozTocId479511
You can get the script, library and sg_start binaries compiled for ARM here:
http://xhorak.fedorapeople.org/spindown.tar.gz
Pinguino7's wlx652 Forum with Debian-Lenny chroot cutomized for WLX652 y NS-K330 with MediaTomb, NFS, Webmin and other goodies (spanish):
http://wlx652.com/
Actual Debian-Lenny 5.0.3 Llimi 2.7.1-4 para WLX652 y NS-K330 chroot post:
http://wlx652.byethost24.com/index.php?topic=64.msg214#msg214

Actual Honzik's Spindown USB disks on Snake OS NAS script:

#!/bin/sh
DISK_NAME="sda"
SPINDOWN_TIMEOUT=1
SPINDOWN_COMMAND="/usb/lenny/TOOLS/spindown/sg_start --stop /dev/$DISK_NAME"
SPINDOWN_LIB="/usb/lenny/TOOLS/spindown"
SPINDOWN_POLL_INTERVAL="5"
initial_sectors_read=`cat /proc/diskstats |grep "$DISK_NAME "| sed -e "s/[ ]*/ /g"|cut -d\  -f7`
initial_sectors_write=`cat /proc/diskstats |grep "$DISK_NAME "| sed -e "s/[ ]*/ /g"|cut -d\  -f11`
mins_idle=0
while [ 1 ]; do
  sleep $SPINDOWN_POLL_INTERVAL
  sectors_read=`cat /proc/diskstats |grep "$DISK_NAME "| sed -e "s/[ ]\+/ /g"|cut -d\  -f7`
  sectors_write=`cat /proc/diskstats |grep "$DISK_NAME "| sed -e "s/[ ]\+/ /g"|cut -d\  -f11`
  if [ $initial_sectors_read -ne $sectors_read ]; then
      initial_sectors_read=$sectors_read
      mins_idle=0
  elif [ $initial_sectors_write -ne $sectors_write ]; then
      initial_sectors_write=$sectors_write
      mins_idle=0
  else
      mins_idle=$(( $mins_idle+1 ))
  fi
  if [ $mins_idle -eq $SPINDOWN_TIMEOUT ]; then
      date
      echo "Spin down disk by $SPINDOWN_COMMAND"
      export LD_LIBRARY_PATH=$SPINDOWN_LIB
      $SPINDOWN_COMMAND
  fi
  #echo $mins_idle
done

# DISK_NAME - device identifier, sda is for first connected disk
# SPINDOWN_TIMEOUT - time in minutes which disk spend in idle is going to be spin-down
# SPINDOWN_COMMAND - command which spin down disk (the path is important in this variable)
# SPINDOWN_LIB - directory which contains libsgutils2.so.2
# SPINDOWN_POLL_INTERVAL - polling interval to reset idle counter or spin-down disk in seconds

Related

Tickets: #21

Discussion

  • Anonymous

    Anonymous - 2011-04-24

    Originally posted by: tezcan.f... (code.google.com)@gmail.com

    Hello everybody!

    I managed to have my SNAKE OS V1.3.2 (20101130) box patched with the followings:
    1- USB port leds work.
    2- Frees up system memory every 20 mins.
    2- Checks attached USB hard disk(s)every 20 min(s) and spins them down if they are idling.

    All you need to do is:
    1- Download attached etc.tar.gz file to your USB disk.
    2- Change your directory to that file.
       cd /usb/<MOUNT_NAME_OF_YOUR_DISK>/
    3- tar xvf etc.tar.gz -C /

    Good luck!

     
  • Anonymous

    Anonymous - 2011-04-24

    Originally posted by: tezcan.f... (code.google.com)@gmail.com

    If everything goes well do not forget to save your config. So that changes remain permanent.

     
  • Anonymous

    Anonymous - 2011-04-24

    Originally posted by: vew...@googlemail.com

    Great job! It successfully spun down my hard drive. I haven't checked to see if the system memory is being freed up, but I'm sure it does.

     
  • Anonymous

    Anonymous - 2011-04-24

    Originally posted by: can-tez...@hotmail.com

    You can follow all the changes in your syslog.

     
  • Anonymous

    Anonymous - 2011-11-03

    Originally posted by: nic... (code.google.com)@gmail.com

    The USB ports light up great! This should be added to snake proper, as they didn't work at all without this.

    And the spindown of disks works too, but unfortunately spinUP does not work .... so the system just hangs when trying to use it after spindown, because the disks are effectively no longer there. Any pointers or suggestions for working out what the spinup problem is?

     
  • Anonymous

    Anonymous - 2011-11-04

    Originally posted by: can-tez...@hotmail.com

    When you use your HD, it automatically spins up. No need to do anything.

     
  • Anonymous

    Anonymous - 2011-11-13

    Originally posted by: betoz... (code.google.com)@gmail.com

    Hi, I liked this, more specificly about the turn leds up again.
    But a little concerned about spin down script, because my external HD already spind down itself. So, if I want use this script, without spind down, what I need to do?

     
  • Anonymous

    Anonymous - 2012-01-11

    Originally posted by: nagygo... (code.google.com)@gmail.com

    Nice job. I will see it in the next snakeOS firmware. Any chance to a full snake OS version with this?

     
  • Anonymous

    Anonymous - 2012-01-21

    Originally posted by: nagygo... (code.google.com)@gmail.com

    I have a problem! The mod spin-downs the had drives even I use them, since I connect a new usb hub. Is the usb hub cause problem? I see a film from the nas and it stop at 20 min. I need to reboot the snake to, see the hard drives again.

     
  • Anonymous

    Anonymous - 2012-07-21

    Originally posted by: rsam... (code.google.com)@gmail.com

    Hi, can it be that after it spins down, and back to normal, I loose permissions on my HDD? As after few hours my hard disk comes to read only, when I restart snake everything comes back to normal!

     
  • Anonymous

    Anonymous - 2013-03-09

    Originally posted by: thebo... (code.google.com)@cox.net

    I needed to make some changes to the spindown script to work on my system.  I am having trouble setting my version to be the default spindown script.  I can copy it into /etc/init.d/scripts and it runs, but then it is replaced with the original version after reboot.  I can not tell where this mystery original version comes from, but it overwrites my version after every reboot.

    How do I make my version the default spindown script?

     
  • Anonymous

    Anonymous - 2013-03-11

    Originally posted by: stefansc...@googlemail.com

    /etc/ sits in memory, so changes in there are lost after rebooting. You have to save the config to make them stick.

    Either run "/usr/share/snake/config save" or click the save config button in the web interface.

     

Log in to post a comment.

MongoDB Logo MongoDB