SATA hot swap
Jarod Wilson
jarod at wilsonet.com
Tue Jun 9 20:50:04 EDT 2009
On 06/09/2009 08:00 PM, Ben Scott wrote:
> What's the "right" way to do hotswap (hotplug) with SATA under Linux?
>
> Assume a recent kernel and SATA chipset. In my current case, it's
> SysRescueCD 1.1.6 with kernel 2.6.27.19, on an Intel DG35EC
> motherboard with 82801HB ICH8 SATA controller.
>
> The hard disks are mounted in removable carriers, and have a switch
> which cuts power to the drive when disengaging, so that much is good.
>
> I know enough to exit software, dismount the filesystem(s), and call
> sync(8) first. There's no RAID involved in this situation, although
> if there's special knowledge around that, it would be good to know for
> future reference. Right now, though, I'm just going to be
> connecting/disconnecting quite a few hard disks in a row. It would be
> better if I didn't have to reboot the computer after each.
>
> I've found conflicting information on the web. Some say it requires
> particular SATA chipset support; others say it will work with anything
> that uses AHCI.
They're only semi-conflicting... A number of SATA chipsets have their
own sata_foo driver, and it does require driver-level support, but most
recent chipsets are all AHCI-compliant, and simply use the ahci (or is
it sata_ahci?) driver, which does have the necessary support in it.
(Nb: because ahci is so common now, Fedora kernels have the ahci driver
as built-in, rather than modular).
> Playing around, I found this sequence seems to work:
>
> [dismount filesystems]
> sync
> sg_start --stop /dev/sda
> [physically power down and remove disk]
> [insert new disk]
> rescan-scsi-bus
> [do stuff]
> [lather, rinse, repeat]
>
> But since I basically just pulled that out of thick ear, I'm worried
> it might be causing problems I'm not realizing.
Eh. It should more or less Just Work(tm) if you simply pull the disk and
re-insert a new one -- that's what I do with my eSATA disks and the disk
in my ThinkPad UltraBay tray, and when you get down to it, they're
really no different than an internal SATA disk or one in a carrier.
Well, the UltraBay thing does some acpi magic to make sure things
disconnect cleanly, but with eSATA, its really pretty much 100%
analogous: sync, unmount, power off, yank connector. I've never had to
bother with rescanning the bus on insert either. Note that the 'eSATA'
interface on my workstation is just a bracket that ultimately plugs into
a (drumroll) onboard ICH7 SATA controller.
Of course, some SATA chipsets (and/or drivers) behave better than
others, but Intel's ICH stuff tends to be pretty solid in my experience.
YMMV with other chipsets.
--jarod
More information about the gnhlug-discuss
mailing list