In the SATA specification this is referred to as
hot plug and
hot removal and they are two separate events. While the electrical and communication layers support both hot plug and hot removal, check that your drive controller, operating system, and drivers support them.
Note that all of the below ONLY applies to host and devices (ie, drive controllers and drives) that BOTH declare they are hot plug capable.
If your drive controller has specific instructions, follow them. If not, read on.
It doesn't matter which plug to attach first. SATA drives are allowed to be connected to data without power, and to power without data. They are designed so when data is connected without power, some limited drive information can still be obtained (this is mostly used in RAID and backup setups where you want to keep some disks offline to reduce wear and tear, but still need to know what's installed).
So if you plug in the power first, the drive turns on, recognizes there's no data cable, and waits for the data cable to be attached.
If you plug in the data first, the computer recognizes the drive attachment, and that the drive isn't ready, and waits for the drive to signal that it's available.
If you do happen to get a single cable with both power and data, though, you'll find that the data pins are further behind the rest. The pins are staged as follows:
- Ground and precharge inrush power
This suggests that while the drives and controllers should support plugging either cable in any order, when they have control over how cables are connected they prefer power before data.
So if you wanted to be pedantic and prefer one order above the other, your best bet is to follow what they do and connect the data cable last. Note that disconnecting the data first, then the power, when removing the drive will allow the drive to detect the removal, and possibly perform a few last millisecond housekeeping tasks before the power is fully removed.
But, again, the specification allows connection in any order, and should work fine in any order.
From SATA revision 3.0 June 2, 2009 Gold Version
4.1.60 hot plug
The connection of a SATA device to a host system that is already powered. The SATA device is
already powered or powered upon insertion/connection. See section 22.214.171.124 for details on hot
You might think the above suggests that power should be applied first or simultaneously, but this is clarified in 126.96.36.199:
188.8.131.52 Hot Plug Overview
The purpose of this section is to provide the minimum set of normative requirements necessary
for a Serial ATA Host or Device to be declared as “Hot-Plug Capable”. As there exists various
Hot-Plug events, there are relevant electrical and operational limitations for each of those types of
events. The events are defined below, and the Hot-Plug Capability is further classified into:
a) Surprise Hot-Plug capable
b) OS-Aware Hot-Plug capable
When a Host or Device is declared Hot-Plug Capable without any qualifier, this shall imply that
the SATA interface is Surprise Hot-Plug Capable.
For the purposes of this specification, Hot-Plug operations are defined as insertion or removal
operations, between SATA hosts and devices, when either side of the interface is powered.
Hot-Plug Capable Hosts/Devices shall not suffer any electrical damage, or permanent electrical
degradation, and shall resume compliant Tx/Rx operations after the applicable OOB operations,
following the Hot-Plug Events.
Here's the key part of the specification you're interested in. All the following situations shall not damage the device or host, and both the device and host shall resume normal TX/RX communication after any of the following events. While these discuss specific architectures (backplanes, for instance) the drive and host themselves are electrically and otherwise the same - these are merely methods of connection and there's no practical difference between them and your individual cable scenario:
Power remains connected while data is plugged/unplugged
- Asynchronous Signal Hot Plug / Removal: A signal cable is plugged / unplugged at
any time. Power to the Host/Device remains on since it is sourced through an alternate
mechanism, which is not associated with the signal cable. This applies to External
Single-Lane and Multilane Cabled applications.
Data is connected where power is not available
- Unpowered OS-Aware Hot Plug / Removal: This is defined as the insertion / removal of
a Device into / from a backplane connector (combined signal and power) that has power
shutdown. Prior to removal, the Host is placed into a quiescent state (not defined here)
and power is removed from the backplane connector to the Device. After insertion, the
backplane is powered; both the Device and Host initialize and then operate normally.
The mechanism for powering the backplane on/off and transitioning the Host into/out of
the “quiescent” state is not defined here. During OS-Aware events, the Host is powered.
This applies to “Short” and “Long” Backplane applications.
There are two other situations here which don't apply to this question. Read the spec for more.
However, they do provide the following warning in the specification:
NOTE: This does not imply transparent resumption of system-level operation since data may be
lost, the device may have to be re-discovered and initialized, etc. Regardless of the above
definitions, the removal of a device, which is still rotating, is not recommended and should be
prevented by the system designer.
In other words, the hot removal 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. If your OS and driver don't have a mechanism to allow you to turn off the drive before unplugging them, then you aren't providing adequate hot removal support, and should not perform hot removals on the system. This is tackled by manufacturers by providing locking or handled drive cages where the lock to remove them tells the OS to perform the drive shutdown, or pulling the handle out a short way does so. The user is then instructed to wait for notification that the drive can be removed (usually an LED on the drive carrier itself).