Finding the major and minor numbers for a block device that corresponds to a SCSI disk

7.1 LPAR mode z/VM guest

Linux® creates block devices that represent SCSI disks. You can find the major and minor numbers of a SCSI disk block device and its partitions from the device representation in the sysfs SCSI branch.

About this task

Figure 1. Major and minor numbers for block devices that correspond to SCSI disks in sysfs

/sys/bus/scsi/devices/<scsi_device>/block/sd<x>/sd<x><n>

In Figure 1, <scsi_device> represents a SCSI device with a block device as a child. The block device has a name of the form sd<x>, which is a standard name that the SCSI stack assigned to the SCSI disk block device. If the disk is partitioned, the block directory that follows contains directories of the form sd<x><n> that represent the partitions, where <n> is a positive integer that identifies the partition.

Both the block device directory and the directories that represent the partitions contain an attribute dev. Read the dev attribute to find out the major and minor numbers for the entire disk or for an individual partition. The value of the dev attributes is of the form <major>:<minor>.

Procedure

Issue a command of this form to find the major and minor numbers:
# cat /sys/bus/scsi/devices/<scsi_disk>/block/sd<x>/dev
The command output shows the major and minor numbers, which are separated by a colon.

Example

The following command shows a major of 8 and a minor of 0 for the block device that corresponds to SCSI disk 0:0:1:1:
# cat /sys/bus/scsi/devices/0:0:1:1/block/sda/dev
8:0
Assuming that the disk has three partitions sda1, sda2, and sda3, the following commands show the respective major and minor numbers:
# cat /sys/bus/scsi/devices/0:0:1:1/block/sda/sda1/dev
8:1
# cat /sys/bus/scsi/devices/0:0:1:1/block/sda/sda2/dev
8:2
# cat /sys/bus/scsi/devices/0:0:1:1/block/sda/sda3/dev
8:3