Loading ...
Sorry, an error occurred while loading the content.

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

Expand Messages
  • Thomas Reitmayr
    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
    Message 1 of 4 , Sep 23, 2009
    • 0 Attachment
      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
    Your message has been successfully submitted and would be delivered to recipients shortly.