knowing a device special file major and minor numbers in linux

Manuel Araoz picture Manuel Araoz · Dec 1, 2009 · Viewed 32.9k times · Source

All files in /dev are special files... they represent devices of the computer. They were created with the mknod syscall. My question is: How can I know the minor and major numbers that were used to create this special file?

Answer

Jed Smith picture Jed Smith · Dec 1, 2009

The list is called the LANANA Linux Device List, and it is administered by Alan Cox.

You can find the latest copy online (direct link), or in the Linux source. Its filename in the kernel tree is Documentation/devices.txt.

To see the major and minor numbers that created a node in /dev (or any device node for that matter), simply use ls with the -l option:

22:26 jsmith@undertow% ls -l /dev/xvd?
brw-rw---- 1 root disk    202,   0 Nov  1 20:31 /dev/xvda
brw-rw---- 1 root disk    202,  16 Nov  1 20:31 /dev/xvdb
brw-rw---- 1 root disk    202,  32 Nov  1 20:31 /dev/xvdc

In this example, 202 is the three devices' major number, and 0, 16, and 32 are minors. The b at left indicates that the node is a block device. The alternative is c, a character device:

crw-rw-rw- 1 root tty       5,   0 Nov 22 00:29 /dev/tty