eniac111 / snake-os

Automatically exported from code.google.com/p/snake-os
2 stars 1 forks source link

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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by arq.nuno...@gmail.com on 4 Nov 2010 at 8:16

GoogleCodeExporter commented 9 years ago
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!

Original comment by tezcan.f...@gmail.com on 24 Apr 2011 at 8:51

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
If everything goes well do not forget to save your config. So that changes 
remain permanent.

Original comment by tezcan.f...@gmail.com on 24 Apr 2011 at 9:25

GoogleCodeExporter commented 9 years ago
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.

Original comment by vew...@googlemail.com on 24 Apr 2011 at 10:44

GoogleCodeExporter commented 9 years ago
You can follow all the changes in your syslog.

Original comment by can-tez...@hotmail.com on 24 Apr 2011 at 4:59

GoogleCodeExporter commented 9 years ago
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?

Original comment by nic...@gmail.com on 4 Nov 2011 at 3:19

GoogleCodeExporter commented 9 years ago
When you use your HD, it automatically spins up. No need to do anything.

Original comment by can-tez...@hotmail.com on 4 Nov 2011 at 7:12

GoogleCodeExporter commented 9 years ago
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?

Original comment by betoz...@gmail.com on 13 Nov 2011 at 11:19

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

Original comment by nagygo...@gmail.com on 11 Jan 2012 at 5:09

GoogleCodeExporter commented 9 years ago
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.

Original comment by nagygo...@gmail.com on 21 Jan 2012 at 7:03

GoogleCodeExporter commented 9 years ago
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!

Original comment by rsam...@gmail.com on 21 Jul 2012 at 1:39

GoogleCodeExporter commented 9 years ago
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?

Original comment by thebo...@cox.net on 10 Mar 2013 at 4:18

GoogleCodeExporter commented 9 years ago
/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.

Original comment by stefansc...@googlemail.com on 11 Mar 2013 at 3:43