1

I have a Pi that is set-up with miniDlna for playing media to my tv and a samba server for a NAS set-up. My pi is connected to an external hard-drive that is actually just a hard drive enclosure; it uses internal ide/sata hard drives and makes them into usb hard drives. When you install the hard drive there is access to all the internal electronic components.

I want to be able to turn off the hard drive when it is not being accessed. I am thinking the best way to do this is to make a small circuit/relay that is activated by the gpio pins. Then the pi would run some software/service that would detect when the media is trying to be accessed. It would then send the signal to the gpio pin/s letting the hard-drive turn on and serve the request.

I believe I can figure out the electronics side of this project! My biggest hurdle and what I need help on is understanding what to look for within the software side and OS so I can determine when the hard drive is going to be accessed. I also am concerned with how miniDlna and samba are working? How connected and aware are they of the HD?

Anyone with any ideas of what I should look into on this would be great to here from you

  • 2
    1. [What @lenik said]. 2. You can use hdparm -y to issue a spin-down signal to the hard-disk. That way, you don't have to worry about syncing file system changes before disconnecting the drive (since you're not disconnecting it) and it will spin up automatically when it is accessed. – n.st May 12 '14 at 22:42
  • I have tried hdparm but with a different parameter passed in. It did spin down but would not allow me to access it after that. I will try with the -y and see. With this hard drive being an ide hard drive in an enclosure connected to the computer by usb it kinda is finicky. – NDEthos May 15 '14 at 15:14
  • I measured the power consumption of by pi with as external Toshiba drive and without. The difference was ~4W. When this drive went to sleep, the power consumption dropped to 3.5W !! I measured the power using a kill a watt meter. – Lord Loh. Sep 10 '14 at 1:38
2

there are a few problems with your idea.

first, turning the HDD off and back on wears down the mechanical part a lot. HDD working 24/7 usually has a 2-3 times longer life than the one switched on in the morning and back off in the evening. the matter gets worse if you're going to flip the power more frequently.

second, the correct way to turn the HDD off would be to close all files opened on the device, flush all caches, unmount and totally disconnect any service that may be using the data (samba, nfs, etc.). you might need a very deep and unnecessary complicated software to do all this properly. and if you don't, you'll be welcome to the wonderful world of the file system corruption.

if you still want to power down the HDD for some reason, the safest bet would be to get a HDD that automatically spins down after period of inactivity. but then, you'll need a solution to reliably spin it back on when needed, and this might be a problem.

there are other questions similar to your, and as far as I know, there's no perfect solution to this problem, and you might be better leave it alone as well.

  • do you have a reference for the "HDD working 24/7 usually has a 2-3 times longer life than the one switched on in the morning and back off in the evening"? – user2813274 Aug 12 '14 at 15:25
  • @user2813274 i have personally withessed how a HDD died in a matter of hours of constant switching power on and off. – lenik Aug 13 '14 at 13:47
  • I was hoping for something other than personal experience.. as in a study with numbers/etc. AIRC the google study showed only a 2% increased failure, and only after 3 years, but they didn't have many drives that spun up/down so it wasn't a good study – user2813274 Aug 13 '14 at 14:02
  • I have my opinion, Google has theirs. If you don't like neither, what stops you from performing the study just the way you like it? (this is a rhetorical questions, that's best left unanswered =) – lenik Aug 14 '14 at 11:09
  • I measured the power consumption of by pi with as external Toshiba drive and without. The difference was ~4W. When this drive went to sleep, the power consumption dropped to 3.5W !! I measured the power using a kill a watt meter. – Lord Loh. Sep 10 '14 at 1:37

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.