# USB ethernet fails to start automatically

## grant123

I'm having a problem with my USB ethernet interface not starting automatically in the default runlevel.  It tries but fails:

 * Bringing up interface enp0s20u2u2

 *   ERROR: interface enp0s20u2u2 does not exist

 *   Ensure that you have loaded the correct kernel module for your hardware

 * ERROR: net.enp0s20u2u2 failed to start

Once the system is booted, I can run 'rc' and it starts fine every time.  I have 5 identical laptops (with no built-in ethernet) set up this way and they all exhibit the problem.  I just upgraded to udev-212-r1 which I was hoping would fix the problem but it has not.  Everything comes up OK if I use rc_hotplug="net.*" because other services call on net.enp0s20u2u2 to start after it initially fails, but I'd rather not enable hotplug.

I worked on this in another thread here:

https://forums.gentoo.org/viewtopic-t-989698.html

but we hit a dead-end and I have a clearer picture of what's happening now so I thought I would start a more focused thread.Last edited by grant123 on Mon May 12, 2014 4:58 pm; edited 2 times in total

----------

## Hu

My first guess would be that your unpredictable interface names are not appearing in time, so at the time that net.enp0s20u2u2 is activated, the interface is still named eth0.  Later, udev renames it to enp0s20u2u2, after which starting it will succeed.  You could test this by modifying the net startup script to log the output of ip l prior to bringing up each interface.

----------

## grant123

Judging by what I've seen in the logs, I think you are 100% correct.  What can I do to fix this?

----------

## Jaglover

Add net.ifnames=0 to kernel command line or switch to eudev. You will have predictable nodes again.

----------

## NeddySeagoon

grant123,

Tell udev to leave the kernel assigned names alone.

Append net.ifnames=0 to your kernel line in grub.conf.

Jaglover wins by 2 min  :)

----------

## grant123

Can I fix this and keep the current naming behavior?

----------

## Jaglover

There are probably many ways to do that, one of them would be to bring it up in /etc/local.d.

----------

## grant123

But in the default runlevel there are several services which depend on the network.

----------

## NeddySeagoon

grant123,

You don't really want to for USB network interfaces. enp0s20u2u2 is named after the USB port your USB network interface is plugged into, so plug it into a different port and it will get a new name.

You can try to get USB networking up faster by building everything it needs into the kernel.

----------

## grant123

You mean instead of loading modules?  I actually don't load any modules that I know of.

I've gotten used to the new network names.  It is nice to be able to plug any USB network adapter into a particular USB port to give it the same name.

Am I out of luck?

----------

## NeddySeagoon

grant123,

The hotplug system will load modules for you.  What does 

```
lsmod
```

 show?

----------

## grant123

You fixed it!  I had forgotten that I had xhci_hcd built as a module because previously I had needed to periodically unload and reload it to get my USB port working again but that hasn't been necessary for awhile.  Thank you!

----------

## grant123

I spoke a little too soon.  My system which is configured as a router with two USB ethernet interfaces still suffers from the problem:

```
Cannot find device "enp0s20u2u1"

 *   ERROR: interface enp0s20u2u1 does not exist

 *   Ensure that you have loaded the correct kernel module for your hardware

 * ERROR: net.enp0s20u2u1 failed to start

 * Bringing up interface enp0s20u2u2

Cannot find device "enp0s20u2u2"

 *   ERROR: interface enp0s20u2u2 does not exist

 *   Ensure that you have loaded the correct kernel module for your hardware

 * ERROR: net.enp0s20u2u2 failed to start
```

```
# lsmod

Module                  Size  Used by

#
```

The ethernet interfaces later come up fine if hotplug is enabled.  What could it be?

----------

## khayyam

 *grant123 wrote:*   

> The ethernet interfaces later come up fine if hotplug is enabled.  What could it be?

 

grant123 ... udev.

 *Arch Udev Wiki wrote:*   

> Udev loads kernel modules by utilizing coding parallelism to provide a potential performance advantage versus loading these modules serially. The modules are therefore loaded asynchronously. The inherent disadvantage of this method is that udev does not always load modules in the same order on each boot.

 

... in your case udev is loading the drivers for the usb ethernet cards, but as it is "parallelised" it doesn't pause to allow that to happen, the entire boot process continues. At some point it tries to rename the devices but by this time the boot process has already arrived at "default" and the network interfaces are brought up, except those names don't exist (yet). So, if you want this not to happen, either disable "(non-)predictable device names" or build the drivers for these network devices into the kernel.

best ... khay

----------

## grant123

The drivers are actually built into the kernel.  I don't have any modules loaded at all:

```
# lsmod 

Module                  Size  Used by 

#
```

I'm running 5 hardware-identical laptops like this but one is still struggling with the issue:

```
Cannot find device "enp0s20u2u1" 

 *   ERROR: interface enp0s20u2u1 does not exist 

 *   Ensure that you have loaded the correct kernel module for your hardware 

 * ERROR: net.enp0s20u2u1 failed to start 

 * Bringing up interface enp0s20u2u2 

Cannot find device "enp0s20u2u2" 

 *   ERROR: interface enp0s20u2u2 does not exist 

 *   Ensure that you have loaded the correct kernel module for your hardware 

 * ERROR: net.enp0s20u2u2 failed to start
```

----------

## khayyam

 *grant123 wrote:*   

> The drivers are actually built into the kernel. I don't have any modules loaded at all

 

grant123 ... oh, in which case the ghost in the machine is parallelised to reach causal unpredictability :)

 *grant123 wrote:*   

> I'm running 5 hardware-identical laptops like this but one is still struggling with the issue

 

Not "hardware-identical" in that all have 2x USB ethernet devices I assume?

best ... khay

----------

## grant123

 *Quote:*   

> Not "hardware-identical" in that all have 2x USB ethernet devices I assume?

 

No but another system does have two of them and works fine.  They're all Dell XPS 13.

----------

## khayyam

grant123 ... not sure this will work but you might try adding a delay ...

/etc/conf.d/net

```
preup() {

   if [ ! -d /sys/class/net/${IFACE} ]; then

     timeout="5"

     while { [ $timeout -gt 0 ] && [ ! -d /sys/class/net/${IFACE} ]; }; do

     timeout=$((timeout - 1)) ; sleep 1

   done

return 0

}
```

... thats *untested* so it may not work as expected, but hopefully it does provide a small delay, at least enough for the rename.

HTH & best ... khay

----------

## grant123

I ended up adding the delay with rootdelay=5 in the kernel command and everything works now.  Thank you for your help!

----------

