Spin down idle drives in Ubuntu Server

Since this server will be running 24 hours a day the running costs are something that should not be ignored. One way of reducing power consumption is to spin down the hard drives, or put them into “standby”, when they are not in use. I’ve never managed to get the system drive to spin down but additional drives can be spun down quite successfully. The utility to spin down drives is called hdparm.

To spin down a hard drive after x minutes of inactivity issue the following commands:

sudo vim /etc/hdparm.conf

and enter your password if prompted. This will open the hdparm.conf file.

Next, scroll down to the bottom and then press the [Insert] key once (this will take us into “edit” mode) and then type the following:

command_line {
hdparm -S 241 /dev/sdb
}

The above command sets the idle standby/spindown time for the 2nd hard drive (/dev/sdb) to be 30 minutes.

Repeat this command for each drive you want to spin down.

If you’re not sure of the names of your drives then you can issue the following command in a Terminal/Putty session to list them:

sudo fdisk -l

If you have more than one drive installed you will see them all listed. For example:

….
….
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
….
…..

So, you would use /dev/sdc in the command_line { command above, in place of the /dev/sdb, if you wanted to spin down this particular drive.

When you have finished editing the hdparm.conf file press the [Esc] key once and type :wq to save and quit out of the file. If you make a mistake at any time then issue :q! instead of :wq to abort your changes.

You will need to reboot your server for the changes to take effect. Reminder: sudo reboot -h now in a Terminal/Putty session.

hdparm has loads of different options. To see what they are simply type man hdparm in a Putty/Terminal session to bring up the manual. Use the Page Up, Page Down, Cursor up and Cursor down keys to navigate the manual and press q to quit out of the manual.