Hot Swap your SATA? Easy!

May 3, 2011 00:00 · 100 words · 1 minute read Linux

  1. We should flush all caches to disk
# sync
  1. We should unmount all mounted partitions on the disk
# umount /dev/sdc1
# umount /dev/sdc2
# umount /dev/sdc3
  1. Ask the controller to delete the device
# echo 1 >/sys/block/sdc/device/delete

Voilà! We can safely detach our hard disk from the system.

After adding a new hard disk, we should ask the SATA controller to rescan the bus

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

NOTE: 1) The SATA controller and/or chipset should support a hot-swap operation. Good news - usually new controllers and chipsets support it! 2) The Linux kernel should be 2.6.x+