One feature which I would like to see on Snake OS and it is not yet implemented is USB disk spindown. Few tips how to accomplish it can be found at http://www.nslu2-linux.org/wiki/FAQ/SpinDownUSBHarddisks. I tried sg_start from this howto and it just worked fine for my Transcend StoreJet 25.
The sg_start command is included in sg3_utils package. You can compile it with CNU SDK (you need to register to get SDK) in few steps:
- Download source tgz from http://sg.danny.cz/sg/sg3_utils.html#mozTocId479511
- Unpack
- Run configure script:
CC=arm-linux-gcc ./configure --host arm-linux - Compile:
make
If everything went well you should find sg_start in src/.libs. You will also need libsgutils2.so.2.0.0 which can be found in libs/.libs directory. To install sg_start to NAS we have to copy both files (sg_start and libsgutils2.so.2.0.0) into NAS disk and rename libsgutils2.so.2.0.0 to libsgutils2.so.2.
Now we can try to spin-down disk on NAS by command:
LD_LIBRARY_PATH=
If the disk rotation is turned off we have succeeded.
#!/bin/sh DISK_NAME="sda" SPINDOWN_TIMEOUT=30 SPINDOWN_COMMAND="/usb/sda1/spindown/sg_start --stop /dev/$DISK_NAME" SPINDOWN_LIB="/usb/sda1/spindown" SPINDOWN_POLL_INTERVAL="60" 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 echo "Spin down disk by $SPINDOWN_COMMAND" export LD_LIBRARY_PATH=$SPINDOWN_LIB $SPINDOWN_COMMAND fi #echo $mins_idle done
The script contains few variables which change it's behaviour (and you may need to change them):
- 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
The last thing is to do is to run script every time the NAS is started. I'm not sure how to do it right now by proper way. I use some workaround which alters inittab which I find wrong thus I'm not going to publish this solution. We may discuss it in comments.
You can get the script, library and sg_start binaries compiled for ARM here:
http://xhorak.fedorapeople.org/spindown.tar.gz
5 comments:
Hello,
Interesting. Congratulation.
Yesterday the Guru released the source for snake-os.
:))
Watch it. :)
Robert
Hi. Nice to see some addition to the SnakeOS. I wonder, since I'm thinking about buying a couple of the NS-K330 devices for both my own use and a clients, if you could upload a screenshot of the webgui. For my own use, a terminal is enough, however, clients tends to like gui:s :-) Thanks /Carl
You can find a few screenshots here:
http://forums.overclockers.com.au/showthread.php?t=865139
There is also official manual located at:
http://code.google.com/p/snake-os/downloads/list
Thanks a lot for the tip, I will soon receive this kind of NAS my self, so if you have more tips, I will enjoy reading them...
Hi, thanks for this great script and binary files!
To start the script at boot time you can add this line to /etc/init.d/cron
nohup /usb/bigdrive/spindown/spindown-disks >& /dev/null &
...then go to the admin/web interface and in system/config select "save config", this will make this change to survive the reboot.
Good Luck.
Post a Comment