Demystifying SATA hotplug

85,076

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.

Wikipedia sata pins

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).

Solution 4

I have bought a sata bay, which physically allows hot swapping. So I was wondering this question. Right now I got strange results. In linux that was booted from nvme, hot swap worked. But in linux loaded from sata drive, hot swapping another drive caused reboot. I am not sure if some kernel parameters are involved, will explore later. And also will test with windows os.

In Linux I used the following command, where I have choosen fields that I think may be relevant:

$ lsblk -d -o NAME,MAJ:MIN,RM,HOTPLUG,MODEL,ROTA,TYPE,TRAN,SUBSYSTEMS,VENDOR

It says that my SSDs are not removable (note RM and HOTPLUG columns):

NAME    MAJ:MIN RM HOTPLUG MODEL                     ROTA TYPE TRAN   SUBSYSTEMS         VENDOR
sda       8:0    0       0 Samsung_SSD_850_EVO_500GB    0 disk sata   block:scsi:pci     ATA     
sdb       8:16   0       0 Samsung_SSD_860_EVO_500GB    0 disk sata   block:scsi:pci     ATA     
sdc       8:32   1       1 Portable_2_Plus              1 disk usb    block:scsi:usb:pci Live Gam
nvme0n1 259:0    0       0 Samsung SSD 960 EVO 1TB      0 disk nvme   block:nvme:pci

However, I do not know how accurate is info from lsblk. At least, I have noticed that sdc is shown as a rotatable disk (ROTA is 1), but that is false, because it is just an sd card.

RM and HOTPLUG fields stayed at 0 even after I enabled Hot Plug in uefi bios for every port. Strange... I thought that at least HOTPLUG field should become 1. I then additionally checked these things on a supermicro server without hardware raid (so, just several sata ssds inserted to backplane), and they are surely hot swappable, however, RM and HOTPLUG are always 0 there too, despite in server's bios the setting for hot plug was enabled or disabled.

Share:
85,076

Related videos on Youtube

gcb
Author by

gcb

Updated on September 18, 2022

Comments

  • gcb
    gcb over 1 year

    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?

    • Admin
      Admin almost 9 years
      The risk of data should be minimal if you properly unmount your filesystems/volumes. Don't simply yank a drive out, or you will likely lose data. BTW a link to a information from a ~10 year old forum post is not likely to have anything to do with the current state of SATA support, unless you have an ancient computer.
    • Admin
      Admin almost 9 years
      Windows displays hot-pluggable (or rather -removable) internal drives the same way it displays USB thumb drives and the like. Ejecting it will also power down the drive.
    • Admin
      Admin almost 9 years
      My anecdotal experience with a half-dozen different computers/motherboards is that hotplugging works perfectly fine as long as you properly unmount things.
    • Admin
      Admin almost 9 years
      Related: In which order do I plug the SATA power and data cables for hotplug? on Server Fault. The accepted answer has several relevant snippets from the actual SATA standard as well as comparisons to SAS cabling.
    • Admin
      Admin almost 9 years
      @MichaelKjörling i had found that before. you can see how the specs are extremely cryptic and how the accepted answers ends up saying that the "capability is the responsibility of the system designer, and they should ensure the drive is stopped before hot removal occurs. You, in this case, are the system designer." which is not a conclusive answer at all :)
  • gcb
    gcb almost 9 years
    right. the staggered ground pin like USB. yeah. the proper sata connector also has 3V besides 12V and 5V. it's the optional orange cable. Now, there is also zero information on which drivers require the orange cable :/ i don't think any manufacturer make use of it because cheap PSU won't provide it and there are people using molex->sata (like i do with 2 drives i run out of native cables)
  • qasdfdsaq
    qasdfdsaq over 7 years
    You can pretty much guarantee any modern drive will park its head automatically on power down because no drive built in the last 10-15 years is even able to power down without doing so without catastrophic failure. Drives use residual power from platter rotation if it really needs to, but some enterprise drives have supercapacitors for additional data loss protection too.
  • SDsolar
    SDsolar almost 7 years
    I believe the different lengths tell the story. Some need to be connected before the others. With SCSI it was simply that it needed power before data. But SATA has this on both sets. Very interesting. Thank you for posting these photos.
  • Arjan
    Arjan over 4 years
    As for the very last paragraph about the possibility to kill one using 12V: in a now deleted answer, user com nut referred to scienceabc.com/humans/how-many-volts-amps-kill-you-human.htm‌​l to deny that.
  • gcb
    gcb almost 4 years
    > "park it's head automatically on power down, because we can't guarantee it has enough power to do it." This is pretty much a death sentence for the drive, as hot-unplugging implies moving the drive to begin with.
  • Thomas Weller
    Thomas Weller over 3 years
    Amperage may kill, but how are 12V supposed to drive 0,3A through my body with 120kOhm?
  • gcb
    gcb over 3 years
    at least on my system, the output of lsblk -d -o HOTPLUG is exactly what is set on my BIOS. E.g. if I set sata port 1 and 2, no matter what is plugged there will show as hotplug=1. Right now i have one HDD and one CD rom drive because i enabled the wrong port on the bios :)