Question: How do I find out the major and minor number of my block device / partition / mount points / SAN disk / filesystem?
Why do you need to know major and minor device number?
Sometimes you may need to know the major and minor number of devices for various reasons. For example, sar utility reports the i/o data of filesystems in the format of devm-n as shown below. (m is major number and n is minor number)
From sar man page following is the meaning for the DEV column shown below:
-d Report activity for each block device (kernels 2.4 and newer only). When data is displayed, the device specification dev m- n is generally used ( DEV column). m is the major number of the device. With recent kernels (post 2.5), n is the minor number of the device, but is only a sequence number with pre 2.5 kernels.
By looking at the sar output below, we cannot tell what mount point (filesystem) dev110-1 indicates. In this case, you know that this device represents a block device that has a major number 110 and minor number 1.
$ sar -d Linux 2.6.9-184.108.40.206.1.ELsmp (webserver) 06/21/2009 12:00:00 AM DEV tps rd_sec/s wr_sec/s 12:02:00 AM dev110-1 6.00 0.00 6.00 12:02:00 AM dev8-1 1.00 1.00 0.00 12:02:00 AM dev1-1 2.00 1.00 1.00 12:02:00 AM dev1-2 1.00 0.00 1.00 12:02:00 AM dev1-3 4.00 2.00 2.00 12:02:00 AM dev1-4 5.00 3.00 2.00
df -k will not display major and minor number
In the following example, when you perform a df -k, it shows that you have a local SCSI hard drive partition (/dev/sda1) mounted as / (root) and a SAN device partition (/dev/san-device1) mounted as /home/mysql. Please note that the SAN device can be a EMC, NetApps or any kind of SAN storage.
$ df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 10317828 2353828 7439884 25% / /dev/sandevice1 50537528 22350656 25619688 47% /home/mysql
How to identify major and minor device number?
Now, if you want to know the major and minor number of these devices, cd to /dev directory and do ls -l as shown below, which will show both major and minor number
$ cd /dev $ ls -l sd* brw-rw---- 1 root disk 8, 0 Feb 8 2008 sda brw-rw---- 1 root disk 8, 1 Feb 8 2008 sda1 [Note: Major for /dev/sda1 is 8 and minor is 1] $ ls -l san* brw------- 1 root root 110, 0 Feb 8 sandevice brw------- 1 root root 110, 1 Feb 8 sandevice1 [Note: Major for /dev/sandevice1 is 110 and minor is 1]
- sda1 – Major number is 8 and Minor number is 1
- sandevice1 – Major number is 110 and Minor number is 1
With this information now you can identify the corresponding device that is reported in the sar -d output.
$ sar -d Linux 2.6.9-220.127.116.11.1.ELsmp (webserver) 06/21/2009 12:00:00 AM DEV tps rd_sec/s wr_sec/s 12:02:00 AM dev110-1 6.00 0.00 6.00 12:02:00 AM dev8-1 1.00 1.00 0.00 [Note: Now, we know dev110-1 is /dev/sandevice1 and dev8-1 is /dev/sda1 ]
Major number for SCSI and IDE drives
The major numbers for SCSI and IDE doesn’t change and has the following hard-coded value.
- SCSI (/dev/sd?) Major Number is 8
- IDE (/dev/hd?) Major Number is 3
Get the Linux Sysadmin Course Now!