RPi – Turn of external hard drive when not in use

If you have a Raspberry Pi connected to an external hard drive and you keep it on all the time then you may find that the external hard drive continues to stay spinning, even though you aren’t reading anything from it. I have two problems with that:
1) Waste of energy (negligible but still)
2) Noise

The noise part annoys me the most because I like a little peace and quiet around the home 🙂

Anyway, I’m using a Seagate Expansion External Hard drive (3Tb) and it never stopped spinning…I found a solution! Follow these steps:

1) Run this command

sudo nano /etc/hdparm.conf

This will open the hdparm.conf file for editing.

2) Look for the line “# -B apm setting” and observe the line that follows. My one looked like this:
# apm = x
where x = some value.

3) Remove the # from the start of the line, and change the 127 to 1.

4) Hit Ctrl+X and press Y to save the file.

5) Reboot your RPi

That’s it!

In Linux, the hdparam program is used to get/set hard drive parameter, see http://linux.die.net/man/8/hdparm. You can achieve the above by entering this:

sudo hdparm -B 1 /dev/sda2


/dev/sda2 is the hard drive’s device path

1 means highest power management (254 is lowest power management)

The bad part is that you have to run that command each time you reboot your RPi. However, by editing the /etc/hdparm.conf file, it is automatically applied at boot time and it becomes the default setting for all hard drives.


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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s