Hotswap Disks are great, we can replace them seamlessly with no downtime to the host computer. Applications on the computer keep on running non-stop.
1. Hotswap SATA
Steps to perform BEFORE pulling hotswap SATA disks out:
- unmount
- sync (unmount takes care of this but it doesn’t hurt to run it)
- hdparm -Y /dev/sdX (put in sleep mode)
- echo offline > /sys/block/sdX/device/state (prevent any access)
- echo 1 > /sys/block/sdX/device/delete (delete associated driver)
- dmesg (to check that the drive is stopped)
- wait at least a minute for the disk to spin down
- pull the drive out slowly
Notes:
- SATA mode set to AHCI
- Enable any hot-swap support in the BIOS
- All steps above should be taken in sequence
- Waiting for spin down to finish before removing the disk is important, step 5 will also spin the disk down if step 3 does not perform the spin down.
2. Hotswap USB
- unmount
- sync
- echo 'offline' > /sys/block/sdX/device/state
- echo '1' > /sys/block/sdX/device/delete
- dmesg (to check that the drive is stopped)
- wait at least a minute for the disk to spin down
- unplug the drive slowly
Some other options:
- eject /dev/sdX
- udisksctl power-off -b /dev/sdX