I'm using a SATA hot-swap bay and I have in BIOS this particular port configured specifically for "Hot-Swap".
This bay has convenient "POWER ON/OFF" button, so no interruptions during plugging-in/out cables occurs.
When I'm turning a drive ON, I'm immediately getting some kernel errors, before it mounts:
[1263413.036674] ata6: exception Emask 0x10 SAct 0x0 SErr 0x4040000 action 0xe frozen
[1263413.036680] ata6: irq_stat 0x00000040, connection status changed
[1263413.036683] ata6: SError: { CommWake DevExch }
[1263413.036698] ata6: hard resetting link
[1263418.796687] ata6: link is slow to respond, please be patient (ready=0)
[1263423.052529] ata6: COMRESET failed (errno=-16)
[1263423.052547] ata6: hard resetting link
[1263428.032390] ata6: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[1263428.032836] ACPI Error: [DSSP] Namespace lookup failure, AE_NOT_FOUND (20150930/psargs-359)
[1263428.032846] ACPI Error: Method parse/execution failed [\_SB.PCI0.SAT0.SPT5._GTF] (Node ffff88040e0c5780), AE_NOT_FOUND (20150930/psparse-542)
[1263428.159582] ata6.00: ATA-9: HGST HDN726040ALE614, APGNW7JH, max UDMA/133
[1263428.159588] ata6.00: 7814037168 sectors, multi 0: LBA48 NCQ (depth 31/32), AA
[1263428.161980] ACPI Error: [DSSP] Namespace lookup failure, AE_NOT_FOUND (20150930/psargs-359)
[1263428.161988] ACPI Error: Method parse/execution failed [\_SB.PCI0.SAT0.SPT5._GTF] (Node ffff88040e0c5780), AE_NOT_FOUND (20150930/psparse-542)
[1263428.164472] ata6.00: configured for UDMA/133
[1263428.164483] ata6: EH complete
[1263428.164650] scsi 5:0:0:0: Direct-Access ATA HGST HDN726040AL W7JH PQ: 0 ANSI: 5
[1263428.165064] sd 5:0:0:0: Attached scsi generic sg4 type 0
[1263428.165502] sd 5:0:0:0: [sdd] 7814037168 512-byte logical blocks: (4.00 TB/3.64 TiB)
[1263428.165508] sd 5:0:0:0: [sdd] 4096-byte physical blocks
[1263428.165582] sd 5:0:0:0: [sdd] Write Protect is off
[1263428.165587] sd 5:0:0:0: [sdd] Mode Sense: 00 3a 00 00
[1263428.165618] sd 5:0:0:0: [sdd] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[1263428.213630] sdd: sdd1
[1263428.214062] sd 5:0:0:0: [sdd] Attached SCSI disk
[1263534.534238] EXT4-fs (dm-5): mounted filesystem with ordered data mode. Opts: (null)
And when I'm unmounting it (like any other drive) and then turning the bay OFF, I'm getting more weird output from kernel (last parts occurs about 10 seconds after turning OFF - system still thinks that drive is connected for a while until it timeouts):
[1263588.964461] ata6: exception Emask 0x10 SAct 0x0 SErr 0x4090000 action 0xe frozen
[1263588.964467] ata6: irq_stat 0x00400040, connection status changed
[1263588.964478] ata6: SError: { PHYRdyChg 10B8B DevExch }
[1263588.964483] ata6: hard resetting link
[1263589.687000] ata6: SATA link down (SStatus 0 SControl 300)
[1263594.686806] ata6: hard resetting link
[1263595.006827] ata6: SATA link down (SStatus 0 SControl 300)
[1263595.006837] ata6: limiting SATA link speed to 1.5 Gbps
[1263600.006678] ata6: hard resetting link
[1263600.330626] ata6: SATA link down (SStatus 0 SControl 310)
[1263600.330634] ata6.00: disabled
[1263600.330645] ata6: EH complete
[1263600.330653] ata6.00: detaching (SCSI 5:0:0:0)
[1263600.334909] sd 5:0:0:0: [sdd] Synchronizing SCSI cache
[1263600.334943] sd 5:0:0:0: [sdd] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[1263600.334946] sd 5:0:0:0: [sdd] Stopping disk
[1263600.334955] sd 5:0:0:0: [sdd] Start/Stop Unit failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
However drive works fine, no problems or data errors whatsoever, but I'm getting a feeling that it might have been done in a better/safer way, without such timeout-ing.
Is there a more proper way for disconnecting hot-swap SATA ?
I've been trying sending a udisksctl power-off -b /dev/sdd command, but while it works fine for USB drives, it does not do anything with SATA. Best thing I figured is to suspend a drive, before powering OFF, but kernel output is this same anyway.
$ uname -a
Linux dev 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux