Is there a way to turn on or off the power supply of up to seven hard drives with the help of an Arduino? Or maybe there is another way to ultimately - but restorable - prevent read/write access to the disks.
Switching power on and off to hard drives is not as simple as you may think.
First you have three voltages to control - 3.3V, 5V and 12V, and on top of that you have (ideally) pre-charging for the 5V and 12V pins. The power-on sequence would ideally be:
- Power up 5V and 12V pre-charge
- Power up 3.3V, 5V and 12V main power
That's 5 poles for one drive (although you can get away without the pre-charge).
So you would be switching at minimum 3 power signals per drive. For 7 drives that would be 21 power signals that need to be switched.
Switching off power to a hard drive using mechanisms that aren't directly under the control of the operating system can cause file-system corruption and data loss.
The operating system caches data internally and writes it to the hard drive when able to. If the hard drive is turned off while there is still data cached that data will never get written to the hard drive. Worse still, if you turn it off whilst it is writing the file-system could become irrevocably corrupted (depending on the file-system in use and the resilience of it).
Most hard drives have the ability to power themselves down at a command from the operating system. I suggest you use this mechanism instead, since it is more reliable that blindly shutting off the power. Chances are your hard drives are already doing this, since most operating systems enable it by default.
If you want to control them externally, I suggest buying e.g. an 8 channel relay. This way you can easily control them with the Arduino, and using external power for the devices to switch on/off.
If you want extra protection (especially with motors or expecting spikes on signals), use relays with opto-couplers.