[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Block device, major- minor ?



On Thu, Nov 06, 2008 at 01:35:02PM -0200, Eduardo M KALINOWSKI wrote:
> Umarzuki Mochlis escreveu:
> > $ mknod block-device b 8 68
> >
> > can somebody explains why do we need major and minor in creating a
> > device file like above?
> 
> Basically for the same reason one needs both the street name and the
> house number to locate a house in a city.

The reason is historical.  Inside the kernel they are just a single
number, from which the "major" and "minor" parts can be extracted.

When devices had numbers statically allocated, so a disc drive
would have a major number, with partitions as minor numbers (for
example), they had a purpose.  Today, where the device numbers
are dynamically allocated and we use udev (previously devfs) to
attach names to the numbers, the major and minor separation has
little meaning.  Currently there is a mixture of both static
names (older devices, for compatibility) and dynamic:

% ls -ld /dev/hda* /dev/mapper/* /dev/usb/*
brw-rw---- 1 root disk   3,  0 2008-11-06 12:51 /dev/hda
brw-rw---- 1 root disk   3,  1 2008-11-06 12:51 /dev/hda1
brw-rw---- 1 root disk   3,  2 2008-11-06 12:51 /dev/hda2
brw-rw---- 1 root disk   3,  3 2008-11-06 12:51 /dev/hda3
brw-rw---- 1 root disk   3,  4 2008-11-06 12:51 /dev/hda4
brw-rw---- 1 root disk   3,  5 2008-11-06 12:51 /dev/hda5
crw-rw---- 1 root root  10, 60 2008-11-06 12:51 /dev/mapper/control
brw-rw---- 1 root disk 254,  4 2008-11-06 12:51 /dev/mapper/hardknott-home
brw-rw---- 1 root disk 254,  0 2008-11-06 12:51 /dev/mapper/hardknott-root
brw-rw---- 1 root disk 254,  5 2008-11-06 12:51 /dev/mapper/hardknott-sbuild--chroots
brw-rw---- 1 root disk 254,  3 2008-11-06 12:51 /dev/mapper/hardknott-swap
brw-rw---- 1 root disk 254,  1 2008-11-06 12:51 /dev/mapper/hardknott-usr
brw-rw---- 1 root disk 254,  2 2008-11-06 12:51 /dev/mapper/hardknott-var
crw-rw---- 1 root root 180,  0 2008-11-06 12:51 /dev/usb/hiddev0

In this case, the hard disc and its partitions are all on
block-major-3.  The LVM volumes are all on block-major-254, but the
partitions have a (semi-)random minor device number, depending on
the order they get discovered/registered in.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.

Attachment: signature.asc
Description: Digital signature


Reply to: