Skip to content

Linux Foundations / Understand the system underneath ยท Step 15 of 38

Lesson: Device namesSwitch
โ† Linux Foundations

System administration

Device names

Decode Linux disk and serial port names and use names that stay the same across reboots.

Linux device names look cryptic, but they follow patterns. Learning them helps you point a command at the right device.

Disks and partitions

SATA, SCSI, SAS and USB storage use the sd prefix. The letters count disks in the order they were found, and a number marks a partition.

  • /dev/sda is the first such disk.
  • /dev/sdb is the second.
  • /dev/sda2 is partition 2 on the first disk.

NVMe drives are named differently. /dev/nvme0n1 is namespace 1 on the first NVMe drive (that numbering starts at 0), and /dev/nvme0n1p1 is its first partition. SD and eMMC cards follow the same p style, as in /dev/mmcblk0p1.

Virtual machines often show /dev/vda (virtio) or /dev/xvda (Xen). An optical drive is usually /dev/sr0.

bash
lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0 465.8G  0 disk
โ”œโ”€sda1        8:1    0   512M  0 part /boot/efi
โ””โ”€sda2        8:2    0 465.3G  0 part /
nvme0n1     259:0    0 931.5G  0 disk
โ””โ”€nvme0n1p1 259:1    0 931.5G  0 part /data

Older versions of lsblk title the last column MOUNTPOINT.

Terminals and serial ports

  • /dev/tty1 is a virtual console.
  • /dev/pts/0 is a pseudo terminal, used by terminal windows and SSH sessions.
  • /dev/ttyS0 is a built in serial port.
  • /dev/ttyUSB0 and /dev/ttyACM0 are common names for USB serial devices.

Run tty to see which one you are using.

Names can change

The sd letters depend on detection order. Add a USB stick or another disk, reboot, and yesterday's /dev/sdb might be /dev/sdc.

udev creates links under /dev/disk that are based on properties of the disk or filesystem:

bash
ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 Nov 29 09:00 3f1c9a2e-7b4d-4c1a-9e0f-2a6b8c5d1e44 -> ../../sda2
lrwxrwxrwx 1 root root 10 Nov 29 09:00 8A2C-11F7 -> ../../sda1

Other directories include by-id (hardware identity), by-label (filesystem label) and by-path (physical connection). Which ones exist depends on your devices.

For /etc/fstab, use UUID= so the correct filesystem is mounted even if its letter changes. blkid or lsblk -f shows the UUIDs. Reformatting a filesystem normally gives it a new UUID.

Before any command that writes to a disk, check the name again with lsblk. The disks and filesystem lab gives you more practice with storage.

Try it

  1. Run lsblk -f and match each name with its filesystem and mount point.
  2. Run ls -l /dev/disk/by-id and follow where the links point.
  3. Run tty in two terminal windows and compare the answers.
  4. Open /etc/fstab with cat and see how filesystems are identified.

Check your understanding

Device names

All 5 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.