When USB devices are connected in Linux the kernel assigns them a minor device number (i.e. the 0 in
/dev/ttyUSB0). It seems that if I have a device at
/dev/ttyUSB0, when I remove it and plug in a new USB device then new device will get a distinct device number. But if I wait long enough or add enough devices eventually one will be given device number 0. How does the kernel decide when to reuse device number 0?
For more context: I have a large number of USB devices connected to a server and I'm using the minor device number to track them. I want to detect when new devices are added and when old ones are removed. I'm worried that if new devices can get be assigned the same device number as an old device which has been removed then I won't know that the device has been replaced.