Spindown

11 09 2008

So in my pursuit to use as little power as possible the best thing for hard disks to do when not in use is spindown! They use maybe 1 W of power in this state versus 4-8 W in idle and spinning state. (Don’t quote me… its approximate) So I was looking for a way to make this happen easily. My motherboard has an option in the bios that I think I tired once and it didn’t work so I moved on… I also compiled and played with sdparm successfully but it was only a command to spin down the drives… no way to monitor idle time and automatically spin them down after x units of time (like hdparm has in it). But alas I have found…

http://code.google.com/p/spindown/

It is a dameon that runs and monitors harddisks, after idle after a time you specify it runs a command against it, in this case it runs the sg_start –stop /dev/sda command when my data drive is idle for 60 seconds (this will change but that is my current testing scenario). The sg_start command is part of the sg3_utils package from MIT maybe? The download link is on the above website which is where I found it.

I downloaded the source and did the standard make, make install and it went fine. Created the .conf files as instructed. The place where I ran into the issue was starting the daemon. The documentation says to start the daemon run:

/etc/init.d/spindown start

Which didn’t work for me it came back with this error:

Starting spindownd daemon… /etc/init.d/spindown: line 91: start-stop-daemon: command not found
done.

Not helpful. So I started the daemon by hand:

spindownd

And found out by default it looked for the config file in the same directory as you run it. So I cd’ed to /etc/ and ran it again and it started. And I tried to get a status on it by running:

/etc/init.d/spindown status

Which told me the damon wasn’t running… which was curious because my drive had already spun itself down, so I know it was running.

So I dug into the /etc/init.d/spindown file. I opened it up in vi and starting poking around. First thing I saw was the code for how it was checking the status… it was calling:

ps auxw | grep -i spindownd | grep -v grep | wc -l

And checking for how many records it returned. If it returned anything but 1 it was say it wasn’t running. I ran the command manually and I had three instances of it running. 3 does not equal 1; now I know why it was “telling” me falsely it wasn’t running. I changed the 1 in the if statemnet ( if [ $CHECK -ne 1];) to a 3 and reran that status check. Sure enough it dumped the headers but didn’t have any info besides that… hmmm. So I headed back to vi to see what was going on. At this point I decided I might need this script to start the daemon so the status part would work so I looked at the error from trying to start it via the script and noticed it said command not found… located the line in the file:

start-stop-daemon –start \
–exec ${SPINDOWNPATH} \
–name spindownd \
— -f ${FIFOPATH} -c ${CONFPATH}

OK, I’ve never dealt with this command before but it looks like it is a generic daemon starting command where the path to the executible, the name of the daemon, and its params are passed to it and it starts. So I went ahead and ran start-stop-daemon on my Puppy linux box and as expected: no command found. Ok so this command doesn’t work on my distro, that explains why it isn’t starting. So I commented all those lines out and added the straight call to the daemon using the variables in the script and came up with:

spindownd -f ${FIFOPATH} -c ${CONFPATH}
# start-stop-daemon –start \
# –exec ${SPINDOWNPATH} \
# –name spindownd \
# — -f ${FIFOPATH} -c ${CONFPATH}

Fired it up again and success it ran. Tried the status… it runs too! Watch my idle times climb and then my disk get spun down. All in all, an easy compile and with a few distro specific tweaks (not unexpected for running a stripped down version of linux like Puppy) it works.

Conclusion:

spindown will be most likely be used for spinning down my SATA data drives

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: