Hot Swapping SATA drive?

Polytropon freebsd at
Wed May 15 00:10:44 UTC 2013

On Tue, 14 May 2013 16:34:11 -0700, Ronald F. Guilmette wrote:
> In message <20130514144721.aa321c25.freebsd at>, 
> Polytropon <freebsd at> wrote:
> >I've been using SCSI "hot swap" devices for many years, and
> >they usually required a re-scan of the bus. The same often
> >works for USB-connected devices which also use CAM, and maybe
> >SATA and eSATA also support it today?
> OK, so what command should I use when I plug a drive in?  Would that be
> "camcontrol rescan foo" where "foo" is something like /dev/ada0?

No. You use the typical "SCSI-like device notation", bus:unit:lun,
for example 0:1:0, or "all" for all buses and devices.

> I'm
> guessing that that can't be correct, because ada0 is an actual drive.
> So what is the "device id" for the bus itself?

With "camcontrol devlist", you can get a list that will show
you what devices have been recognized and how the bus:unit:lun
corresponds to the device files.


$ camcontrol devlist
<HL-DT-ST DVDRAM GSA-H42N RL00>    at scbus0 target 0 lun 0 (pass0,cd0)
<HL-DT-ST DVD-ROM GDR8163B 0L30>   at scbus0 target 1 lun 0 (pass1,cd1)
<Generic Flash HS-CF 4.55>         at scbus3 target 0 lun 0 (pass2,da0)
<Generic Flash HS-MS/SD 4.55>      at scbus3 target 0 lun 1 (pass3,da1)
<Generic Flash HS-SM 4.55>         at scbus3 target 0 lun 2 (pass4,da2)
<WDC WD15 EARS-00MVWB0 >           at scbus4 target 0 lun 0 (pass5,da3)

The disk you're attaching will probably be something like the
entries for the USB disk (last line).

> >Again, it may be nice (to the system) to detach the ATA device
> >from the bus; see "man atacontrol" (and "man camcontrol" in
> >comparison) for the proper command to do this. From the "electrical
> >point of view", there should be no problem.
> I am a firm believer in being nice.  I just need to know the proper
> command.   Would that be "camcontrol stop foo" ?

Yes. You can use the "start" and "stop" commands like the "attach"
and "detach" commands for atacontrol. Additionally, you can use
"tur" for "test (if) unit (is) ready", and "readcap" to print the
capabilities. Also "reset" and "rescan" are helpful.

See "man camcontrol" for details about what those commands do,
and how to properly call them. In most cases,

	# camcontrol <command> <bus:unit:lun | all>

will be the correct form.

> >The only thing that might be worth looking at in the CMOS setup
> >would be the "method" of the driver, making the device come up
> >as da0 (for example) or ada0, depending if EHCI or XHCI can be
> >selected.
> Ummm... my new little SATA plug-in bay is strictly SATA... not eSATA,
> and *definitely* not USB, so I think that EHCI and/or XHCI are probably
> irrelevant.  Those are strictly USB things, no?

I'm not fully sure about that, but I assume you're right, if
the manufacturer has properly glued the SATA ports onto the
mainboard instead of creating some strange abomination of
a "SATA through USB something". :-)

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list