And how to increase the maximum number of usb devices

hubkernelusbusb-flash-driveusb-storage

I'm wondering what is the maximum number of USB devices the Linux kernel can manage?
Does this depend on the root-Hub or something else, too?

Is there a way to increase this maximum number?

I need to do this, because I've ran into problems while trying to write to a large amount of USB sticks. To do this, I have a setup as follows:

There is 1 computer running Ubuntu Linux, with 3 (active) HUBs attached to 3 USB ports of this machine.
All of those three HUBs are 7 port HUBs. To 6 of those 7 ports, more HUBs are attached.
This gives me the number of 3 * 6 = 18 HUBs in the "second" layer.
Each of these HUBs is an active 7 port HUB, too.
There is a USB stick attached to every port of those second layer HUBs.
In total I have 126 USB Sticks connected to the computer.

I have a script that searches for all USB disk devices (through listing /dev/disk/by-path/ ). Each of the USB disk devices is then first partitioned, written to using cp and then made bootable using syslinux. This is NOT done in parallel!

The problem:
I only get 105 USB disk devices using

ls -la /dev/disk/by-path | grep usb | grep -v part | wc -l

The LEDs of the sticks in 3 rows (one row corresponds to one HUB in the second layer) are off, too.

How do I get all of those sticks to work? (Or possibly even more?)

Best Answer

It's by standard as explained here: https://en.wikipedia.org/wiki/USB_device#System_design

You can't have more than 127 devices (hub inclusive) connected to a single host controller.

Now: the host controller+3 hub (1st layer)+18 hub (2nd layer) = 22 devices that DON'T appear as disk devices.

127 minus these 22 USB devices = 105 devices that can be managed by the kernel as disks.

127 devices is a hard limit of the USB protocol (see here: http://www.beyondlogic.org/usbnutshell/usb3.shtml#USBProtocols) because the ADDR address field is seven bit long.

So by software there is no way to increase it. Maybe you can try with more than a host controller interface, or change topology by reducing the number of hubs (thus increasing the number of disks seen by the system).

Related Question