10

I've got a laptop with 2 USB 2.0 and 1 USB 3.0 ports and I would like to know how many USB hard drives I could plug into it. Is there a hard limit in the Linux kernel?

On the performance side, what is the speed shared across the drives plugged into the port?

1
  • 1
    My dad loves his novelty USB devices. I'll get him some more for his birthday and let you know when he reaches the limit :D
    – Greg
    Jun 4, 2011 at 14:32

2 Answers 2

14

Theoretically you can have up to 127 devices connected to one host PC but there are practical power and data bandwidth limitations that would prevent that. These 127 devices can be arranged in a tiered network of hubs up to seven levels, counting the PC host as level 1 and the farthest device as level 7. The PC supplies 5 units of power to a hub. Each unit is 100 mA and each port requires a minimum of 1 unit. The hub itself consumes one, leaving 4 units for up to 4 ports. So you will never find a bus-powered hub with more than four ports.

Bus-powered hubs have a further limitation. Since each port has only a single unit of power, they can only connect downstream to a single device. You cannot connect them to another hub for expansion because that hub requires an additional 5 units. And not all devices can run off a single unit. A low-power device like a mouse will work, but a high power device can claim up to 5 units. High power USB devices will only work when plugged directly into a PC host or a self-powered hub that can supply 5 units to the port.

When you connect a device, the PC queries the device for its capabilities and requirements. So, for example, the PC knows that it is connected to a 4-port bus-powered hub which means that each port can only drive one unit. If you try to plug a high power device into that hub, the OS will throw up an error message and refuse to enable the device.

Bus-powered hubs are generally a bad idea because of these limitations and are intended mainly for mobile, not desktop use.

On the other hand, if the devices that are plugged into the port are themselves self-powered, then they may not need more then one unit from the hub. For example external disk drives have their own power so should work okay on a bus-powered hub.

A self-powered hub will be able to supply 5 units to each port, allowing high-power devices and further levels of hubs. So you could plug in one 7-port self-powered hub and then seven more 7-port hubs into that, giving you 49 available ports at just the fourth tier.

Some self-powered hubs will allow you to use them also in bus-powered mode, but if you try to plug in too many devices, the OS will give you an error message.

Most hub controller chips have 4 ports so you commonly see 4-port hubs. When they want to build a bigger hub, they just use two 4-port chips. But they have to daisy chain them with the first chip connected to the host and the second connected to one of the downstream ports on the first chip. This leaves only seven ports left for the user, three on the first chip and four on the second -- hence the common 7-port hub.

USB is plug-and-play in the sense you don't have to know any of this stuff when you connect things up. The OS keeps track of the power budget of each hub and device, will tell you if the connection will not work, and that you need to use a self-powered port.

edit: USB packets look like this:

Token:
Packet ID: 8 bits
Address: 7 bits
Endpoint: 4 bits
CRC: 5 bits

Start of frame:
Packet ID: 8 bits
Frame Number: 11 bits
CRC: 5 bits

Data Packet:
Packet ID: 8 bits
Data: 0-1023 bytes
CRC: 16 bits

Handshake:
Packet ID: 8 bits

Since the address is only 7 bits, you can only have 128 devices on the entire bus (with 7 bits that can each be on and off, there are only 128 total different combinations of bits possible). This includes your computer, so that leaves 127 other things you can attach to it.

9
  • 1
    @crazy2be keep in mind that while you are allowed 127 devices per controller, your pc will be unlikely to provide enough current to power 127 hardrives. If each drive has its own power supply it should be fine but don't expect a laptop to source so much power.
    – crasic
    Jun 4, 2011 at 18:04
  • 127 usb sticks is possible. 128 hard disc? Don't think so :D
    – Rinzwind
    Jun 4, 2011 at 18:06
  • how about data transfer? If I have 1 hard-drive at X GBps, would an 8 port replicator transfer to X/8 to each hard-drive? And X/127 in the max configuration?
    – 719016
    Jun 4, 2011 at 21:49
  • From personal experience, my webcam will only work if connected directly to my PC's USB ports. It wouldn't work connected to a powered hub. That would imply to me that you will run into bandwidth limitations before running into a number of devices limit.
    – fragos
    Jun 4, 2011 at 22:51
  • I can not find a lot of information about that but this will be dealt with by the OS itself: the OS will probably finish some tasks with nearly max speed and put the others on hold until these tasks finish (the length and quality of the usb cable comes in play too).
    – Rinzwind
    Jun 5, 2011 at 6:58
2

So, you will find out that with USB3 chipsets, you will actually hit a limit at 30 devices or so, due to a hard 32 device limit (really 96 endpoint limit) on USB3 chipsets.

I dealt with this problem too and it took me a while to find the real problem and solutions. I wrote a blog post about it.

Basically, it boils down to these things

  1. There is a 96 endpoint limit with USB3 (which translates to 32 devices only)
  2. You lose further endpoints due to hubs, using a USB2 cable to a USB3 hub gives you a few slots back
  3. More generally you should disable USB3 if you can do without it (remove the USB3 kernel driver, or easier if you can, disable USB3 in your bios). Using a USB3 chip in USB2 mode does not help, you have to disable the USB3 so that your motherboard reroutes the port to a USB2 controller that doesn't have that endpoint limit
  4. if you cannot disable USB3, get a USB2 only PCIe card and that one will truly give you 120 devices or so.

Further resources:

1
  • thanks @Zanna for improving the answer. No idea why it only got 1 vote ;) Mar 28, 2021 at 3:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .