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

spin down disks on debianslug

Expand Messages
  • spikes_nslu2
    hi all, I have managed to install the sg3-utils so i can use the sg_start to stop my drives. but i can t figure out a script to auto spin-down drives after x
    Message 1 of 11 , Dec 28, 2006
      hi all, I have managed to install the sg3-utils so i can use the
      sg_start to stop my drives.

      but i can't figure out a script to auto spin-down drives after x
      amount of time, like scsi-idle does on unslung etc.

      anyone willing or able to help?

      many thanks.

      Peter.
    • Laurent Gilson
      Hello, ... Are you really, really sure the hardware supports it ? Not all USB-enclosers use inteligent chips. And the stupid ones cannot do spindown, no matter
      Message 2 of 11 , Dec 28, 2006
        Hello,

        > hi all, I have managed to install the sg3-utils so i can use the
        > sg_start to stop my drives.

        Are you really, really sure the hardware supports it ? Not all
        USB-enclosers use inteligent chips. And the stupid ones cannot do
        spindown, no matter what you install on or do with your nslu2.

        cu
      • spikes_nslu2
        ... yes, if i run sg_start --stop /dev/sdb then my usb disk goes in to idle state, but then starts again fine whenever i need to access it. so i presume its
        Message 3 of 11 , Dec 28, 2006
          --- In nslu2-linux@yahoogroups.com, "Laurent Gilson" <pumpkin@...> wrote:
          >
          > Hello,
          >
          > > hi all, I have managed to install the sg3-utils so i can use the
          > > sg_start to stop my drives.
          >
          > Are you really, really sure the hardware supports it ? Not all
          > USB-enclosers use inteligent chips. And the stupid ones cannot do
          > spindown, no matter what you install on or do with your nslu2.
          >
          > cu
          >

          yes, if i run sg_start --stop /dev/sdb then my usb disk goes in to
          idle state, but then starts again fine whenever i need to access it.
          so i presume its just an auto script to get it to work as i need it to?

          peter
        • CN
          ... Peter, Not many boxes will do that. You are lucky! What o/s? slugos/be or unslung? Which manufacturer and part number for the usb box? Which disk drive?
          Message 4 of 11 , Dec 28, 2006
            On Thu, 28 Dec 2006 22:21:46 -0000, spikes_nslu2 wrote:

            > yes, if i run sg_start --stop /dev/sdb then my usb disk goes in to
            > idle state, but then starts again fine whenever i need to access it.
            > so i presume its just an auto script to get it to work as i need it to?
            >
            > peter

            Peter,

            Not many boxes will do that. You are lucky! What o/s? slugos/be or unslung?
            Which manufacturer and part number for the usb box? Which disk drive?

            Cordially, Chacko
          • spikes_nslu2
            ... it to? ... unslung? ... hi, i am using debian etch rc1 - downloaded off http://www.slug-firmware.net/ just the other day, using the installer. have no idea
            Message 5 of 11 , Dec 29, 2006
              --- In nslu2-linux@yahoogroups.com, "CN" <t4chacko@...> wrote:
              >
              > On Thu, 28 Dec 2006 22:21:46 -0000, spikes_nslu2 wrote:
              >
              > > yes, if i run sg_start --stop /dev/sdb then my usb disk goes in to
              > > idle state, but then starts again fine whenever i need to access it.
              > > so i presume its just an auto script to get it to work as i need
              it to?
              > >
              > > peter
              >
              > Peter,
              >
              > Not many boxes will do that. You are lucky! What o/s? slugos/be or
              unslung?
              > Which manufacturer and part number for the usb box? Which disk drive?
              >
              > Cordially, Chacko
              >


              hi, i am using debian etch rc1 - downloaded off
              http://www.slug-firmware.net/ just the other day, using the installer.
              have no idea on the manufacturer or part number of the box, just that
              it was bought from pcworld about 8months ago. the drive is a 120gb
              seagate.

              cheers
              Peter.
            • BxWen
              ... Here s what I do to my gentoo nslu2: 1. root on a 1GB flash drive, a westerndigital 120G mounted at /external 2. vixie-cron runs the script every 15
              Message 6 of 11 , Dec 29, 2006
                --- In nslu2-linux@yahoogroups.com, "spikes_nslu2" <peter.spikes@...>
                wrote:
                >
                > hi all, I have managed to install the sg3-utils so i can use the
                > sg_start to stop my drives.
                >
                > but i can't figure out a script to auto spin-down drives after x
                > amount of time, like scsi-idle does on unslung etc.
                >
                > anyone willing or able to help?
                >
                > many thanks.
                >
                > Peter.
                >
                Here's what I do to my gentoo nslu2:
                1. root on a 1GB flash drive, a westerndigital 120G mounted at /external
                2. vixie-cron runs the script every 15 minutes
                3. the script checks the mount point /external with fuser. If it is
                not used, power it down.

                #!/bin/sh
                #
                # Script to see whether argument is positive or negative
                #
                echo "***************`date`********" >> /var/log/power
                t=`fuser -c /external`
                if test "$t"
                then
                echo "in use" >> /var/log/power
                else
                echo "not in use, power down." >> /var/log/power
                echo "`sdparm -C stop /dev/sdb`" >> /var/log/power
                fi
                echo $t >> /var/log/power
                echo "" >> /var/log/power
              • Marcus Better
                ... Great. Please list your enclosure model and chipset on the wiki, if it isn t already listed: http://www.nslu2-linux.org/wiki/FAQ/SpinDownUSBHarddisks ...
                Message 7 of 11 , Dec 31, 2006
                  spikes_nslu2 wrote:
                  > hi all, I have managed to install the sg3-utils so i can use the
                  > sg_start to stop my drives.

                  Great. Please list your enclosure model and chipset on the wiki, if it isn't
                  already listed:
                  http://www.nslu2-linux.org/wiki/FAQ/SpinDownUSBHarddisks


                  > but i can't figure out a script to auto spin-down drives after x
                  > amount of time, like scsi-idle does on unslung etc.

                  There are a few scripts on that page. I also wrote my own version in C which
                  I intend to clean up and publish, but if someone is interested in
                  experimenting with it, I can post it.

                  (You should not use scsi-idle, the scripts do the job just fine.)

                  Marcus
                • CN
                  ... Marcus, I am interested. Please post it on a new Wiki page, and clearly show that as experimental. Thank you! Cordially, Chacko
                  Message 8 of 11 , Dec 31, 2006
                    On Sun, 31 Dec 2006 13:33:55 +0100, Marcus Better wrote:

                    > > but i can't figure out a script to auto spin-down drives after x
                    > > amount of time, like scsi-idle does on unslung etc.
                    >
                    > There are a few scripts on that page. I also wrote my own version in C which
                    > I intend to clean up and publish, but if someone is interested in
                    > experimenting with it, I can post it.
                    >
                    > (You should not use scsi-idle, the scripts do the job just fine.)
                    >
                    > Marcus

                    Marcus,
                    I am interested. Please post it on a new Wiki page, and clearly show that as
                    experimental. Thank you!

                    Cordially, Chacko
                  • dA
                    ... my LaCie 250GB works also with sg3-utils. Type: LaCie 250 GB Vendor: SEAGATE Model: ST3250823A Rev: 3.03 Best regards dA PS: I found the following
                    Message 9 of 11 , Jan 1, 2007
                      > >
                      > > Not many boxes will do that. You are lucky! What
                      > o/s? slugos/be or
                      > unslung?
                      > > Which manufacturer and part number for the usb
                      > box? Which disk drive?
                      > >

                      my LaCie 250GB works also with sg3-utils.

                      Type: LaCie 250 GB
                      Vendor: SEAGATE Model: ST3250823A Rev: 3.03

                      Best regards
                      dA

                      PS:

                      I found the following perl script on

                      http://nslu2-info.de/showpost.php?p=17397&postcount=32

                      http://nslu2-info.de/showpost.php?p=20987&postcount=42

                      #!/usr/bin/perl
                      use POSIX qw(strftime);

                      $timeout = 5 * 60;

                      # device to use
                      #$devicelist = "sda,sdb,sdc,sdd";
                      $devicelist = "sdb";


                      #################################


                      foreach $device (split(',', $devicelist)) {
                      $lastRCount{$device}=0;
                      $lastATime{$device}=0;
                      $sleepTime{$device}=0;
                      }

                      while (true) {
                      foreach $device (split(',', $devicelist)) {
                      open F, "< /sys/block/" . $device .
                      "/device/iorequest_cnt";
                      $requestCount{$device} = hex <F>;
                      close F;

                      $now=strftime "%s", localtime;
                      if ($requestCount{$device} !=
                      $lastRCount{$device}) {
                      $lastATime{$device} = $now;
                      }

                      # if we are after the timeout and there were new
                      # accesses after the last sleep time -> go to
                      sleep (again)
                      if ($now > $lastATime{$device} + $timeout &&
                      $lastATime{$device} > $sleepTime{$device}) {

                      $sleepTime{$device} = $now;
                      system "logger -i -t scsi_idle sending $device
                      to sleep...";
                      # system "/usr/bin/sg_start 0 -pc=3
                      /dev/$device";
                      system "/usr/bin/sg_start 0 /dev/$device";

                      # increase the request count by one for the
                      command we just sent
                      $requestCount{$device}++;
                      }

                      $lastRCount{$device}=$requestCount{$device};
                      }
                      sleep 60;
                      }



                      __________________________________________________
                      Do You Yahoo!?
                      Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
                      http://mail.yahoo.com
                    • spikes_nslu2
                      ... i have edited this slightly to use Sg_start and am also calling this using crontab, seems to be working ok at the moment, and will report any problems.
                      Message 10 of 11 , Jan 2, 2007
                        --- In nslu2-linux@yahoogroups.com, "BxWen" <bxwen@...> wrote:
                        >
                        > --- In nslu2-linux@yahoogroups.com, "spikes_nslu2" <peter.spikes@>
                        > wrote:
                        > >
                        > > hi all, I have managed to install the sg3-utils so i can use the
                        > > sg_start to stop my drives.
                        > >
                        > > but i can't figure out a script to auto spin-down drives after x
                        > > amount of time, like scsi-idle does on unslung etc.
                        > >
                        > > anyone willing or able to help?
                        > >
                        > > many thanks.
                        > >
                        > > Peter.
                        > >
                        > Here's what I do to my gentoo nslu2:
                        > 1. root on a 1GB flash drive, a westerndigital 120G mounted at /external
                        > 2. vixie-cron runs the script every 15 minutes
                        > 3. the script checks the mount point /external with fuser. If it is
                        > not used, power it down.
                        >
                        > #!/bin/sh
                        > #
                        > # Script to see whether argument is positive or negative
                        > #
                        > echo "***************`date`********" >> /var/log/power
                        > t=`fuser -c /external`
                        > if test "$t"
                        > then
                        > echo "in use" >> /var/log/power
                        > else
                        > echo "not in use, power down." >> /var/log/power
                        > echo "`sdparm -C stop /dev/sdb`" >> /var/log/power
                        > fi
                        > echo $t >> /var/log/power
                        > echo "" >> /var/log/power
                        >


                        i have edited this slightly to use Sg_start and am also calling this
                        using crontab, seems to be working ok at the moment, and will report
                        any problems.

                        will add it to the wiki later this evening.

                        #!/bin/sh
                        #
                        # Script to see if external storage is being used
                        # if its not being used, place drive in idle
                        #
                        # to change to your own config, change /hd to your mount point
                        #

                        echo "***************`date`********" >> /var/log/power
                        t=`fuser -c /hd`
                        if test "$t"
                        then
                        echo "in use" >> /var/log/power
                        else
                        echo "not in use, power down." >> /var/log/power
                        echo "`sg_start --stop /dev/sdb`" >> /var/log/power
                        fi
                        echo $t >> /var/log/power
                        echo "" >> /var/log/power


                        many thanks

                        Peter
                      • Marcus Better
                        ... No, it s too unfinished to put on the wiki, but you can download it here as a tarball or Debian package: http://www.better.se/debian/spindown-idle/ Run it
                        Message 11 of 11 , Jan 3, 2007
                          CN wrote:
                          >> I also wrote my own version in C which I intend to clean up and publish,

                          > I am interested. Please post it on a new Wiki page,

                          No, it's too unfinished to put on the wiki, but you can download it here as
                          a tarball or Debian package:

                          http://www.better.se/debian/spindown-idle/

                          Run it like this:

                          # spindown-idle /dev/sda 600

                          to spin down after 600 seconds inactivity. (Drives other than /dev/sda are
                          not supported yet!)

                          Marcus
                        Your message has been successfully submitted and would be delivered to recipients shortly.