your script helps a lot, I think!
Need to learn sh syntax again ;-) but i like it.
Some small questions:
Do you know what rmtab counterpart for SAMBA is?
Did I understand right, you don't evaluate the in-que-read/write operations?
why can you use hdparm? AFAIK, the slug has no IDE port, and hdparm does
not work via USB, as I read here:
<http://www.nslu2-linux.org/wiki/FAQ/SpinDownUSBHarddisks#method1>
with regards & respect,
Mai Kee
Thomas Reitmayr wrote:
> Hi Mai Kee,
> you can read /sys/block/<dev>/stat (with <dev> corresponding to your
> HDD, eg. sdb) and look for changes. After a certain timeout you could
> issue your scsi-stop command.
> Altough my disk on a TS-109 could spin down automatically, I use such a
> script to be able to take other aspects into account - the disk will
> never spin down as long as I have one of its NFS shares mounted from my
> PC.
>
> That's my script:
>
> =========================================
> #!/bin/sh
>
> #DEV=sdb
> DEV=`blkid -t LABEL=MEDIA | sed 's/[0-9].*//'`
> DEV=${DEV#/dev/}
> STATFILE=/sys/block/$DEV/stat
> RMTAB="/var/lib/nfs/rmtab"
> let 'CYCLES=10*60/5'
> LOGFILE=/var/log/spindown.log
> state=active
>
> rw=0
> count=0
> echo "" >> $LOGFILE
> date "+%D %T - start" >> $LOGFILE
> while true ; do
> rw_old=$rw
> read reads a2 a3 a4 writes rest < $STATFILE
> let "rw=$reads+$writes"
> if [ "$rw" != "$rw_old" -o -s "$RMTAB" ] ; then
> count=0
> state=active
> lastacc="`date '+%D %T - idle'`"
> else
> if [ "$state" = "active" ] ; then
> let "count=$count+1"
> fi
> fi
> if [ "$state" = "active" -a $count -gt $CYCLES ] ; then
> echo "$lastacc" >> $LOGFILE
> date "+%D %T - spindown" >> $LOGFILE
> hdparm -Y /dev/$DEV
> state=standby
> fi
> sleep 5
> done
> =========================================
>
> You will probably need to tweak it a bit, eg. set DEV=sdb or change the
> disk LABEL, remove the code watching $RMTAB, or maybe do not write a log
> file (especially if your /var/log directory is not located on a ram
> disk). And of course "hdparm -Y" should be your scsi-stop command.
> The script will wait for 10 minutes of inactivity, set via CYCLES.
>
> Hope that helps.
> -Thomas
>
>
> Am Dienstag, den 22.09.2009, 19:02 +0200 schrieb Mai Kee Reis:
>
>> Can anybody please give me a hint how to spin down my HDD if not used a while?
>> My system is a NSLU2 with SlugOS 5.3 LE.
>>
>> The following does work fine, if invoked manually:
>> /opt/sbin/scsi-stop /dev/sdb
>>
>> So I think about using cron - good idea?
>>
>> Or will this cause trouble to attached processes? (Samba,...)
>> I'm not shure, but I think I saw a solution with crontab + some
>> kind of disk statistics, but can't google or remember anymore
>>
>> (invoking '/opt/sbin/scsi-idle /dev/sdb 180' does not do the job
>> as it shall by documentation)
>>
>> Greetings,
>> Mai Kee
>>
>>
>>
>>
>>
>> ------------------------------------
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>
>
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/nslu2-linux/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/nslu2-linux/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:nslu2-linux-digest@yahoogroups.com
mailto:nslu2-linux-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
nslu2-linux-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
No comments:
Post a Comment