Solved How to reset SATA drive without reboot?

SOLUTION:

camcontrol devlist # to see bus number, eg "at scbus1 target 0 lun 0 (ada0,pass0)"
camcontrol reset 1 # change 1 to appropriate scbus number
camcontrol rescan 1 # change 1 to appropriate scbus number

---

I have a SATA drive that drops out when it hits a bad sector: /dev/ada0 still exists, but the drive itself just returns an error for everything (including detection by smartctl)

I had been power cycling the drive to get it back, but then discovered that a soft OS reboot (shutdown -r now) suffices. So the BIOS (or perhaps FreeBSD at boot) is commanding the drive to reset, without a hard power cycle.

tl;dr What FreeBSD commands can I use to reset the drive?

(I'm trying to image it, and it has thousands of reported pending sectors, so multiple restarts are not really an option. Thanks.)
 
Last edited:
A reset will not make errors or pending sectors magically disappear. Rewriting the drive may allow it to remap a spare sector to replace bad sectors with spares. Replace the drive if that doesn't work.
 
(I'm trying to image it, and it has thousands of reported pending sectors, so multiple restarts are not really an option. Thanks.)
Try sysutils/ddrescue, it can pick up where it left off. But you're probably need to be quick about it. Sounds like your drive is about to depart to silicon heaven permanently.
 
Maybe camcontrol(8), like camcontrol reset?
I did try that, along with various other things like rescan, stop, eject, but no luck.
After a break and fresh approach, I've discovered that I need to do reset then rescan - both commands, and in that specific order.

A reset will not make errors or pending sectors magically disappear. Rewriting the drive may allow it to remap a spare sector to replace bad sectors with spares. Replace the drive if that doesn't work.
Not trying to save the drive for use - I'm only interested in the data. :)

Try sysutils/ddrescue, it can pick up where it left off. But you're probably need to be quick about it. Sounds like your drive is about to depart to silicon heaven permanently.
I've been using recoverdisk(1) which looks to be a similar (built-in) utility, but the issue is that once the drive drops out it flags Every. Single. Sector. following as bad, because the drive literally refuses to respond to anything. Does ddrescue have the option to perform arbitrary commands when there's a failure?

EDIT: ddrescue's --verify-on-error option (renamed to --check-on-error in newer versions) will after an error try reading a known good sector, and abort if that also fails. This was exactly what I needed. Wrote a simple script to loop camcontrol reset+rescan, then ddrescue. It's been able to image 99.99% of the sectors to another drive.
 
but the issue is that once the drive drops out it flags Every. Single. Sector. following as bad
Had that happen with a drive once too. Got it working again by disconnecting and reconnecting, but eventually stopped working altogether. Wouldn't even initialize any more.
 
Back
Top