[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: disk power down



> Can I configure my Linux system to do the same?  Most modern IDE drives
> should support this feature, is support required on the Motherboard or
> Bios to make this work, or is it all in the OS?
> 
> My Linux box uses an AZZA AT socket 7 motherboard with an Intel TX
> chipset and an AMD K6-233 cpu.  I think the bios does support powerdown
> features but the powersupply in my box does not (might only work with
> an ATX power supply).

Running hdparm is not the only thing to consider.  If you want a real powerdown
and not a periodic cycle of disk on and off, you must shutdown stuff
that dings the disk.  When I want to powerdown, I exit all such apps (this
includes Netscape, ppp, etc) and run my script: snooze on.
One caveat, I frequently am lazy and neglect to run snooze off, so be warned
that this may lead to bad habits.
The sysklogd lines are commented out because I have edited my /etc/syslog.conf
to limit the amount of logging enabled.  You might want to uncomment here.

My snooze script:
----------------------------------------------------------------------
#!/bin/sh
# Start/stop system functions related to disk activity.  I run this to
# kill cron and atd deamon so my hard disk will spin down.
# This script uses Debian start/stop scripts in /etc/init.d
# To ensure disk spin down, kill most programs (especially netscape, ...)
# and run (as root)
#    snooze on
# When I return,
#    snooze off

case "$1" in
on)     echo  "Stopping cron, atd"
        hdparm -S 240 /dev/hda
        /etc/init.d/cron stop
        /etc/init.d/atd stop
#        /etc/init.d/sysklogd stop
        ;;
off)    echo  "Starting cron, atd"
        /etc/init.d/cron start
        /etc/init.d/atd start
#        /etc/init.d/sysklogd start
        ;;
*)      echo "Usage: snooze {on|off}"; exit 1
        ;;
esac
exit 0
------------------------------------------------------------------------------

This may be more than you want, but when playing around to get the powerdown
going, it helped to monitor disk activity over periods of time.  Compile the
the following program and leave it running in a terminal to monitor disk
activity on your system:

/* Read /proc/stat and print diskusage info.
 * cc -o disk disk.c
 */

#include <stdio.h>
#include <time.h>

void    readProcStat(void);
char    date[80];

main()
        {
        time_t          tloc;
        struct tm       *pTm;
        
        while (1)
                {
                sleep(15);
                time(&tloc);
                pTm = localtime(&tloc);
                strftime(date, 80, "%I:%M %p", pTm);
                readProcStat();
                }
        }


unsigned long   diskusage;

void
readProcStat(void)
        {
        FILE            *f;
        char            buf[128];
        unsigned long   delta, ll, l0, l1, l2, l3;
        
        f = fopen("/proc/stat", "r");
        if (f)
                {
                fgets(buf, 128, f);     /* cpu n n n n */
                fgets(buf, 128, f);     /* disk n n n n */
                sscanf(buf,"disk %lu %lu %lu %lu", &l0, &l1, &l2, &l3);
                ll = l0 + l1 + l2 + l3;
                delta = ll - diskusage;
                diskusage = ll;
                if (delta > 0)
                        printf("%s - %ld\n", date, delta);
                fclose(f);
                }
        }

-----------------------------------------------------------------------------
Bill Wilson <billw@wt.net>


Reply to: