eSATA hot swap in Linux

I hoped that eSATA interface allows to attach and detach HDDs to Linux on the fly, and the system would notice the changes automatically. The reality was quote apposite, the system hung during experiments. Finally, after scanning internet knowledge, and trying to get commands like atacontrol or scsiadd working, I found the command for manual swap.

After a HDD is attached, ask Linux to re-scan the bus to find the HDD:

$ sudo sh -c 'echo "- - -" >/sys/class/scsi_host/host0/scan '

or without sudo:

# echo "- - -" >/sys/class/scsi_host/host0/scan

To detach the HDD (umount it first!) (in this case, the hdd is sdb):

$ sudo sh -c "echo 1 > /sys/block/sdb/device/delete "

or without sudo:

# echo 1 > /sys/block/sdb/device/delete

Well, I actually don't need hotswap, manual swap is ok for me. The problem is solved.

Categories: linux