Wednesday, September 23, 2009

Re: [nslu2-linux] scsi-stop and cron-job?

 

Hi Mai Kee,
it is the script I use on my QNAP TS-109, which has its disk(s) attached
via SATA, so for the NSLU2 you would just replace hdparm with scsi-stop.

I am not 100% sure what you mean with "in-que-read/write operations".
The parameters from /sys/block/$DEV/stat used in the script are the
number of completed reads and writes
(see /usr/src/linux/Documentation/iostats.txt). However you could
actually simplify this by just watching for _any_ change
in /sys/block/$DEV/stat, as shown in the following stripped down version
of the script (untested!):

#!/bin/sh

DEV=sdb
TIMEOUTMIN=10
TICKSEC=10
let "CYCLES=$TIMEOUTMIN*60/$TICKSEC"

state=active
stat=""
count=0
while true ; do
stat_old=$stat
stat=`cat /sys/block/$DEV/stat`
if [ "$stat" != "$stat_old" ] ; then
# disk activity detected
count=0
state=active
else
[ "$state" = "active" ] && let count++
fi
if [ "$state" = "active" -a $count -gt $CYCLES ] ; then
# spin down
/opt/sbin/scsi-stop /dev/$DEV
state=standby
fi
sleep $TICKSEC
done

Regarding samba, you could watch the client and/or "Locked files"
entries returned by the tool 'smbstatus' and only spin down the disk if
there are no such entries (if that's the behavior you desire). However I
am not that familiar with samba, so this might not cover all your use
cases...

Best regards,
-Thomas

Am Mittwoch, den 23.09.2009, 23:17 +0200 schrieb Mai Kee Reis:
> Hi Thomas,
>
> 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

__._,_.___
Recent Activity
Visit Your Group
Give Back

Yahoo! for Good

Get inspired

by a good cause.

Y! Toolbar

Get it Free!

easy 1-click access

to your groups.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___

No comments:

Post a Comment