Linux : Major and Minor device numbers

19,321

Solution 1

All devices have a major, minor number pair. The major number is a larger, more generic category (e.g. hard disks, input/output devices etc...) while the minor number is more specific (i.e. tells what bus the device is connected to).

Check the kernel documentation for more examples.

Solution 2

The major device number identifies the driver (e.g. IDE disk drive, floppy disk, parallel port, serial port, ...) or sometimes a peripheral card (first IDE card, second IDE card of the PC) and the minor number identifies the specific device (i.e., the first floppy would have minor 0, the second would be 1, ...).

Solution 3

Maybe you are interested in the LANANA device list that describes the major codes.

As @Renan says, minor depends on the device.

Share:
19,321

Related videos on Youtube

Referential
Author by

Referential

Updated on September 18, 2022

Comments

  • Referential
    Referential over 1 year

    What types of devices fall under the major device number category and what types of devices fall under the minor device number category. What is the real difference between the two categories?

  • Jpark822
    Jpark822 about 11 years
    No. Major numbers are fixed. E.g. SCSI drives at major 8. The first SCSI drive is (8,0), the second drive (8,1), the third (8,2) etc etc. Even if you have no other major devices that will still stay fixed at 8. Same with every other device. The M coded into the drivers and will always be the same.
  • vonbrand
    vonbrand about 11 years
    @Referential, no. The first IDE controller has major number 3, on it the master is block minor 0 and the slave 1; floppy major is block 2, parallel port is char 6, minor identifies the port. The number belongs to the driver, independent of a device being present (or even if the driver is compiled into the kernel at all). LANANA (Linux Assigned Names And Numbers Authority) is in charge of allocating them.
  • Referential
    Referential about 11 years
    Which types of devices would specifically fall under the minor device number category? I thought that the minor device number category mirrors the major device number (eg: hard disk 1 has a major device number and the minor number identifies it as a hard drive). If someone can please give me a few more examples. Thanks
  • vonbrand
    vonbrand about 11 years
    @Referential There are a few devices that can only exist in one copy, they don't have minor device numbers. Each time a device can be present seveal times, they are numbered by a minor number. Major is device type (driver), minor is device number (instance).
  • Nate Eldredge
    Nate Eldredge almost 7 years
    The list of device numbers is no longer at that location in the Linux kernel source tree. Do you know where it moved to?