Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
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 '11 at 14:32
add comment

2 Answers

up vote 12 down vote accepted

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.

share|improve this answer
2  
+1 - Good explanation. –  Nathan Osman Jun 4 '11 at 16:52
2  
Where does the 127 limit come from? Just wondering. –  crazy2be Jun 4 '11 at 16:58
    
@crazy2be: you ask, I edit :) –  Rinzwind Jun 4 '11 at 17:01
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 '11 at 18:04
    
127 usb sticks is possible. 128 hard disc? Don't think so :D –  Rinzwind Jun 4 '11 at 18:06
show 2 more comments

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.