major and minor device number

Linux creates special files, called nodes, for each device on the system. All communication with the device is performed through the device node. Each node has a unique number pair that identifies it to the Linux kernel. The number pair includes a major and a minor device number. Similar devices are grouped into the same major device number. The minor device number is used to identify a specific device within the major device group. This is an example of a few device files on a Linux server:

root@dell:/dev# ls -al sda* ttyS*
brw-rw—- 1 root disk 8, 0 Feb 8 07:12 sda
brw-rw—- 1 root disk 8, 1 Feb 8 07:12 sda1
brw-rw—- 1 root disk 8, 2 Feb 8 07:12 sda2
crw-rw—- 1 root dialout 4, 64 Feb 8 07:12 ttyS0
crw-rw—- 1 root dialout 4, 65 Feb 8 07:12 ttyS1
crw-rw—- 1 root dialout 4, 66 Feb 8 07:12 ttyS2
crw-rw—- 1 root dialout 4, 67 Feb 8 07:12 ttyS3

The fifth column is the major device node number. Notice that all of the sda devices have the same major device node, 8, while all of the ttyS devices use 4. The sixth column is the minor device node number. Each device within a major number has its own unique minor device node number.

The first column indicates the permissions for the device file. The first character of the permissions indicates the type of file. Notice that the SCSI hard drive files are all marked as block (b) device, while the COM port device files are marked as character (c) devices.

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.