# External device (hard drive array) not detected at boot



## jcd (Dec 29, 2014)

Hi everyone,

I have an external hard drive array that I would like to have mounted at boot.  The problem is that the device is not detected by the kernel until it is unplugged and plugged back into the USB port.

So I ask for you support to understand why the computer won't detect a USB device at boot/reboot?

For reference:

Compulab fit-PC3 system running FreeBSD 10.0-RELEASE-p12
Hard drive array: Addonics 1U Rack R1ESU3F configured in RAID 5 mode 

Hard drive array plugged into a USB 3.0 port using a USB 3.0 cable.
The message after unplugging the array and plugging it back again:


```
da0 at umass-sim0 bus 0 scbus5 target 0 lun 0
da0: <SSI H/W RAID5 > Fixed Direct Access SCSI-5 device
da0: Serial Number E84BB675FFFF
da0: 400.000MB/s transfers
da0: 11446176MB (23441768448 512 byte sectors: 255H 63S/T 1459182C)
da0: quirks=0x2<NO_6_BYTE>
```

No [FONT=Courier New]da0[/FONT] related events are logged in [FONT=Courier New]/var/log/messages[/FONT] during boot.

Thanks everyone.

Juan


----------



## SirDice (Dec 30, 2014)

What kernel are you using? GENERIC should have support for umass(4). Are there any messages when you unplug the drive (before it works)? Does it work if you plug it in _after_ the system is fully booted, i.e. not connected during boot?


----------



## jcd (Dec 30, 2014)

SirDice,

The Kernel is indeed GENERIC, and there are no messages when unplugging the drive before it works.

It does work if plugged after the system is fully booted.

Thanks for your help.


----------



## protocelt (Dec 30, 2014)

If the device works correctly after re-plugging after boot, you could try adding a larger delay for better detection by increasing one or both of the following sysctl knobs:

```
kern.cam.boot_delay=10000
kern.cam.scsi_delay=10000
```
These would be added to your /boot/loader.conf file.

This will increase boot time. If this works but boot time is not acceptable with the above numbers, try lowering  them until the device is no longer detected again.


----------



## jcd (Dec 31, 2014)

Thanks protocelt.

I added the suggested knobs but the device remains undetected.

Further researching on those knobs, some people mention to use `debug.acpi.disabled`.  So I added it to /boot/loader.conf as follows:

```
kern.cam.boot_delay="10000"
kern.cam.scsi_delay="10000"
debug.acpi.disabled="hostres"
```
 but the device remains undetected.

Also tried by having only `debug.acpi.disabled` on loader.conf, same results.

Further ideas?

I'd like to get a solid understanding of the detailed USB process, both from a theoretical and a practical perspective.  Chapter 13 of the FreeBSD Handbook includes some information, but I would like to go deeper, to understand things like:

What happens during the boot process of FreeBSD that makes a USB device be detected (or not).  What happens after it?
USB debug tools under FreeBSD.
Any references will be appreciated.

Cheers!


----------



## chrbr (Jan 1, 2015)

Dear jcd,


jcd said:


> I'd like to get a solid understanding of the detailed USB process


I think https://www.freebsd.org/doc/en/books/arch-handbook/usb.html is a good starting point.


----------



## protocelt (Jan 1, 2015)

jcd said:


> Thanks protocelt.
> 
> I added the suggested knobs but the device remains undetected.
> 
> ...


The Addonics 1U Rack R1ESU3F unit looks like it includes a eSATA connection. Is it an option for you at least in the mean time to try connecting the unit that way? It might be a bit more reliable. From my limited understanding USB 3.0 on FreeBSD may still have some quirks here and there although that may have changed recently.

In regards to the specifics of USB on FreeBSD from a theoretical perspective, that's quite a bit above my own knowledge level unfortunately. You may find this book to be of interest. I haven't picked it up yet but I hear it's quite good. Should you not get any more answers here you could always ask this question on the FreeBSD mailing lists as well. Specifically this one if you haven't already.

Regards


----------



## jcd (Jan 1, 2015)

chrbr said:


> Dear jcd,
> 
> I think https://www.freebsd.org/doc/en/books/arch-handbook/usb.html is a good starting point.



Thanks for your suggestion chbr, that is precisely the chapter on USB Devices of the FreeBSD Handbook (it used to be chapter 13, now chapter 18).

There is a section on the FreeBSD Developers' Handbook dedicated to USB devices and I believe the information in both Handbooks is exactly the same.  And FreeBSD Device Drivers by Joseph King contains a full chapter on USB Drivers.

Yet none of those explain how FreeBSD manages USB connections.  Thinks like:

Which process/daemon is in charge of detecting new USB connections?  

Are the knob delays suggested by protocetl related to that process?  How?
Ultimately, what happens when my device (or any other device for that matter) is plugged in, something that I guess is not occuring when the same device is plugged before booting the operating system?
Even utilities like camcontrol(8) and usbconfig(8) fail to see the device if plugged before booting,  why?

I might take a look at "The Design and Implementation of the FreeBSD Operating System" (thanks protocelt for this reference).  "The Design and Implementation of the 4.4BSD Operating System", available online, might be a good alternative for those under tight budget (like myself ).

I appreciate everybody's patience and contributions.


----------



## jcd (Jan 1, 2015)

protocelt said:


> The Addonics 1U Rack R1ESU3F unit looks like it includes a eSATA connection. Is it an option for you at least in the mean time to try connecting the unit that way? It might be a bit more reliable. From my limited understanding USB 3.0 on FreeBSD may still have some quirks here and there although that may have changed recently.
> 
> In regards to the specifics of USB on FreeBSD from a theoretical perspective, that's quite a bit above my own knowledge level unfortunately. You may find this book to be of interest. I haven't picked it up yet but I hear it's quite good. Should you not get any more answers here you could always ask this question on the FreeBSD mailing lists as well. Specifically this one if you haven't already.
> 
> Regards



I might give eSATA a try for the time being (will let you know how it works), and wait a few more days before asking on the suggested mailing list. 

Best wishes for everyone on this new day, new cycle.


----------



## jcd (Jan 2, 2015)

Hi again everyone,

Everything works nicely after connecting the driver array into the eSATA port, it gets beautifully detected and mounted at boot.

Still, if anyone has suggestions for the USB port, I would love to try it.

Best.


----------



## ralphbsz (Jan 4, 2015)

jcd said:


> Still, if anyone has suggestions for the USB port, I would love to try it.


My suggestion: abandon it.  Running serious storage over USB is just a bad idea.  It's just not reliable enough.  I think the basic reason is that USB is internally just too complicated, with too many device types, too many drivers, too many initiator implementations, and standardization that happened too late.  I would stick to SATA or a SCSI protocol for connecting storage devices.

For occasional use (a backup disk that you connect to your laptop once a week, or transferring pictures from a digital camera SD card), that's fine, if it fails not much is lost.

Clearly, my suggestion doesn't help your particular problem.  I think your problem would require serious debugging: Start reading the kernel source code.  Above you asked "which process/daemon is in charge of detecting new USB connections".  Once you find the piece of code that is in charge, add a few print statements or similar debugging hooks to it, recompile, and reboot.  Obviously, this suggestion is impractical other than for developers.


----------



## jcd (Jan 8, 2015)

Thanks for your suggestion ralphbsz.  

It is my first experience installing an external USB device for serious storage, and thanks to people's comments on this thread, I went on and read about the intrinsic characteristics of both of USB and eSATA.  

Now I understand why eSATA is a better option for the RAID array and will leave the device running through eSATA.

If I happen to have some time, which I doubt, I still would like to test and understand why the device is not being recognized by FreeBSD 10.0 at boot time.  Just for the sake of learning and contributing to the growth of project.


----------



## CraigW (Nov 25, 2018)

This is an old thread, 
but I recently (12 RC2) solved a similar problem with an old USB2 external cdrom connected via USB3 port.

It would only detect upon a fresh unplug/replug scenario.

I spent considerable time in the BIOS monkeying with and disabling most of the XHCI options (ie handoff, pre-OS,  and a few other stream options).

The cdrom drive now shows both within the BIOS and upon boot without being unplugged and replugged.

dmesg shows USB2 attached to EHCI, and USB3 attached to XHCI even with XHCI options disabled in the BIOS.

_Maybe that will be helpful to someone else._


----------

