Hot Swap your SATA? Easy!

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

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

Whoa-la! We can safely detach our hard disk from the system.

After adding new hard-drive, we should ask SATA-controller to rescan the bus

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

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