Sign up ×

The minor number is used by the kernel to determine exactly which device is being referred to.

The above explanation is just two abstract, can someone illustrate?

share|improve this question

2 Answers 2

The major number identifies the device driver to use, the minor number indicates which device. If you have multiple partitions, for instance, each gets its own minor:

brw-rw---- 1 root disk 8, 0 Jun  3 20:48 /dev/sda
brw-rw---- 1 root disk 8, 1 Jun  3 20:48 /dev/sda1
brw-rw---- 1 root disk 8, 2 Jun  3 20:48 /dev/sda2

Minor 0 in this case is the raw drive, minor 1 is partition 1, minor 2 is partition 2, etc. Not all devices use 0 as a special case, however. The serial devices start their numbering at 0, where /dev/tty0 is just the first (virtual) terminal device on the system:

crw--w---- 1 root tty  4, 0 Jun  3 20:48 /dev/tty0
crw------- 1 root root 4, 1 Jun  3 20:50 /dev/tty1
crw------- 1 root root 4, 2 Jun  3 20:50 /dev/tty2
crw------- 1 root root 4, 3 Jun  3 20:50 /dev/tty3

In either event, when the device file is opened the kernel will use the major number to determine which module will handle the file and passes the minor to the open() method of the struct file_operations structure that was registered with register_chrdev().

share|improve this answer
The book I'm reading says firstminor should be the requested first minor number to use; it is usually 0 in the function int alloc_chrdev_region(dev_t *dev, unsigned int firstminor,unsigned int count, char *name); , how can devices usually be 0 ? – httpinterpret Jun 7 '10 at 15:46
I've updated the answer to cover minor 0. – Hudson Jun 7 '10 at 15:51
Disks are usually not numbered with 0, but with other devices, there's a 0 at the first one: /dev/rfcomm0,/dev/fd0,/dev/lp0,... – Piskvor Jun 7 '10 at 15:56

as in the language C ,counting starts from 0 could be a sort of convention followed by driver writers ...after all everything in Linux is based upon C or to some extent C++.Its just a numbering scheme ..You can also start naming your devices from any number between 0 and 255,but please be carefull do not cross the 255 mark for minor numbers else you may overwrite the next available major number..hope this answer helps

share|improve this answer

Your Answer


