After reading the chapter about block device drivers in the book "Understanding the Linux Kernel" I am a bit confused about the usage of minor numbers.
I have read before about major and minor numbers and their usage. So major numbers identify the driver to use for handling I/O requests to the physical hard disk. Minor numbers are only used by the driver itself to identify several hard disks and partitions. That's how it is described in almost every explanation I have found.
In the chapter of the aforementioned book the author says that during initialization the driver creates a gendisk structure for every existing hard disk in which it only records the first usable minor number and the amount of available minor numbers.
So before the hard disk is accessed, the general block layer of the kernel converts the relative sector number within some partition to the absolute sector number within the hard disk. So the device driver doesn't have to care about any partitions.
The only purpose I can imagine, is to distinguish between different hard disks but not partitions. I think that I am wrong and it would be great if someone knows the truth.

The only purpose I can imagine, is to distinguish between different hard disks but not partitions.

That is correct.

There are many block device drivers, and many types of partitions. The underlying block device driver is not required to implement any partition handling, except for setting the number of supported partitions.

The main thing that exception is used for, is not to bother supporting partitions on devices like LVM, where they are generally not needed.

(If you do need the kernel to provide sub-partitions on LVM, you can use kpartx which creates new device mapper devices, with device names that conveniently look like the normal partition name pattern).

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.