Linux block devices naming

devicesdisklinux

I am a bit confused with how linux hard drive/ storage device, block files are named.

My questions are:

  • How are IDE devices and partitions named?

  • How are EIDE devices and partitions named?

  • How are PATA devices and partitions named?

  • How are SATA devices and partitions named?

  • How are SCSI devices and partitions named?

Lastly, I have been reading articles on this subject, and I have seen mentions of 'master drives' and 'slave drives'. What are these, what are they used for, and how are they named?

Best Answer

Introduction

First of all, all the devices populate the /dev folder.

Also, it is important to note that (E)IDE and PATA terms usually refer to the same thing, which is the interface standard PATA. IDE and PATA are interchangable terms in this context.

There was a major change in naming conventions for block devices in Linux, around the release of Linux kernel version 2.6. The kernel supports all ATA devices through libATA, which started with SATA devices support in 2003 and was extended to current PATA support.

Therefore, be aware that, depending on your distribution and kernel version, the drives naming convention can differ.

Since a while, PATA devices on "modern" distributions are named the ways SATA drives are, since both are now using libATA.


For your distribution, you can find this in /lib/udev/rules.d/60-persistent-storage.rules.

On my system using Debian 9, it is also the case. For example:

$ cat /lib/udev/rules.d/60-persistent-storage.rules | grep "ATA"
# ATA
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", 
ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode"

By browsing this file, you will know how your distribution will name every block device you could connect to your machine.

Block devices naming conventions

IDE drives

  • IDE drives (using the old PATA driver) are prefixed with "hd"
    • the first device on the IDE controller (master) is hda
    • the second device (slave) is hdb

Since there can only be two drives on one IDE controller/cable, the master is the first one and the slave is the second one. Since most motherboard are fitted with two IDE controllers, it goes on the same way with the second controller:hdc being the master drive on the second controller and hdd the slave drive.

Be aware that, since Linux kernel 2.6.19, the support of IDE drives has been merged with SATA/SCSI drives and, therefore, will be named like them.

SATA and SCSI drives

This naming convention started with SCSI drives, and was extended to SATA drives with libATA. It applies to SCSI, SATA, PATA as well as others drives, out of the scope of OP question (USB mass storage, FireWire, etc.). Anyway, usually, all the devices using a serial bus use the same denomination nowadays (except for NVMe drive, but this would a story for PCI devices).

  • SATA/SCSI drives start with "sd"
    • the first one is sda
    • the second one is sdb
    • etc.

Partitions naming conventions

Regarding partitions, each of them is denoted by a number at the end of each disk, named as described previously, starting from 1. Except for some other devices not mentioned in OP, it is always the case.

By instance, for the partitions on a SATA drive, they would be listed as sda1, sda2, and so on, for primary partitions. Logical partitions start at the index "5", while the extended partition takes the index "4". Note that this is obviously only true for drives making use of MBR and not GPT.

Below, this is the output of lsblk giving an example for disk called sdd, with 3 primary partitions (sdd1,sdd2,sdd3), 1 extended partition (sdd4) and 2 logical partitions (sdd5,sdd6).

$ lsblk
sdd      8:48   1   1.9G  0 disk 
├─sdd1   8:49   1   153M  0 part 
├─sdd2   8:50   1   229M  0 part 
├─sdd3   8:51   1   138M  0 part 
├─sdd4   8:52   1     1K  0 part 
├─sdd5   8:53   1   289M  0 part 
└─sdd6   8:54   1   1.1G  0 part 

Master and slaves devices

A single IDE interface can support two devices. Usually, motherboards come with dual IDE interfaces (primary and secondary) for up to four IDE devices on a system.

To allow two drives to operate on the same parallel cable, IDE uses a special configuration called master and slave. This configuration allows one drive's controller to tell the other drive when it can transfer data to or from the computer. The name comes from the fact that the slave drive ask the master if it is communicating with the motherboard; if the master is, it will tell the slave to wait until the operation is finished but if not, it will tell the slave to go ahead.

The master/slave role could be chosen thanks to the "Cable Select" feature: you could use a jumper on each drive supporting this feature to select either "Master", "Slave" or "Auto" (this last option meaning that the master is at the end of the IDE cable and the slave is the other).

Related Question