You are not logged in.

#1 2014-07-16 08:01:37

cdwijs
Member
Registered: 2010-04-24
Posts: 310

Hotplugging hard drives, how can this be automated?

Hi All,

I'm planning to build something that can hotplug a hard drive. This is done by removing and re-applying the power on demand. (On my allwinner A20 I can assert a general purpose pin, that get's fed into a FET circuit between power supply and drive)
The problem with this aproch, is that a normal linux installation is not prepared for a harddrive to disapear and re-apprear. What I need for this to work, is a script that is run when the hard drive is not needed, and a second script that is run when a process needs data from the harddrive again.

Normally this is done by the harddrive itself, but I have a harddrive that uses a lot of power while it's idle (not spinning). Of course I can replace this drive by a drive that uses less idle power, but i like to take on the challenge of getting the idle power down to 0.

Does anybody know some way of doing this?

Kind regards,
Cedric

Offline

#2 2014-07-16 16:15:00

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Hotplugging hard drives, how can this be automated?

What kind of a drive are you using? If a SATA drive, then take a look at eSATA. If not, then I assume you use an external power supply for this, that provides enough voltage smoothing and can handle power load up to 10 W. How will you interface the drive with the system? If it is an IDE drive, I recommend using a SATA adapter, but make sure it supports plug'n'play hot plugging, this should be implemented [almost] everywhere.

I do not see what problems you want to encounter here. After powering up, disk should function as usual. For spinning up/down, at least indirectly, use hdparm or one of those applications/daemons in aur (search for 'spin down'). you only have to take care about powering the hdd until it really is idle  [including unmounted] and down. Maybe udev can help you make it removable if not already recognized as such.

In case I missed something and you are planning to use this for a desktop with a desktop PSU: Where do you want to draw the power from? Most [modern at least] PSUs do not support devices "hot" plugging (this might depend on the rails used though). Since you mention "a lot of power" (name a number) when the drive is idle, I would argue that USB3.1 would be sufficient, should it be already available.

Edit: Updated and clarified.

Last edited by emeres (2014-07-16 23:14:40)

Offline

#3 2014-07-16 16:41:09

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: Hotplugging hard drives, how can this be automated?

cdwijs wrote:

linux installation is not prepared for a harddrive to disapear and re-apprear.

More specifically, Linux is not prepared for a drive to disappear then reappear when the drive is in use (eg. mounted). I highly doubt you'll be able to work around this with scripting.

emeres wrote:

I recommend using a SATA adapter, but make sure it supports plug'n'play

AFAIK plug'n'play is not related to SATA hotpluggability. What's necessary is an AHCI-capable SATA controller with AHCI or RAID mode enabled in the BIOS.

emeres wrote:

Most PSUs do not support devices "hot" plugging.

What is the basis for this claim?

Last edited by alphaniner (2014-07-16 16:44:58)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2014-07-16 17:00:29

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Hotplugging hard drives, how can this be automated?

Right, plug'n'play is a different story, my bad, I will change that in the previous post. As far as I know all SATA devices should be hot pluggable, controllers are another story, but they should support it.
As for the PSUs, most of the modern units have various failsafes. Working with dozens models/units (most were nonames) over the last decade or so (actually longer, I feel old), I never witnessed one that could handle current surge for starting/initializing a dvd/hdd. Maybe some older PSUs ignore it, but modern ones? I highly doubt it. Even a recent cheap one from Asia, that used "special" oil on the fan bearing, so that eventually it was glued and could not turn, did have various protections and would shutdown on an attempt to plug a dvd drive. In short: my experience, yours may differ.

Edit: Now that I think about it, maybe hdds were not that big of a problem, but optical drives were.

Edit: Another aspect that I may missed upon consideration: different voltage rails. A modern PSU usually has several and from the description of most manufacturers, each of them is individually protected. So if I would attempt to connect an optical drive or an hdd to unloaded rail, it probably would trigger protection circuits. However should I attempt to use an already loaded rail (with hdds for example), it may not trigger any event. I do not recall, how I tested different devices myself, and I am certainly not willing to get an unscheduled shutdown right now. Building those safety measures in makes sense, since internal hardware is usually connected once in a while, molex connectors are build to maintain that connection and one should not work with power turned on inside the pc.

Last edited by emeres (2014-07-16 23:12:19)

Offline

Board footer

Powered by FluxBB