There are times when devices fail, or lock up.
In some of those cases it could be a SATA hard disk locking up (perhaps it is developing bad blocks, perhaps it just had a power failure due to a bad connector and got left in an undefined state).
Thankfully, Linux offers you vast control over the hardware.
To reset a SATA device, start by figuring out which logical port the drive is connected to:
readlink /sys/block/sdX
../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
Notice the host1 in the returned line above. That’s the controller that needs rescanned.
Force disconnect the device:
echo 1 > /sys/block/sdX/device/delete
Trigger rescan:
echo "- - -" > /sys/class/scsi_host/host1/scan
This should do it. If the device is still alive, it should return to working condition.
You can monitor dmesg for status information.
Excelent, that solved my problem! Thank you
Excelent! I wonder if it could be possible to remount at 3bps, half speed, for the cases where the problem is bus/card
I did this to a working RAID member which had dropped to 3gbps due to errors, and it disappeared as /dev/sdd and came back as /dev/sdo! Mdadm failed out the drive, I re-added it to the array and now it’s rebuilding… [facepalm.gif] But hey, at least it did come back and it even came back in 6gbps mode!
The kernel kind of remembers device IDs and will assign the next available one when new hardware pops up. Reaching all the way to sdo could be an indication that a device (or several) vanish intermittently, getting new IDs assigned on each reconnect. You might want to dig through the logs to see if sde,f,g…….n were ever assigned and whom to.
Excelent low level article.
Works perfectly 🙂