Spindown 0.4.0

Spindown is a system daemon that spins down idle disks and so saving energy and giving the disks a longer lifetime.
Spindown is a system daemon that spins down idle disks and so saving energy and giving the disks a longer lifetime.

It works by checking how many blocks are read and written from the disks. When no blocks are read or written the disk is idle. When a disk stays idle long enough spindown uses sg_start to spin the disk down. It also works with usb disks and hotswappable disks because it doesn't watch the device name (hda, sdb, ...), but the device id. This means that it doesn't matter if the disk is swapped while the deamon is running.

Requirements:

� sg_start

Installation

First you need to download the source code and compile it. Because there are no nasty dependencies (except for sg3_start), this should be no problem.

$ tar xvzf spindown-x.x.x.tar.gz
$ cd spindown-x.x.x.tar.gz
$ make
# make install


Configuration

After compiling and installing the deamon you still need to configure it. Do this by editing the sample configuration file (spindown.conf.example) with your favorite editor. Once you are satisfied with the settings save the file and copy it to /etc/spindown.conf.

The sections

The configuration file consists of two different sections: the general section and several disk sections. There should only be one general section, but different disk sections are allowed.

[General]
[Disk 0]
[Disk 1]
...
[Disk n]


The General section

The General section has only two parameters: cycle-time and idle-time. The cycle-time parameter defines the time in seconds between checks (looking up the device name for the disk id and updating the amount of block read and written), a good value is 60. The idle-time parameter defines how long a disk should be idle before it is spundown. Don't use a to small value for this setting, because spinning the disc up and down to much isn't good for it's health. A good value for idle-time is 3600. As of version 0.2 of spindown it is also possible to set this time per disk.

[General]
cycle-time = 60 # Number of seconds between two cycles
idle-time = 3600 # The time in seconds a disk has to be idle before it is spundown.
# Do not use a value that is to small (less than 3600)


The Disk sections

There are several Disk sections allowed, but they need to have a different id or name. Each disk can have several parameters, but only the id or name parameter is obligated (not both).

Id parameter

The id parameter must contain the id of the diks, this is not the device name (sda, sdb, hda, ...), but mostly a string like this ata-Hitachi_HTS54161-SB2404SJHD07JE. You can find the id of your disk by looking in /deb/disk/by-id

$ ls -l /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root 9 2008-03-20 10:38 ata-Hitachi_HTS54161-SB2404SJHD07JE -> ../../sda
lrwxrwxrwx 1 root root 10 2008-03-20 10:38 ata-Hitachi_HTS54161-SB2404SJHD07JE-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 2008-03-20 10:38 ata-Hitachi_HTS54161-SB2404SJHD07JE-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 2008-03-20 10:38 ata-Hitachi_HTS54161-SB2404SJHD07JE-part4 -> ../../sda4
lrwxrwxrwx 1 root root 9 2008-03-20 10:38 scsi-S_SB2404SJHD07JE -> ../../sda
lrwxrwxrwx 1 root root 10 2008-03-20 10:38 scsi-S_SB2404SJHD07JE-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 2008-03-20 10:38 scsi-S_SB2404SJHD07JE-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 2008-03-20 10:38 scsi-S_SB2404SJHD07JE-part4 -> ../../sda4


Lets say you'll need to know the id of sda, in this case this is ata-Hitachi_HTS54161-SB2404SJHD07JE. Be sure not to use the id's of the partitions. When there are more entries for the same disk it shouldn't matter wich one you chose. This method is really great for swappable disks like usb drives because the device name could change when you have several.

Name parameter

You can also also use the name parameter if you know you are never going to unplug the disk. Then you can just use a device name (sda, hdb) with the name parameter.

Spindown parameter

The spindown parameter is boolean, it can either be 1 or 0. When it is 1 this means that disk will be spundown when it has been idle long enough. When this parameter is not given it defaults to 0.

Command parameter

The command parameter tells the spindown script which parameters to use to spindown the disc with sg3_start. You should try to find these out by your self. For me it mostly is enough to use "--stop" or "--stop --pc=2". You can try these parameters by running sg_start yourself.

$ sg_start --stop /dev/sda

Just replace sda with the name of your disk and make sure that there is no activity on this disk (by unmounting it or something like that). You should hear the disk spinning down when the command worked. If this parameter is not defined "--stop" is used.

Idle-time parameter

As of version 0.2 of spindown it is also possible to set the idle-time per disk. This time is also given in seconds.

Example of configuration file

So your disk sections may look something like this:

# Add as much disks as you want.
# Only id is needed, for everything else the default values will be used.
# If spindown is not specified the disk will not be spun down.
# The default command is --stop.
[Disk 0]
id = ata-Hitachi_HTS54161-SB2404SJHD07JE
spindown = 0

[Disk 1]
id = usb-Sony_Storage_Media_1A06101710143-0:0
spindown = 1
command = --stop --pc=2
idle-time = 900

[Disk 2]
name = sda
spindown = 0


Disks that are not specified will not be spun down.

last updated on:
April 19th, 2009, 18:54 GMT
price:
FREE!
homepage:
code.google.com
license type:
GPL v3 
developed by:
Dimitri Michaux
category:
ROOT \ System \ Hardware
Spindown
Download Button

In a hurry? Add it to your Download Basket!

user rating 30

3.1/5
 

0/5

Rate it!
What's New in version 0.3.0
  • Spindown no longer uses multiple threads, and the init script now uses Linux Standard Base functions.
read full changelog

Add your review! 1 USER REVIEW SO FAR

SUBMIT