Before you partition, format, mount or resize anything, you need to know which disks exist and what’s on them. lsblk shows block devices as a tree, and blkid shows filesystem types and UUIDs. Together they answer “which disk is the new one?” and “what UUID goes in fstab?”

lsblk: the overview

lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
vda     252:0    0   80G  0 disk
├─vda1  252:1    0   79G  0 part /
├─vda14 252:14   0    4M  0 part
└─vda15 252:15   0  106M  0 part /boot/efi
vdb     252:16   0  500G  0 disk

Reading it:

  • vda is the first virtual disk. On VPSes disks are usually vd* (virtio) or sd*, and on NVMe hardware nvme0n1.
  • TYPE is disk, part (partition), lvm, raid1, loop or rom.
  • MOUNTPOINTS is empty for unmounted devices. Above, vdb is a new, empty 500 GB disk.

Show filesystems and UUIDs

lsblk -f
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
vda
├─vda1 ext4   1.0         0b4a8c1e-6c7e-4f34-9f6e-1a2b3c4d5e6f   61.2G    19% /
└─vda15 vfat  FAT32       7A1B-2C3D                              99.6M     6% /boot/efi
vdb

vdb has no FSTYPE, so it’s blank and ready to partition or format.

Choose your columns

lsblk -o NAME,SIZE,TYPE,FSTYPE,UUID,MOUNTPOINTS
lsblk -o NAME,SIZE,MODEL,SERIAL,ROTA      # model and serial (dedicated servers)
lsblk -d                                  # disks only, no partitions
lsblk -p                                  # full paths (/dev/vda1)
lsblk -b                                  # sizes in bytes

ROTA = 1 means a rotating hard disk and 0 means SSD or NVMe. That’s handy on dedicated servers with mixed drives.

For scripts, use JSON or raw output:

lsblk -J -o NAME,SIZE,MOUNTPOINTS
lsblk -nr -o NAME,TYPE | awk '$2=="disk"{print $1}'

blkid: filesystem details

sudo blkid
/dev/vda1: UUID="0b4a8c1e-…" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="…"
/dev/vda15: LABEL_FATBOOT="UEFI" UUID="7A1B-2C3D" TYPE="vfat" PARTUUID="…"

One device, or one value:

sudo blkid /dev/vdb1
sudo blkid -s UUID -o value /dev/vdb1       # just the UUID, for scripts and fstab

There are two UUIDs to know about:

  • UUID belongs to the filesystem. It’s created by mkfs and is what /etc/fstab should use.
  • PARTUUID belongs to the partition (GPT). It’s used by some bootloaders, and stays the same if you reformat.

Run blkid with sudo. Without root it may show cached or incomplete data.

Identify a newly attached disk

A new volume was attached, or a new drive was installed in a dedicated server. Which one is it?

lsblk -d -o NAME,SIZE,TYPE,MODEL
sudo dmesg | tail -20       # kernel messages about newly detected disks

The disk with no partitions and no mount point, of the expected size, is the new one. Double-check before writing to it. Formatting the wrong disk destroys data.

If a hot-added disk doesn’t appear, rescan:

echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan

Virtio disks usually show up immediately. Some setups need a reboot.

Other useful views

ls -l /dev/disk/by-uuid/       # UUID → device symlinks
ls -l /dev/disk/by-id/         # stable names based on model and serial
df -hT                         # mounted filesystems with usage
findmnt                        # mount tree
sudo fdisk -l                  # partition tables in detail

Paths under /dev/disk/by-id/ are great for RAID and ZFS configs on dedicated servers, because they identify physical drives by serial number.

Next steps

Goal Guide
Partition the disk fdisk or parted
Create a filesystem mkfs
Mount it permanently fstab
Grow a partition after a disk upgrade growpart and resize2fs
Combine disks flexibly LVM

Quick reference

Task Command
Tree of disks lsblk
With filesystems and UUIDs lsblk -f
Disks only lsblk -d
All filesystem info sudo blkid
UUID of one partition sudo blkid -s UUID -o value /dev/vdb1
JSON for scripts lsblk -J
SSD or HDD lsblk -d -o NAME,ROTA

Related: mount and df.

  • Linux
  • Storage
  • Command Line