SATA hot swap

Ben Scott dragonhawk at gmail.com
Tue Jun 9 20:00:22 EDT 2009


  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.

  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.

-- Ben


More information about the gnhlug-discuss mailing list