[2248] in linux-scsi channel archive

home help back first fref pref prev next nref lref last post

Re: How to turn power off on an idle scsi drive.

daemon@ATHENA.MIT.EDU (Philippe Strauss)
Mon Aug 4 21:11:06 1997

Date: 	Tue, 5 Aug 1997 00:15:25 +0200
From: Philippe Strauss <philou@lili.urbanet.ch>
To: Robert Johannes <rjohanne@piper.hamline.edu>
Cc: linux-scsi@vger.rutgers.edu
In-Reply-To: <Pine.SOL.3.96.970804134659.4006B-100000@mutt>; from Robert Johannes on Mon, Aug 04, 1997 at 01:51:28PM -0500

On %M %N, Robert Johannes wrote
> Hello,
> I've a bt-948 card, and quantum fireball st and ibm ultra scsi harddrives;
> A lot of the time when I'm using the fireball, the ibm drive is idle;
> that's, I've no use for it.  It consumes power though, and contributes
> unnecessary heat.  How do I turn power off to a scsi drive if it is not in
> use?  Is there a special command for that in linux or even win95?  Would
> that affect the termination of the operating scsi drive?  If any body
> knows how to turn power off on an idle scsi drive, please help me.
> 
> Regards.
> 
> robert Johannes

Here it is.
Be sure to unmount all partition of that disk before spinning it down :)


/* start/stop SCSI unit
 * derived from scsiinfo by:
 *
 * Eric Youngdale - 11/1/93.  Version 1.0.
 *
 * Version 1.1: Ability to change parameters on cache page, support for
 *  X front end.
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2, or (at your option)
 *   any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <stdio.h>
#include <getopt.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/hdreg.h>

FILE *infile;
unsigned char buffer[10*1024];

int do_unit(int startstop)
{
  int status, i;
  unsigned char *cmd;
  unsigned char tmp;

  for (i=0; i<10*1024; i++)
  {
    buffer[i] = 0;
  }

  *( (int *)  buffer )          = 0;    /* length of input data */
  *( ((int *) buffer) + 1 )     = 0;    /* length of output buffer */

  cmd = (char *) ( ((int *) buffer) + 2 );

  cmd[0] = 0x1b;                        /* START/STOP UNIT */
  cmd[1] = 0x01;                        /* lun=0, immed=1 */
  cmd[2] = 0x00;                        /* (reserved) */
  cmd[3] = 0x00;                        /* (reserved) */
  cmd[4] = startstop;                   /* start or stop */
  cmd[5] = 0x00;                        /* control */

  status = ioctl( fileno(infile), 1 /* SCSI_IOCTL_SEND_COMMAND */, buffer );
  if(status) printf( "ioctl(SCSI_IOCTL_SEND_COMMAND) status\t= %d\n", status );

  return status;
}

void usage(char * errtext){
  int i;
  fprintf(stderr,"Error: %s\n", errtext);
  fprintf(stderr,"Usage: ./unit [start|stop] device\n");
  exit(0);
}

int main( int argc, char *argv[])
{
  int startstop;

  if (argc != 3)
      usage("number of parameters invalid");

  if (!strcmp(argv[1],"start"))
      startstop = 1;
  else
      if (!strcmp(argv[1],"stop"))
          startstop = 0;
      else
          usage("must be start or stop");

  infile = fopen( argv[2], "r" );
  if(!infile) {
    perror("unit(fopen)");
    exit(0);
  }

  do_unit(startstop);
  return 0;
}

-- 
Philippe Strauss <philou@lili.urbanet.ch>

Homepage & PGP key:	http://lili.urbanet.ch

"I know not with what weapons World War III will be fought, but World
 War IV will be fought with sticks and stones." -- Albert Einstein
--

home help back first fref pref prev next nref lref last post