16

fdisk(8) says:

The device is usually /dev/sda, /dev/sdb or so. A device name refers to the entire disk. Old systems without libata (a library used inside the Linux kernel to support ATA host controllers and devices) make a difference between IDE and SCSI disks. In such cases the device name will be /dev/hd* (IDE) or /dev/sd* (SCSI).

The partition is a device name followed by a partition number. For example, /dev/sda1 is the first partition on the first hard disk in the system. See also Linux kernel documentation (the Documentation/devices.txt file).

Based on this, I understand that in the context of Linux, a string like /dev/hda or /dev/sda is a "device name". Otherwise, the second sentence I have emphasised above does not make sense: it would instead say, "For example, sda1 is the first partition on the first hard disk in the system."

This view is corroborated by the Linux Partition HOWTO:

By convention, IDE drives will be given device names /dev/hda to /dev/hdd.

Is there a technically correct (and, preferably, unambiguous and concise) English term for the substring hda or sda of such a device name? For example, would it be correct in this case to call sda the drive's:

  • "short name"; or
  • "unqualified device name"; or
  • something else?

(I am not asking for colloquialisms that are technically incorrect, even if they are in common use.)

  • 3
    FWIW, the man page for dkinfo, which is the only command I've encountered that doesn't use a disk device's full pathname, calls it the "disk name". – Mark Plotnick Sep 17 '17 at 1:39
  • @MarkPlotnick, thanks, but this question is about Linux or GNU/Linux, not about other OSes. As such, dkinfo, which is not part of Linux or GNU/Linux (but instead is part of SunOS), is out of scope, sorry. – sampablokuper Sep 18 '17 at 9:16
25

sda is the device name. /dev/sda is the device path.

Think of /sbin/fdisk, fdisk is the file name, while /sbin/fdisk is the file path.

  • 5
    Although you have to be careful with "device path" as there are several meanings of that... – derobert Sep 17 '17 at 8:31
  • 1
    Thanks :) "sda is the device name. /dev/sda is the device path." That was my initial view as well, for the reason you have given, but it is unsupported by a close reading of the util-linux fdisk man page excerpt quoted in my question. (I have now edited the question to better emphasise this.) Hence my asking about the matter here on SE. N.B. This does not mean your answer is wrong - perhaps that part of the man page was sloppily written? - it just means that your answer and the util-linux fdisk man page appear to be at odds. Do you have any sources to corroborate your answer? Thanks again :) – sampablokuper Sep 17 '17 at 9:41
  • 6
    /dev/sda is the path to the block device, but the actual device path would be something like /devices/pci0000:00/0000:00:17.0/ata2/host1/target1:0:0/1:0:0:0/block/sda – Dietrich Epp Sep 17 '17 at 16:45
  • 2
    @jiggunjer: But mount also directs a device driver to map some RAM (not a volume) as a filesystem, can --bind a portion of the file tree as a subtree, etc. Furthermore, mounting a RAID "disk" can do useful and/or bizarre things with multiple volumes to access or deaccess parts of it. In short, mount can do many things but the most typical is making a filesystem appear somewhere in the file tree. – wallyk Sep 18 '17 at 4:09
  • 1
    @jiggunjer I think you may mean a filesystem format, which is not the same as the instantiation of such a format, which is usually refereed to as a filesystem, what you call a volume. Even if that is technically incorrect, that's what people mean by filesystem. I have yet to meet anyone who referees to an instantiation of a filesystem format as a volume. None of the books I have read on the topic has ever used the word "volume" to mean "filesystem" (in either meaning) either. – Clearer Sep 18 '17 at 11:06
6

The sda part of /dev/sda may represent several things depending on your point of view:

  1. File name
    In general, it is the name of a file, which, if it is a disk, is a block device, therefore, a device name

    As root:

    $ ls -la /dev/sd*
    brw-rw---- 1 root disk 8, 0 Sep 11 22:01 /dev/sda
    brw-rw---- 1 root disk 8, 1 Sep 11 22:02 /dev/sda1
    brw-rw---- 1 root disk 8, 2 Sep 11 22:01 /dev/sda2
    
  2. Disk names
    sda is the string that gives a name to a disk (diferent than partitions sda1, sda2, sdX, etc. ). It is usually generated by udev based on the applied device rules.

  3. Directory path
    sda is the basename of the path /dev/sda


Limited to the interpretation related to disk names:

In the old times: sda used to be the device name of SCSI disk a.

As the same library got extended to SATA drives I guess that now it should be called:

device name: SATA/SCSI/SAS disk a

Or simply:

device name: first SATA/SCSI/SAS disk
3

It is kernel-generated block disk/partition device name:

sda is a disk name generated by kernel. Kernel drivers (including SCSI stack which is happened to be very convenient to use for SATA disks) fill disk_name field of gendisk structure (i.e. for SCSI: drivers/scsi/sd.c#L3338) to generate sda name.

This name is later used to be a name of corresponding block device in /dev, /sys and /proc/{partitions,diskstats}. However, manual for procfs names it partition name (proc(5)) and documentation on disk stats calls it device name (iostats.txt).

  • Interesting, I guess sda and /dev/sda are interchangeable, and both referred to as a device name. I think that's because (in a normal system) you mount devfs on /dev, so names like sda turn into paths like /dev/sda (which you could also call a name). – Peter Cordes Sep 17 '17 at 22:05
1

In Linux/Unix everything is a file. A device represents as a file. All device type file located at /dev location. So sda is a block device type special file.

hd(x) - IDE
sd(x) - SATA,SSD,ISCI,SAS

Note: where x is a variable. x represents the position of hard disk.

if x = a for IDE disk means hda represents primary master disk
   x = b for IDE disk means hdb represents primary slave disk

Now in sd*

if x = a for SATA/SSD/ISCI/SAS sda represents first disk
   x = b fo SATA/SSD/ISCI/SAS sdb represents second disk
  • IIRC, even IDE (PATA) disks get sd* names with some drivers, or always with modern kernels? I forget, I don't have any active machines with PATA and a modern kernel. – Peter Cordes Sep 17 '17 at 8:59
  • 2
    Thanks for the answer, but it does not seem to address the question I asked :( I understand that in a context like /dev/sda, sda is a file, and I also understand what the file represents. My question was about what to call the substring sda and strings like it, when referring to them verbally. – sampablokuper Sep 17 '17 at 9:50
  • 1
    @PeterCordes having been using openSUSE Leap 42.2 for a while, I can confirm that the IDE PATA drives, both hard and optical, get sdX names, and intermingled with the SATA and SUB as well. – Gypsy Spellweaver Sep 17 '17 at 17:13
1

There seem to be at least two valid answers

  1. sda can correctly be called the "basename" for the drive.

  2. sda can also correctly be called the "kernel disk name" for the drive.

How did you reach this conclusion?

By process of elimination on each of the plausible candidates:

  • "device name"

This cannot be the correct term. As noted in the original question, it refers to the fully qualified name (e.g. /dev/sda), not to the final fragment (e.g. sda).

Corroborating evidence exists in additional sources, such as p.68 of The Definitive Guide to SUSE Linux Enterprise Server 12:

You can also choose to use … a mount that is based on device name (such as /dev/sdb1) …

and p.94 of The Linux Bible 2008 Edition:

Click the Device tab and type the device name (such as /dev/cdrom) …

  • "filename" or "file name"

This cannot be the correct term either, as it is used in technical documentation as a synonym for the fully qualified name (e.g. /dev/sda), not just the final fragment (e.g. sda):

BASENAME(1):

basename - strip directory and suffix from filenames

DIRNAME(1):

dirname - strip last component from file name

  • "name"

This cannot be the correct term either, as it is used in technical documentation as a synonym for the fully qualified name (e.g. /dev/sda), not just the final fragment (e.g. sda):

GNU Coreutils: basename invocation:

basename removes any leading directory components from name.

GNU Coreutils: dirname invocation:

dirname prints all but the final slash-delimited component of each name.

  • "shortname" or "short name"

This cannot be the correct term either. I cannot find any technical documentation that refers to the last part of a device name as a "shortname" or a "short name". Those terms seem to be used, in Linux or GNU, only in the context of either VFAT mount options, or host names on networks.

  • "basename"

This term appears to be a valid answer, based upon p.149 of Installing Red Hat Linux 7:

Make absolutely sure that the basename of the disk you are planning to partition is not listed (this is hdb, in the case of the drive I added).

and the course notes for CST8207 (GNU/Linux Operating Systems) at Algonquin College:

Definition of basename: The basename of any pathname is its right-most name component, to the right of its right-most slash.

and p.1456 of A Practical Guide to Red Hat Linux 8:

basename: The name of a file that, in contrast to a pathname, does not mention any of the directories containing the file (and therefore does not contain any slashes [/]). For example, hosts is the basename of /etc/hosts.

Happily, GNU/Linux also has a basename command, which can be used to obtain the basename:

$ basename '/dev/sda'
sda
  • "kernel disk name"

This term also appears to be a valid answer, due to p.100 of Linux Kernel in a Nutshell:

/dev/<diskname>

Use the kernel disk name specified by <diskname> as the root disk.

Incidentally, "kernel disk name" also appears to be valid terminology in the context of Solaris:

For this version of the iostat command, the output shows extended statistics for only those disk devices with nonzero activity, by physical device path instead of the logical kernel disk name (that is, c0t0d0 instead of sd0).

  • Yes you can say basename when talking about splitting up paths, but I've never seen "basename" when talking about devices. "Name" yes, "base name" no. Neither of the links in your question use the term "basename" or "base name"; what did you mean that the sources in the question support calling it a basename? – Peter Cordes Sep 17 '17 at 22:01
  • @PeterCordes, I meant that strings such as /dev/sda are referred to by: BASENAME(1) as "filenames"; DIRNAME(1) as "file names"; the GNU Coreutils docs as "names"; & by FDISK(8) and TLDP as "device names". So, none of those terms can ever unambiguously be used to refer to just the final slash-delimited component of the string. Ergo, if we want a term that can be used to unambiguously refer to that part of the string, then we must use something else. The sources in my answer, taken together, say the part before the final slash is the "dirname", & the part after is the "basename". Voilà. – sampablokuper Sep 17 '17 at 23:56
  • I guess that's fair. If you were documenting something that only accepted sda and not /dev/sda, you might call it the "basename". Or you could just use "name" vs. "path" in that documentation and give an example, like most documentation does. I don't think there is a commonly-agreed-upon term other than "name", even though some documents use "name" to include the full path. – Peter Cordes Sep 18 '17 at 1:56
0

"Everything is a file" - so isn't sda the simply file name, /dev the directory (and the empty string the extension) of the device made available via the full path /dev/sda, which by convention is the first non-IDE disk? Just like passwd is the file name and /etc the directory of the file accessible as /etc/passwd that by convention contain(ed) password data?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.