4

The /proc/devices file lists devices by major revision number and name. On my system it shows (partially):

Block devices:
259 blkext
  7 loop
  8 sd
  9 md
 11 sr
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
253 device-mapper
254 mdp

What are all those 'sd' devices? The first one (rev. no. 8) is probably /dev/sda but the rest of them don't show up in /dev - there are no devices with those major revision numbers.

I do see a list of devices:

crw-rw---- 1 root tty       7, 128 Jul 29 14:15 vcsa
crw-rw---- 1 root tty       7, 129 Jul 29 14:15 vcsa1
crw-rw---- 1 root tty       7, 130 Jul 29 14:15 vcsa2
crw-rw---- 1 root tty       7, 131 Jul 29 14:15 vcsa3
crw-rw---- 1 root tty       7, 132 Jul 29 14:15 vcsa4
crw-rw---- 1 root tty       7, 133 Jul 29 14:15 vcsa5
crw-rw---- 1 root tty       7, 134 Jul 29 14:15 vcsa6

where the minor number might be a match - would /proc show minor revision numbers, and why are they called sd. Either way, I don't see any device with no. 135.

Could someone explain this to me?

2 Answers 2

6

The first disk /dev/sda is 8:0 (major:minor), but the major number 8 contains the next 15 disks too (Documentation/devices.txt in the kernel source):

  8 block       SCSI disk devices (0-15)
                  0 = /dev/sda          First SCSI disk whole disk
                 16 = /dev/sdb          Second SCSI disk whole disk
                 32 = /dev/sdc          Third SCSI disk whole disk
                    ...
                240 = /dev/sdp          Sixteenth SCSI disk whole disk

                Partitions are handled in the same way as for IDE
                disks (see major number 3) except that the limit on
                partitions is 15.

The rest are for the rest of your drives (major numbers 66-71 and 128-134 are similar, and the partitioning scheme is the same for all of them):

 65 block       SCSI disk devices (16-31)
                  0 = /dev/sdq          17th SCSI disk whole disk
                 16 = /dev/sdr          18th SCSI disk whole disk
                    ...


135 block       SCSI disk devices (240-255)
                  0 = /dev/sdig         241st SCSI disk whole disk
                    ...
                240 = /dev/sdiv         256th SCSI disk whole disk

Well, you probably don't have that many disks, and the system only generates the nodes that are required for the devices you actually have, so you don't see anything but sda and its partitions in /dev.


As for vcsa and friends, they're related to the virtual consoles:

  7 char        Virtual console capture devices
                  0 = /dev/vcs          Current vc text contents
                  1 = /dev/vcs1         tty1 text contents
                    ...
                128 = /dev/vcsa         Current vc text/attribute contents
                129 = /dev/vcsa1        tty1 text/attribute contents
                    ...

Also note that /dev/vcs* are character devices, not a block devices. The first letter in the ls output tells which one it is.

1

It's just that there can be up to 16 * 1048576 sd block devices (which would have been ony 16 * 256 when dev_t was 16bits).

The code has:

    for (i = 0; i < SD_MAJORS; i++) {
            if (register_blkdev(sd_major(i), "sd") != 0)
                    continue;
            majors++;
            blk_register_region(sd_major(i), SD_MINORS, NULL,
                                sd_default_probe, NULL, NULL);
    }

To register those 16 major numbers.

And:

/*
 * More than enough for everybody ;)  The huge number of majors
 * is a leftover from 16bit dev_t days, we don't really need that
 * much numberspace.
 */
#define SD_MAJORS       16

Where:

/*
 * Device no to disk mapping:
 *
 *       major         disc2     disc  p1
 *   |............|.............|....|....| <- dev_t
 *    31        20 19          8 7  4 3  0
 *
 * Inside a major, we have 16k disks, however mapped non-
 * contiguously. The first 16 disks are for major0, the next
 * ones with major1, ... Disk 256 is for major0 again, disk 272
 * for major1, ...
 * As we stay compatible with our numbering scheme, we can reuse
 * the well-know SCSI majors 8, 65--71, 136--143.
 */
static int sd_major(int major_idx)
{
    switch (major_idx) {
    case 0:
        return SCSI_DISK0_MAJOR;
    case 1 ... 7:
        return SCSI_DISK1_MAJOR + major_idx - 1;
    case 8 ... 15:
        return SCSI_DISK8_MAJOR + major_idx - 8;
    default:
        BUG();
        return 0;       /* shut up gcc */
    }
}

Which shows how majors and minors are allocated.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .