Boot processing order: USB disk, before RAID?

I probably am doing something strange that is a (minor?) problem and I wonder if there is a fix (maybe adding a script to the init scripts).

I have created a RAID1 (mirror) set with the uSD card and a partition of a USB attached SATA SSD drive. The M64 boots off the uSD card (that is where uBoot is installed). The boot process starts the RAID array in degraded mode, because the USB attached SATA SSD drive is not seen until a little later in the boot process. Is there a way to get the USB Disk settled earlier in the boot process?

Here is the relevant parts of dmesg:

[   34.412844] usb 3-1.4: new full-speed USB device number 13 using ehci-platform                                             
[   34.642763] usb 3-1.4: New USB device found, idVendor=0a05, idProduct=7211, bcdDevice= 1.00                                
[   34.642772] usb 3-1.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0                                            
[   34.642778] usb 3-1.4: Product: USB2.0 HUB                                                                                 [   34.643534] hub 3-1.4:1.0: USB hub found                                                                                   
[   34.643762] hub 3-1.4:1.0: 4 ports detected                                                                                
[   34.985541] usb 3-1.4: USB disconnect, device number 13                                                                    [   35.004949] usb 3-1.4-port2: attempt power cycle                                                                           
[   35.442593] md/raid1:md0: active with 1 out of 2 mirrors                                                                   [   35.442692] md0: detected capacity change from 0 to 31591563264                                                            
[   35.504867] usb 3-1.4: new full-speed USB device number 18 using ehci-platform                                             
[   35.722922] usb 3-1.4: New USB device found, idVendor=0a05, idProduct=7211, bcdDevice= 1.00                                
[   35.722936] usb 3-1.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0                                            
[   35.722943] usb 3-1.4: Product: USB2.0 HUB                                                                                 
[   35.723753] hub 3-1.4:1.0: USB hub found                                                                                   [   35.723974] hub 3-1.4:1.0: 4 ports detected                                                                                

[   42.609213] usb 3-1.4.2: new full-speed USB device number 44 using ehci-platform                                           
[   42.816624] usb 3-1.4.2: not running at top speed; connect to a high speed hub                                             [   42.818032] usb 3-1.4.2: New USB device found, idVendor=152d, idProduct=2329, bcdDevice= 1.00                              
[   42.818038] usb 3-1.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=5                                          
[   42.818043] usb 3-1.4.2: Product: USB to ATA/ATAPI bridge                                                                  [   42.818047] usb 3-1.4.2: Manufacturer: JMicron                                                                             
[   42.818051] usb 3-1.4.2: SerialNumber: 153510A117BB                                                                        [   42.819280] usb-storage 3-1.4.2:1.0: USB Mass Storage device detected                                                      
[   42.819559] usb-storage 3-1.4.2:1.0: Quirks match for vid 152d pid 2329: 8020                                              
[   42.819639] scsi host0: usb-storage 3-1.4.2:1.0                                                                            

[   43.887741] scsi 0:0:0:0: Direct-Access     Micron_M 500DC_MTFDDAK480 0144 PQ: 0 ANSI: 2 CCS                               
[   43.888506] sd 0:0:0:0: Attached scsi generic sg0 type 0                                                                   
[   43.889590] sd 0:0:0:0: [sda] 937703088 512-byte logical blocks: (480 GB/447 GiB)                                          [   43.890820] sd 0:0:0:0: [sda] Write Protect is off                                                                         
[   43.890831] sd 0:0:0:0: [sda] Mode Sense: 28 00 00 00                                                                      
[   43.892124] sd 0:0:0:0: [sda] No Caching mode page found                                                                   [   43.902077] sd 0:0:0:0: [sda] Assuming drive cache: write through                                                          
[   43.954505]  sda: sda1 sda2                                                                                                
[   44.071996] sd 0:0:0:0: [sda] Attached SCSI disk                                                                           

It is clear that the USB hub is itself seen early in the boot process, but it appears that detecting the attached devices is defered for some reason. Is there some trick to fix that? I am able to hot add the partition later (ala mdadm /dev/md0 --add /dev/sda1), but I would rather not have to do that.

Make sure this https://github.com/armbian/build/blob/master/config/kernel/linux-sunxi-current.config#L5262 is set to Y

It is in all three of the kernels I have – the stock 5.7.15-sunxi64, and both custom (5.7.15) kernels I built from the 5.7.15-sunxi64 sources.

Looking closely at the dmesg log, there seems to be some issue with the USB hub – it is disconnecting and reconnecting repeatedly.

That’s another story. USB was simply not designed for that kind of usage. For experimenting perhaps - connection is not a very reliable and one should avoid to attach permanent disk storage to it … just look around. You will not find any storage expert that will recommend you such setup. All will tell you not to use USB storage in first place.

Native SATA or PCI2SATA. Also there you have to avoid SATA multipliers which can fu* things up …

Unfortunately, there are no SATA ports on the M64…

I know, just saying that storage options on those board are so-so. Lots of USB2SATA converters are also garbage …

You need some luck.

I expect my problem is the “cheap” USB hub. I can probably get a better one.