8

The Linux Programming Interface states:

Each device driver registers its association with a specific major device ID, and this association provides the connection between the device special file and the device driver.

Is it possible to obtain the list of those associations?

0

2 Answers 2

13

Documentation/admin-guide/devices.txt in the kernel source code documents the allocation process and lists all the allocated device numbers. sd gets a whole bunch of major device numbers because of the large number of devices it can handle: major 8 covers /dev/sda to /dev/sdp, major 65 covers /dev/sdq to /dev/sdaf, 66 /dev/sdag to /dev/sdav and so on all the way to 135 for /dev/sdig to /dev/sdiv (for a total of 256 disk devices).

2

The link in Stephen Kitt's answer provides the table for common device types. However some systems (for example device-mapper) don't hardcode their major numbers and instead obtain them dynamically.

In those cases, you can read the /proc/devices file to get a table of registered major numbers, along with a driver-specified description string that should point you in the right direction.

Note that, since the value is dynamically registered, it may change from boot to boot, depending on the order that the driver modules happen to register.

1
  • The link also describes (briefly) the dynamic allocation process 😉 but it doesn’t mention /proc/devices, that is a very useful piece of information in the context of this question. Thanks! Commented Sep 12, 2022 at 19:40

You must log in to answer this question.

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