What does /dev/sda for linux mean?

95

32

What does :

/dev/sda

stand for? What does it mean?

I have both Fedora and Ubuntu installed and if I explore them using Ext2explore from windows, I see these names :

/dev/sda6
/dev/sda9

Please explain me what does that mean? I mean the numbers there and also the /dev/sda/.

saplingPro

Posted 2013-02-27T10:26:46.027

Reputation: 1 101

Answers

142

TL;DR: It has to do with the way linux (and all unixes) name their drives, much in the way that windows uses C:, D:, etc. (NOTE: This is what we call a metaphor. In other words, a blatant lie that helps people understand without being even remotely accurate. Read on for a more detailed explanation...)

  • /dev/ is the part in the unix directory tree that contains all "device" files -- unix traditionally treats just about everything you can access as a file to read from or write to.

  • sd originally identified a SCSI device, but since the wildgrowth of USB (and other removable) data carriers it became a catch-all for any block device (another unix term; in this context, anything capable of carrying data) that wasn't already accessible via IDE. When SATA came around, the developers figured it'd be much easier and much more convenient for everyone to add it into the existing framework rather than write a whole new framework.

  • The letter immediately after sd signifies the order in which it was first found -- a,b,c...z, Aa...Az... etc. (Not that there are many situations in the real world where more than 26 discrete block devices are on the same bus...)

  • Finally, the number after that signifies the partition on the device. Note that because of the rather haphazard way PCs handle partitioning there are only four "primary" partitions, so the numbering will be slightly off from the actual count. This isn't a terrible problem as the main purpose for the naming scheme is to have a unique and recognizable identifier for each partition found in this manner...

So /dev/sda9 means the ninth partition on the first drive.

Shadur

Posted 2013-02-27T10:26:46.027

Reputation: 1 732

1/dev/sd[A-Z][a-z] actually is considered invalid by AWS now, unless it requires extra configuration. – cxdf – 2016-01-11T21:04:21.960

shouldn't -- the dev-by-UUID nodes should be symlinks. – Shadur – 2016-01-11T21:12:32.637

A metaphor is usually related in some sort of tangential way that is more closely related to the addressee's experience than the concept or thing one wishes to explain. So one might explain the workings of a processor in terms of tractors and muddy boots to a farmer, for example. The hope is the addressee will be able to utilise the symbolic link(s) in order to mentally construct a working model of whatever the addresser is describing, without first-hand knowledge. So it's only really a lie in the same way a block-chain is a lie about a pass-phrase. In fact, a blockchain is a sort of metaphor. – What's in a Google Search – 2016-05-16T15:59:28.837

Note that with NVMe instead of SATA, the name of the first device is /dev/nvme0n1 – Boiethios – 2017-07-28T20:26:20.740

Does this mean that SATA piggybacks on the SCSI framework? i.e. if you don't include SCSI in the kernel you wouldn't be able to mount SATA drives? – linuxgnuru – 2017-09-10T21:28:53.913

@linuxgnuru Judging by the output of lsmod on one of my systems, the answer to that is yes -- scsi_mod is required by libata. Then again, scsi_mod is also required by usb_storage so there you go... – Shadur – 2017-09-10T21:32:01.253

@Shadur what if on df -h I see sda and sde but not sdb? – mrgloom – 2019-07-26T13:45:39.850

@mrgloom drive 'letters' are not automatically resequenced every time they change -- if I had to guess, I'd say you've plugged and unplugged several USB data carriers since the last time this system was rebooted. – Shadur – 2019-07-26T14:05:02.990

I didn't understand the third point. Can you please help me in that – saplingPro – 2013-02-27T11:24:42.823

13Meaning that the first device found would be sda, the second would be sdb, and so on until the 26th device would be called sdz and the system would start with sdAa if you wind up having more devices than that... – Shadur – 2013-02-27T13:58:38.960

17

/dev is your filesystem representation of devices your system understands - providing a mechanism for applications to access data on the device without needing to know specifically what the device is.

sd is for (originally) scsi disk devices, however it seems to now refer to removable devices in general and SATA devices

and the letter is just the number of the device, starting at a, with the number indicating the partition.

Rory Alsop

Posted 2013-02-27T10:26:46.027

Reputation: 3 168

10

sd originates from the driver sd-mod. It literally stands for scsi disk.

The reason (S)ATA disks are also listed as SCSI disks is, SCSI commands pretty much provides a superset of features that can be provided by ATA commands, therefore modern systems (including Windows, AFAIK) will have an implementation of SCSI-ATA Translation Layer (SATL) in the system (in Linux it is provided by the libata driver) to talk to the (S)ATA disks, while the upper layer of the system can be generalized.

As you may not aware of, USB drives "speaks" SCSI (i.e. takes and responds to SCSI commands), no matter if it supports the USB Attached SCSI Protocol or not. Also, most of the USB HDDs/SSDs are SATA disks bridged to USB. For those the bridge provides the SATL, but not the operating system.

Tom Yan

Posted 2013-02-27T10:26:46.027

Reputation: 4 744