Difference between revisions of "Debian hdd spindown"

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search
Line 44: Line 44:
 
In the above example I've set hdparm's priority to 19 so it is before such things as NFS, Webmin, etc. You can change this to some other reasonable setting (check your /etc/rc2.d folder to find a good number).
 
In the above example I've set hdparm's priority to 19 so it is before such things as NFS, Webmin, etc. You can change this to some other reasonable setting (check your /etc/rc2.d folder to find a good number).
  
= Modify ''syslogd'' Configuration =
+
== Modify '''syslogd''' Configuration ==
 
If you do not do that, your HDD will be turned on every 20 minutes because syslog will log a "MARK" in /var/log/messages every 20 minutes. So we need to remove that marking :
 
If you do not do that, your HDD will be turned on every 20 minutes because syslog will log a "MARK" in /var/log/messages every 20 minutes. So we need to remove that marking :
 
edit /etc/init.d/sysklogd and set SYSLOGD to
 
edit /etc/init.d/sysklogd and set SYSLOGD to
 
  SYSLOGD="-m 0"
 
  SYSLOGD="-m 0"
 +
 +
== '''exim''' Configuration ==
 +
Exim is what the kurobox could be using as a replacement for sendmail. The problem is that it has no exim.conf file by default (which makes it write to one log file) and it wants to write to the drive every 15 minutes or so. Run this command to configure exim (and creating its configuration file:
 +
eximconfig
 +
I chose option(4) for local delivery only, and gave my non-root username for the recipient when asked during the questions. This process will create a file called /etc/exim/exim.conf with all the chosen configuration settings inside.
 +
 +
The next step is to make it so that exim doesn't try and write to logs every 15 minutes... otherwise setting up hdparm won't do us much good (depending on your setup). Edit the '''/etc/cron.d/exim''', and change this line:
 +
08,23,38,53 *    * * *    mail  if [ -x /usr/lib/exim/exim3 -a -f /etc/exim/exim.conf ]; then /usr/lib/exim/exim3 -q ; fi
 +
To this:
 +
0 * * * *    mail  if [ -x /usr/lib/exim/exim3 -a -f /etc/exim/exim.conf ]; then /usr/lib/exim/exim3 -q ; fi
 +
This will tell cron to start the exim process only on every hour (rather than every 15 minutes or so).
  
 
[[Category: Debian]]
 
[[Category: Debian]]

Revision as of 05:42, 27 August 2006

If you're not using your Kurobox 24 hours a day, it could be good to allow the hard drive to spin down and reduce noise and power usage. For this you'll need to install hdparm to tune the sleep delay, and configure syslog to prevent it from writing to the disk, causing it to wake up every 20 minutes!

Contents

Install, Test & Configure 'hdparm'

Installation

Use apt-get to install hdparm as well as any dependencies automatically:

apt-get install hdparm

Testing

You can find out what your drive's settings are by running this command:

hdparm -i /dev/hda

Typical output would be something like this:

kurobox:~# hdparm -i /dev/hda
/dev/hda:
Model=ST3320620A, FwRev=3.AAC, SerialNo=5QF06WD4
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
BuffType=unknown, BuffSize=16384kB, MaxMultSect=16, MultSect=16
CurCHS=65535/1/63, CurSects=4128705, LBA=yes, LBAsects=268435455
IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes:  pio0 pio1 pio2 pio3 pio4
DMA modes:  mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
AdvancedPM=no WriteCache=disabled
Drive conforms to: device does not report version:
* signifies the current active mode

You can give options to the hdparm command to either view or change specific characteristics. Look through the man page or /etc/hdparm.conf to find out what each option does. For example, changing the spindown time to 5 minutes from the command-line would be:

hdparm -S60 /dev/hda

Read through this Gentoo wiki page to find out some good options to play with in order to possibly increase your drive performance. Make sure to run this drive test both before and after in order find out whether you changes made things better or worse.

Configuration

Once you have found the best possible settings for your drive, edit the hdparm configuration file:

vi /etc/hdparm.conf

You can either uncomment the lines about /dev/hda at the end of the file, which would make the section look like this:

/dev/hda {
       mult_sect_io = 16
       write_cache = off
       dma = on
       spindown_time = 120
}

Add any additional options within the curly brackets for those changes to be permanent. You can also edit the options individually throughout the file (information on each option is provided as comments within the file).

One last step is to make sure hdparm runs for at least your chosen runlevel. For some reason hdparm is not set to run on runlevel 2 by default, so use this command to first remove it's rc.d entries:

update-rc.d -f hdparm remove

Then use this command to add it back to runlevel 2 (with shutdown running at reboot, shutdown, and single-user mode):

update-rc.d hdparm start 19 2 . stop 19 0 1 6 .

In the above example I've set hdparm's priority to 19 so it is before such things as NFS, Webmin, etc. You can change this to some other reasonable setting (check your /etc/rc2.d folder to find a good number).

Modify syslogd Configuration

If you do not do that, your HDD will be turned on every 20 minutes because syslog will log a "MARK" in /var/log/messages every 20 minutes. So we need to remove that marking : edit /etc/init.d/sysklogd and set SYSLOGD to

SYSLOGD="-m 0"

exim Configuration

Exim is what the kurobox could be using as a replacement for sendmail. The problem is that it has no exim.conf file by default (which makes it write to one log file) and it wants to write to the drive every 15 minutes or so. Run this command to configure exim (and creating its configuration file:

eximconfig

I chose option(4) for local delivery only, and gave my non-root username for the recipient when asked during the questions. This process will create a file called /etc/exim/exim.conf with all the chosen configuration settings inside.

The next step is to make it so that exim doesn't try and write to logs every 15 minutes... otherwise setting up hdparm won't do us much good (depending on your setup). Edit the /etc/cron.d/exim, and change this line:

08,23,38,53 *     * * *     mail   if [ -x /usr/lib/exim/exim3 -a -f /etc/exim/exim.conf ]; then /usr/lib/exim/exim3 -q ; fi

To this:

0 * * * *     mail   if [ -x /usr/lib/exim/exim3 -a -f /etc/exim/exim.conf ]; then /usr/lib/exim/exim3 -q ; fi

This will tell cron to start the exim process only on every hour (rather than every 15 minutes or so).