Hi Mai Kee,
you can read /sys/block/<
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/
RMTAB="/var/
let 'CYCLES=10*60/
LOGFILE=/var/
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+$
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+
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-
>
> 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-
> as it shall by documentation)
>
> Greetings,
> Mai Kee
>
>
>
>
>
> ------------
>
> Yahoo! Groups Links
>
>
>
>
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
No comments:
Post a Comment