

Unmount disk in linux driver#
If you're using some other sort of SATA controller, the driver might be confused by hotplugging. If you're using an AHCI controller, it should cope with devices being unplugged. When I do that with a drive in an eSATA enclosure, I can hear the drive's heads park themselves, so the kernel apparently tells the drive to prepare for power-down. That'll unregister the device from the kernel, so you know nothing's using it when you unplug it. If you want to be extra cautious, do echo 1 | sudo tee /sys/block/(whatever)/device/delete first. ( echo 1 | sudo tee /sys/block/(whatever)/device/delete)

I doubt whether is the correct way to do so, but I cannot find some proof against it either. Replace X with the appropriate number for your SATA/eSATA port. Some driver/chipset combinations do not properly handle hotplugging and need a warmplug command such as the following one: echo 0 - 0 > /sys/class/scsi_host/hostX/scan How the chipset and driver handles this is another question. not damaged if you insert/pull the plug). This will power the drive down allowing for it's removal w/o risk of voltage surge.ĭoes this mean that the disk caches are properly flushed and powered off thereafter?Īll SATA and eSATA hardware is physically able to be hotplugged (ie. (where X represents the device you wish to power off.
Unmount disk in linux software#
What then do you do on the software side before unplugging? Is it a simple "umount /dev/sd"?Īfter unmounting the device, to "power off" (or sleep) the unit: hdparm -Y /dev/sdX How can I safely remove the SATA disk from the system? This Phoronix forum thread has some suggestions: At other times, I have the very weird setup of connecting a SSD using a SATA-eSATA cable on my laptop while pulling power from a desktop.

I sometimes need to plug a disk into a disk bay.
