Spinning down USB drives in linux

Some of the commercial solutions like the “Passport” and “MyBook” USB drives have spin down logic built in to avoid excessive wear and tear. I recently came across a steal on newegg for a bare bones Intel D2500 (atom) based nettop, and decided to get one and plug some external drives in to it, and finally make use of them as part of an oddly configured file server.

The downside, it turns out, is that Ubuntu 12 Server (precision) only comes with the absolute bare bones software to be a functional system. You’re expected to install anything you might need, like say, SSH or Apache2. Servers don’t have much use for USB drive utilities that spin down drives. Actually, it does come with hdparm, which is actually designed to spin down local drives, but is incapable of spinning down external drives, which is what I needed.

Now, to be fair, the official Ubuntu help Wiki does have this page, but it’s rather obtuse and perhaps overly complex. It has a complicated looking script in the middle, but really the only two piece of information you need are

  • The ‘sg3-utils’ package (sudo apt-get install sg3-utils)
  • sg_start –pc=3 /dev/sda (or in my case, sdc)

I was able to then add a single line to my crontab file after testing,

0 0,4,8,12,16,20 * * * sg_start –pc=3 /dev/sdc #sleeps external sdc (250gb) drive every 4 hrs

And now I don’t have to worry about burning up my already old drives in their unventilated enclosures!

This entry was posted in computing, linux and tagged , , , , , , , , , . Bookmark the permalink.

One Response to Spinning down USB drives in linux

  1. Theo says:

    Hi, this is great – plan on using it for my ubuntu media server.
    Firstly I had problems when using: –pc=3
    and had to replace it with –pc=3 (double hyphen if its just a font problem).

    Also was wondering what happens if the disks are in use when this command is issued. In a perfect world the command would just fail and the disk would continue to function, otherwise it could cause whatever function the disk is used for to fail?

    Thanks,
    Theo

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>