Rain WikiWindows · Linux · Android

lsblk and block devices

Command-line toolAll Linux distributions

lsblk lists block devices such as disks, partitions, LVM volumes and loop devices as a tree, with their size, type and mount point. It is the safest first step before partitioning, formatting or mounting, because it shows which device is which.

1Reading the tree

Disks appear as sda, nvme0n1 or vda, and their partitions below them (sda1, nvme0n1p1). TYPE shows disk, part, lvm or loop; MOUNTPOINTS shows where each is mounted.

2Useful options

lsblk -f adds the file system type, label and UUID. lsblk -o NAME,SIZE,MODEL,SERIAL shows the disk model and serial number, which helps tell disks apart. -e7 hides loop devices, which snap packages create in large numbers.

3Related tools

blkid prints UUIDs and file system types, df -h shows free space of mounted file systems, and findmnt shows the mount tree.

How to identify a newly added disk

  1. List devices before connecting the disk: lsblk -e7
  2. Connect the disk and run the same command again.
  3. The new entry without mount points is the new disk; confirm with: lsblk -o NAME,SIZE,MODEL,SERIAL
  4. Check whether it already has a file system: lsblk -f

Cautions

  • Double-check the device name before running partitioning or formatting tools: a mistake erases the wrong disk.
  • Device names can change between boots; use UUIDs in /etc/fstab.

Sources

  1. lsblk(8) manual page man7.org
  2. blkid(8) manual page man7.org

Last reviewed: