Demystifying SATA hotplug
I have a BIOS that has an option to enable hot-plug on individual ports. I have a sliding enclosure for HDD and SSD (nothing more than a pass-trhu to power and a sata port) that allow me to cut power to the drive before physically moving it.
I would love the convenience of inserting and removing HDD/SSD there without shutting down the computer every time.
But while researching about SATA hotswap, out of expensive enterprise solutions, there is zero reliable information. I tried even looking at patents. I can't find a single reliable source that tells me how reliable/unreliable is hotswapping on the consumer world.
So, I do have support in my bios, motherboard and enclosure. The drivers I've never seen mentioning hot-pluggable on the specs, even on the enterprise ones. How much risk of data loss will i be facing for this convenience?
Then, hardware aside, there is the software issue. Do i need support on the OS? and is there any AT command to unplug the drive that must be issued or does it park it's head on power down automatically? there is a slightly informed discussion on the software side here
edit: found some more info regarding hot-pluggable. from Western Digital: it says every driver that supports SATA by definition of the standard, already support hot-plugging.
SATA-compliant devices thus need no further modification to be hot-pluggable and provide the necessary building blocks for a robust hot-plug solution, which typically includes: Device detection even with power downed receptacles (typical of server applications)
Pre-charging resistors to passively limit inrush current during drive insertion
Hot-plug controllers to actively limit inrush current during drive insertion
source: http://wdc.custhelp.com/app/answers/detail/a_id/941/~/hot-swap-or-hot-plug-wd-sata-drives
But, the above starts another doubt. it says:
In order to take advantage of hot-plug capabilities for your Serial ATA hard drive, you must use the Serial ATA power connection, not the Legacy (Molex) power connection. The Legacy (Molex) power connection does not support hot-plugging.
some of my drivers are connected from molex->sata power, just because i'm out of sata power ports on my PSU. from what i could trace, some molex and Sata power comes from the same 12V rail. and the SATA plug does not have any logic it seems. it is just dumb plastic. Does that mean i'm safe and the doc refers to drivers that supports both sata and molex?
Solution 1:
How much risk of data loss will i be facing for this convenience? Unless the drive dies, there's not much risk of data loss. HDD are really reliable with handling unexpected power lost. SSD are not as reliable regarding unexpected power lost. That said, if there's no activities happening on the drive, hot-plugging is pretty safe. I do this almost everyday.
Do I need support on the OS? Nah, the drives doesn't care about the OS. If the OS doesn't support hot-plug, then it means the OS might need to restart to detect the drive, and that it won't send commands to the drives for a more graceful shutdown. Worst case scenario, the OS crash, but your drive will be OK. Remember, as long as there are no activities on the drive, then it's pretty safe to unplug it.
Is there any AT command to unplug the drive that must be issued or does it park it's head on power down automatically? There are commands to force the drive to park it's heads, but it will also do that when there's no activity on the drive. Can't guarantee that it will park it's head automatically on power down, because we can't guarantee it has enough power to do it.
Oh, here's a caveat. Some OS might delay sending data to the drive, or saving file system information to the drive. This is when you should use the "Safely remove" or "Unmount" features. This only applies for newly written data.
Solution 2:
and the SATA plug does not have any logic it seems. it is just dumb plastic.
That is wrong. The logic contained in the sata power plug is passive logic but it is still there. It is easier to see in a picture of the hard drive pins however it is also present in the power supply connector as well. Notice how some of the pins below are shorter than others? This is so that the pins are connected in a specific order. (I don't recall which order but I believe on the power wires the longer pins are ground and connect first.) The data pins are also setup the same way.
Solution 3:
Just my two cents help... when talking about molex power makes disk not hot swapable, it is about powering the disk by using the molex conector that is on the disk itself.
In other words, if you use from power suply a molex power conector with a molex to sata power adaptor, the disk itself is powered by its sata power connector, so it may be hot swapable, but if such molex power is atached to the molex power conector on the disk (also using a sata power to molex power adaptor) the disk can not be hot swap without risk (electrical peaks on conect and disconect).
Just to let it very clear:
For some disks that they have a molex power conector on them, do not power them through such conector, molex conector is not safe for hot-swap
If the power conector on the disk that is been used is the sata power conector, then it does not matter where power comes, you can use molex to sata power adaptors... since the disk is been powered by its sata power connector.
The risk is using the molex conector present on some disks, not all sata drives has such molex conector on the disk.
Also, a disk powered by sata power connector that is powered with a molex to sata power adaptor can die if such molex conection is not firm or if you disconnect the molex part.
So resuming: Never disconect the molex power connector, only sata power conectors.
Hope it is clear now.
2º Point: Hot-swap support, it must be supporeted (better said, implemented) on sata port, not on sata drive; and it also must be supported on the operating system.
The OS must know when a drive on a sata port will be disconnected prior to disconnect (among modern OS are able to detect abrutly disconections and still work, other OS just freezes), so user (or software apps) must tell the OS that a disk is going to be removed (eject on Linux, safe remove on Windows, etc).
If the OS is not designed for hot-swap, weird things can happen when you plug another disk, like the OS thinking the old disk come to live again... and the OS will not see the new disk is different... modern OS detect hardware changes, other OS do not.
So, yes, sata hot-swap must be implemented on sata controller hardware and on the OS... but not on the disk, the disk itself has nothing related with hot-swap.
To hot-swap any disk, the OS flushes all data, and send a command to the disk telling it must flush all its internal cache and then do a spin-down, after that the OS tell the sata driver to disconnect data port and if well designed also power port, then the user can safaly remove the disk (no data can be sent, no power that may case electrical peaks, etc), the the sata hardware must detect infinite impedance (no drive is conected) on sata data port and sata power port, and get prepared for a new drive, listening for non infinite impedances, so it reconects power and data ports as soon as the other drive is connected... then it must tell the OS a new hardware has been connected, and the OS must see what it is and load drivers, etc.
Sata hot-swap must be implemented on hardware, oh, yes, it must be... some manufactures are a bit lazy and do not follow Sata specs, they do not implement hot-plug, hot-swap, etc.
Sometimes i found SataIII ports that died when conecting a drive while system is powered.
I recomend one test prior to test with the OS loaded... boot to bios without drive conected to sata and see bios do not detect the drive, then plug the drive very carfully without exiting the bios, and re-check that the bios now detects the disk... if not do not procced and power off the pc inmediatly without exiting the bios.
If your bios can see the disk after hot pluging it, you know it is hot-plug... but wait, you still not know if is it hot-swap... for that you need another diferent disk (not the same model/brand/capacity) and continue with the test inside the bios... now you must unplug the disk and see if bios hangs or if it detect now there is not such disk... if hangs, power off inmediatly, your bios is not hot-swap... if it detects there is no disk, just continue the test to see if it is hot-swap or not.
If the bios detects no disk after unplug, now it is time to check another disk... use one disk you do not need, it can die as soon as connected, you are warned!... plug it and see if bios detects it, if not then power off inmediatly, it has no hot-swap implemented, ... if it sees the disk as if it where the previous one, power off inmediatly, no hot-swap... buy if it sees the new one, you are very lucky, the hardware has the implementation for hot-swap.
If such tests shows you that you hardware is not trully hot-swap, no matter what do the OS, the hot-swap procedure is very risky if not impossible at all... and better do not use it at all, allways power down prior to swap.
But if your bios show you it see the drive, then it see you unpluged it, then it see the other disk plugged, then you have hardware support for hot-plug on that sata port... i repeat: on that sata port. Oh, yes, my friends, some lazy manufactures only implements hot-swap on some ports and not on all of them.
Risks of this tests you must support: Loosing sata port because if dies when pluging a drive on it while being on bios... no matter, it would also died if you where running the OS, and with OS running it could also damage other sata ports.
Worst case scenario: Sata root controller died because no hot-swap capable, if you where on bios, no data was on risk, but if you where running the OS you can loose all data and also damage other components like graphics card, ram, efc.
Doing the tests while on bios is the safiest... and if any damage is caused to sata port, mosy times only one port dies... anyway, if it is on warranty they must fix it, since legal rules i pose manufactures to not cause damage by conect/disconect in a properly manner.
Said again, do not trie hot-plu, hot-remove, hot-swap, if disk is powered by the molex connector that is fixed to the disk (not all drives has molex power connector, most do not have it)... and neither disconnect the molex part of any molex to sata power adapters.
Molex conectors are not designed for hot-plug, hot-remove, hot-swap... they cause electrical peaks.
P.D.: On some molex pins, the current that is passing can be more than 3.5A, that can kill a person (not common, but it can), the voltage (12V) is not what kill people, it is the amperage (>0.3A can kill, no matter the voltage, it is the ampetage what kills).