Friday, October 15, 2010

Hot-swap SATA disks in FreeBSD

If you ever need to hot-swap a disk on a FreeBSD box, atacontrol(8) is your friend. Swap the disk, then use atacontrol list to retrieve the list of ATA channels on the system.

root@neutron:~-> atacontrol list
ATA channel 0:
Master: acd0 ATA/ATAPI revision 5
Slave: no device present
ATA channel 2:
Master: ad4 SATA revision 2.x
Slave: no device present
ATA channel 3:
Master: ad6 SATA revision 2.x
Slave: no device present
ATA channel 4:
Master: ad8 SATA revision 1.x
Slave: no device present
ATA channel 5:
Master: no device present
Slave: no device present


Find the appropriate channel, in this case ata5. Then simply perform a detach/attach operation on the channel and the disk should be found.

root@neutron:~-> atacontrol detach ata5
root@neutron:~-> atacontrol attach ata5
Master: ad10 SATA revision 2.x
Slave: no device present


This example was done on FreeBSD 8.1-RELEASE.