2

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

NDEthos
  • 121
  • 1
  • 2

1 Answers1

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.

lenik
  • 11,533
  • 2
  • 32
  • 37