I use my Pi as a homeserver (headless via ssh, always on, restarted once a week). It's running raspbian, and I am running Ubuntu on my Desktop. Now, I want to add hard drives for backups and NAS to the Pi. At the moment I use an external usb hard drive, but later I may want to use a raid system (in case a drive fails). I also use autofs with --ghost to unmount the drive when not used for some time.

The idea/hope behind this was that the hard drive would go into some kind of standby/spindown mode when unmounted via autofs, but this is not the case. It seems to spin as fast as always, and it also gets as warm as when mounted.

So what I want is mass storage that goes to the deepest sleep/standby mode available, so it does not get too hot, saves energy and only awakes when needed (i.e. when mounted). Does someone know how I can achieve this? Thanks.

EDIT: I tried the following:

$ sudo hdparm -Y /dev/sda

 issuing sleep command
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


$ sudo hdparm -y /dev/sda

 issuing standby command
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


sudo sdparm --flexible --command=stop /dev/sda

this seems to be nearly the fix, the drive spins down, but gets fast again after a second or so.

EDIT2: This looks promising:

Someone told me I should use eject, and it worked. It's not installed by default, though. So I did the following:

sudo apt-get install eject
sudo eject /dev/sda

And the drive spinned down completely. Autofs was still able to wake it up. Since I use autofs to decide when the drive get's unmounted (and to automatically mount it again when needed), I have to execute this command when autofs unmounted the drive. I did not find a solution to do this, though. Do you have any suggestions?

  • In my case the HDD spins down after 10 mins idle, when the server is running (odroid), but when it is unplugged or the server does not run, then it spins indefinitely. What happens by your external HDD when you turn off the rpi? – inf3rno Feb 13 '16 at 1:00
  • mine doesn't stop not even with "eject". The only one that works si hd-idle but it stops only for 1 minute, then it goes back on. – Danny182 Jun 26 '17 at 9:02
sudo hdparm -y /dev/sda

(assuming you only have one USB disc connected) can put your device into sleep. If you do this after unmounting the device, it should stay in this powersaving mode until you try to mount it again.

You may also try -Y option for sleep mode instead of stand by.

You can also try:

hdparm -k1 -K1 -S2 /dev/sda

which should spin your drive after 10 seconds of inactivity (you can change -SXX to other values (1-240 can be used to specify multiples of 5 seconds, 0 turns spin down time off, 241-255 can be used to specify longer periods).

Another option you could try is to use:

sdparm --flexible --command=stop /dev/sda

Note: It seems that which commands are supported depends on both HDD and HDD->USB converter being used.

  • I have the impression that hdparm doesn't necessarily work on USB-connected disks. This might depend on the USB-to-SATA (or IDE) controller in use. But on directly connected IDE or SATA disks I am sure hdparm it's the right way. – Frepa Mar 27 '13 at 16:21
  • @Frepa: I know that at least some people reported that it works for them so it may indeed depend on the particular controller. – Krzysztof Adamski Mar 27 '13 at 19:02
  • OK, good to know. I didn't get it to work myself, I don't know precisely why. – Frepa Mar 28 '13 at 11:34
  • Sorry for answering so late, I just couldn't find the time to try this. I tried it now, but it does not work for me. I'll edit the error messages from the terminal into my question. – verpfeilt May 2 '13 at 13:41
  • @chocobai: I've updated my answer. It may help your case. – Krzysztof Adamski May 2 '13 at 14:49

Advanced power management (APM) of a hard drive that is connected through USB-to-SATA bridge can be set by command

sudo smartctl -s apm,127 /dev/sdx

Value 127 means "intermediate (APM) level with standby". Using this level, the hard drive spins down after several seconds of inactivity and starts again on demand.

Tested on BeagleBone, Ubuntu 13.10.

  • To install smartctl you need to run sudo apt-get install smartmontools – Hengjie Feb 8 '16 at 10:43

USB-Ports are general solutions only...for everything, but not specialized on Harddrives, these slow USB-2 Ports have shared access with the Ethernet-Adapter. This means you will be slow as hell with many disks connected to them.

You may use an additional controller board for your project solution. Look for "raspberry pidrive" and get an X8XX Controller board to attach.

You may also look at https://www.smartmontools.org/wiki/USB describing what is possible with a "humpty-dumpty" USB interface, and what control you have with SATA....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.