Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Dec 1995 23:48:23 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-current@freebsd.org, sycheng@cis.ufl.edu
Subject:   Re: (fwd) [Wanted] Tools to disable SEGATE HD power saving mode
Message-ID:  <199512011248.XAA17281@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>    Is there any tool which I can use like Linux's "hdparm" to disable
>  the power saving feature of SEGATE hard drive ?

No but, cron activity might be enough to keep the drive awake, or you
could try something like:

	#!/bin/sh
	while :; do sleep 60; echo -n 1; done >/var/run/nodoz

Some Linuxer's used the program in the enclosed news to do the reverse
before hdparm was in common use.

Bruce

Article 31724 of comp.os.linux.misc:
Path: godzilla.zeta.org.au!warrane.connect.com.au!yarrina.connect.com.au!harbinger.cc.monash.edu.au!msunews!agate!ames!newsfeed.gsfc.nasa.gov!beowulf.gsfc.nasa.gov!not-for-mail
From: becker@cesdis.gsfc.nasa.gov (Donald Becker)
Newsgroups: comp.os.linux.misc,comp.os.linux.help,comp.os.linux.admin
Subject: Re: Green-PC disk doesn't powerdown with Linux: why?
Date: 24 Dec 1994 12:44:30 -0500
Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
Lines: 121
Message-ID: <3dhmlu$fqn@beowulf.gsfc.nasa.gov>
References: <ARNHOLT.94Dec11112806@miata.mayo.edu>
NNTP-Posting-Host: beowulf.gsfc.nasa.gov
Xref: godzilla.zeta.org.au comp.os.linux.misc:31724 comp.os.linux.help:71299 comp.os.linux.admin:20667

In article <ARNHOLT.94Dec11112806@miata.mayo.edu>,
Jeff Arnholt <arnholt@autobahn.mayo.edu> wrote:
>I purchased a green motherboard and processor with the ambition of both
>reducing my electric bills and being environmentally conscious.  Under
>DOS, the hard drive spins down after 30 minutes of non-use (having
>set the BIOS to do this).  Linux kept the drive spinning all night.
>Other than an aberrant 'cron', what could be causing this activity?

There has been some misinformation in answer to this thread.

o The mechanism to spin down the disk when idle resides in the disk drive
itself.  Most modern (post-1991) IDE drives support this feature.  Unlike
most other "Green" features which require runtime OS support or additional
motherboard chipset hardware, the BIOS merely sends the StandByTimer command
to the drive.  When the drive hasn't been accessed in 5*n seconds it
spins itself down.

o I've been using a trivial user-level program to do the same thing for two
years.  Mark Lord has an improved version included with his IDE package.

o The dirty pages in the buffer cache of a traditional UNIX are flushed to
disk every 30 seconds by the 'update' program doing a 'sync()' function
call.  Linux 1.0 followed this model, but Linux 1.1.* uses the modern
'bdflush' method of continuously dribbling dirty pages to disk.  This
shrinks the time window when file data may be lost if the machine is shut
off and avoids losing interactive response every 30 seconds when doing large
writes.

o *Never* kill the update/bdflush process.  Instead remove the source of the
writes.  Typical hidden writes are:
	- 'cron' in Slackware is configured to write a file in /tmp
	  every minute.  You should disable 'cron' completely unless you are
	  using it.
	- Emacs auto-saves modified buffers.  Check the variables auto-save-*.
	- Some kernel/drive combinations generate a warning message about
	  the interrupt when the drive spins down.  If you log that message
	  with syslog, the disk immediately spins back up :^<.

I'm typing this in bed with a laptop that spins down the disk down soon
after I get my usual set of program started.

/* diskdown.c: Shut down a IDE disk if there is no activity.

   Written by Donald Becker (becker@cesdis.gsfc.nasa.gov) for Linux.
   The version released under the Gnu Public License, incorportated herein
   by reference. 

   This program must be run as 'root' or SUID 'root'.  It takes a single
   optional parameter, the number of seconds to wait before going into
   standby mode.

   This program enables the spin-down feature which is standard in all
   modern IDE disks.  A user-level program is a poor way to do this, but
   I got tired of patching it into my own kernels and I didn't feel I
   could maintain an Official Kernel Feature.

   This program, when combined with disks that are slow to spin up, may
   cause Linux kernels before 1.1.53 to log an error when the disk
   doesn't respond immediately.  The kernel then resets the controller, and
   by that time the disk has spun up.  One other annoying misfeature with
   older kernels is that the disk drive posts an interrupt when it goes
   into spin-down mode, the kernel doesn't know what the interrupt is
   from, and 'syslog' immediately spins the disk back up.  The quick,
   sleazy solution is to configure 'syslog' to ignore those messages.
   The long-term solution is to upgrade to a kernel later then 1.1.53.
 */

#include <unistd.h>
#include <stdio.h>
#include <asm/io.h>

#define IDE_BASE	0x1f0
#define IDE_SECTOR_CNT	0x1f2
#define IDE_CMD		0x1f7
#define PORTIO_ON	1

enum ide_cmd {StandbyImmediate=0xe0, IdleImmediate=0xe1, StandbyTimer=0xe2,
	  IdleTimer=0xe3,};

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

    if (ioperm(IDE_BASE, 8, PORTIO_ON)) {
	perror("diskdown:ioperm()");
	fprintf(stderr, "diskdown: You must run this program as root.\n");
	return 1;
    }

    if (argc > 1) {
	timeout = atoi(argv[1]);
	if (timeout < 10)
	    timeout = 60;
    }
    
    {
	int old_cnt = inb(IDE_SECTOR_CNT);
	/*printf("Old sector count: %d.\n", old_cnt);*/
	/* The timeout period is in units of 5 seconds, up to an index of 240.
	   Values over 240 (20 minutes) set vendor-specific timeouts. */
 	outb((timeout + 4)/5,IDE_SECTOR_CNT);
	outb(StandbyTimer, IDE_CMD);
 	outb(old_cnt,IDE_SECTOR_CNT);
    }

    return 0;
}

/*
 * Local variables:
 * compile-command: "gcc -O6 -o diskdown diskdown.c"
 * comment-column: 32
 * End:
 */

  	  
-- 
Donald Becker					  becker@cesdis.gsfc.nasa.gov
USRA-CESDIS, Center of Excellence in Space Data and Information Sciences.
Code 930.5, Goddard Space Flight Center,  Greenbelt, MD.  20771
301-286-0882	     http://cesdis.gsfc.nasa.gov/pub/people/becker/whoiam.html





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199512011248.XAA17281>