For When You Can't Have The Real Thing
[ start | index | login ]
start > Linux > Drive Device Naming Conventions

Drive Device Naming Conventions

Created by dave. Last edited by dave, 3 years and 129 days ago. Viewed 991 times. #5
[diff] [history] [edit] [rdf]
labels
attachments

What's up with drive names like hda and sdb?

The kernel deals with two types of drives:

  • IDE drives, like old hard drives and many CD/DVD drives -- these use the name hd$x
  • SCSI drives -- these use the name sd$x
SATA, SAS, and USB drives all use the SCSI subsystem because it has certain advantages that the older IDE drivers do not have. So these controller devices are abstracted to look like SCSI controllers, containing SCSI devices, to the hosting computer.

With IDE drives, the naming convention is pretty rigid:

  • hda is the master drive on the first bus
  • hdb is the slave drive on the first bus
  • hde is the master drive on the third bus
...and so on. (And yes it's possible to have more than two IDE buses.) So when you have a CD or DVD drive on an IDE bus, it is not uncommon to see those drives hung on the second IDE bus (because that's the way it has always been done -- but that's another discussion). So it is quite possible to have hdc without having hda and hdb.

This is important to know because the SCSI subsystem is different. Drives are labelled in the order in which they are detected.

So say you had an old-school SCSI bus, and hung disks at SCSI ID 0, 3, and 5. Those drives would get detected as sda, sdb, and sdc respectively.

Now assume you've bought a fourth drive, and for reasons only known to yourself, you assign it to SCSI ID 4. This new drive now gets detected as sdc, whereas the pre-existing drive on SCSI ID 5 is now sdd. This could cause all kinds of hilarity if you are refering to partitions by absolute name -- after booting with the inserted new drive, /dev/sdc1 isn't what it used to be, you mean /dev/sdd1 now.

This is one reason why RedHat (and others) like the e2label functionality, where you assign a unique label to the partition and mount it by reference to that.

(You might want to read about matching SCSI Device Names And Bus IDs.)

I don't know why Linux was built like this. Older-school OSs like Solaris force you to refer to the disk by SCSI address -- so /dev/dsk/c0t0d0s0 (controller 0, target (or ID) 0, disk 0 (legacy, don't ask), slice (or partition) 0) will be absolute, no matter what other disks are on the bus. It does suffer the same problem if you insert a new scsi controller, introducing a new bus ID, but that's relatively rare and most computers know to prefer their internal controllers over ones added later. The linux way can be simpler -- you don't need to know, or care about, your controller/id information. You just know it is the first, or second disk. And for most users this is true, you only have at most a couple of drives to deal with, so you don't really care what it is named as long as you can find it.

Partition numbers are something else again. The standard MS (DOS) partition table that is used on PCs has four primary partitions in it. No more, no less. They can be 0-length, and there's no need to start by defining partition 1. You can start with partition 3 if you want. I don't think they even have to be contiguous on the disk -- you can define partition 3 to start at block 0, and partition 1 to start somewhere after that. Most linux partitioning tools will write the partition tables starting with partition 1, and so on. Most linux kernels will treat an 0-length partition as an empty or non-existent partition and won't announce its existence.

If you need more partitions, you have to mark one of you primary a container for "extended" partitions. Then you can subdivide that into as many extended partitions as you like (subject to some limit which I don't know off the top of my head). The difference is that extended partitions are always enumerated by the kernel starting at partition number 5. So if you have a disk hda with two primary partitions and two extended partitions (for whatever reason), they would get enumerated as hda1, hda2, hda5, and hda6. Partition 3 would be marked as containing extended partitions and wouldn't be enumerated.

So that's a lot of words to explain the device names. It is really just to signal you that a device is a IDE or a SCSI-controlled device and to give you some idea how the device is partitioned.

Unless there's a compelling reason to do otherwise, I wouldn't mess with them. Changing them will only later confuse users who think they know what they are doing.

(Something I wrote for >>SuperUser)

no comments | post comment

Virtual Dave Megaplex:

Internet Explorer 6 Users >>Click Here

(read this note about local search)

Logged in Users: (0)
… and 4 Guests.


Editing: snipsnap-help, Image Macro

(Et auditum est, et idcirco ego nunc simulare)

Installed 3 years and 195 days ago
Powered By >>SnipSnap Version 1.0b1-uttoxeter

This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt