Tutoriel Linux

Lsblk under Linux: identifying a disk before mounting or formatting it

Débutant5 min de lecture

Before mounting, formatting, or adding a disk in /etc/fstabI always take a few seconds to check what Linux actually sees. A name like /dev/sdb

The order lsblk Its purpose is precisely to perform this inventory properly. It displays the disks, partitions, LVM volumes, mount points, and, with the correct columns, the UUIDs useful for avoiding major errors. In this article, I’ll show you the commands I use before any sensitive storage operation.

Tux inspects Linux disks and partitions before mounting or formatting.
Identifying the correct disk with lsblk prevents mounting or formatting the wrong partition.

Displaying disks seen by Linux

The basic command already provides a clear view of the block device tree:

lsblk

You usually get a column NAME with the main disk, its partitions, and then any volumes. The important columns to read first are SIZE, KIND And MOUNTPOINTS.

  • disk refers to a complete disc.
  • leaves designates a partition.
  • lvm, crypt Or raid indicate a layer above the disk or partition.
  • MOUNTPOINTS shows if the partition is already in use by the system.

The classic trap is to only look /dev/sdb and to forget that the useful partition is perhaps /dev/sdb1Never start a formatting process just because a name seems logical to you.

Add UUIDs, models, and mount points

To prepare a clean edit or modify fstabThe default output is a bit short. I prefer to explicitly request the relevant columns:

lsblk -o NAME,SIZE,FSTYPE,UUID,MOUNTPOINTS,MODEL,SERIAL,TYPE

This view avoids a lot of confusion. You see the file system, the UUID, the disk model, the serial number when available, and the active mount point. On a server with several disks of similar size, this is much more reliable than working by feel.

If you want a more compact, filesystem-centric output, also use:

lsblk -f

This variant notably displays FSTYPE, LABEL, UUIDThe available space and the percentage used when the information is retrieved. This is useful for distinguishing a partition ext4, xfs, vfat or an LVM volume before touching the mount.

Cross lsblk with blkid before mounting a disk

lsblk It reads the kernel and udev information. In most cases, that’s sufficient. But before an fstab line or a persistent mount, I cross-check with blkid to confirm UUIDs and file system types.

sudo blkid

You can then compare the two outputs. If the UUID displayed by lsblk -f corresponds to that of blkidYou now have a cleaner base for a line like this:

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/data ext4 defaults,nofail 0 2

For details on persistent mounting options, I’ve already published a dedicated guide on fstab under LinuxThe main point to remember here is: use a UUID, not a disk name that can change.

Check what has already been installed

Before manually mounting anything, first check if the system already uses it. lsblk gives you a first clue with MOUNTPOINTS, but findmnt is often clearer for reading active setups.

findmnt

To target a specific mounting point:

findmnt /mnt/data

And to check the space occupied after assembly:

df -h

If you connect a USB flash drive or external hard drive, the principle remains the same: identify the correct device, check its file system, see if it’s already mounted, and then proceed. For the specific case of a USB flash drive, you can also consult the guide. Mounting a USB drive under Linux.

Locate the correct disc without targeting the wrong target.

When multiple disks are present, I often start by displaying only the physical disks:

lsblk -d -o NAME,SIZE,MODEL,SERIAL,TRAN,ROTA,TYPE

The option -d limits output to parent devices. The columns MODEL, SERIAL And TRAN help to recognize a SATA, NVMe, USB or virtual disk. ROTA can also give a clue: one for a rotating disk, zero for an SSD in many cases.

On a virtual machine, you will sometimes see generic templates. In this case, rely primarily on the size, partitions, UUIDs, mount point, and hypervisor context. If you are working remotely, keep a backup console available whenever possible.

Before formatting, perform these checks.

Formatting is unforgiving. Before a command of the type mkfs.ext4I advise you to carry out at least this series of checks:

lsblk -o NAME,SIZE,FSTYPE,UUID,MOUNTPOINTS,MODEL,SERIAL,TYPE
sudo blkid
findmnt
df -h

Next, check three simple points:

  • the target disk or partition is not the system disk;
  • the expected mounting point is empty or corresponds to the desired volume;
  • You have a backup if the disk already contains data.

If the problem stems from a full disk, don’t immediately proceed with formatting. Start by running disk space diagnostics, in particular df, du and basic controlsThis is not the same type of troubleshooting.

Keep the output legible for diagnosis

To share a storage state in a ticket or keep a record before intervention, I prefer an explicit output:

lsblk -p -o NAME,SIZE,FSTYPE,UUID,MOUNTPOINTS,MODEL,SERIAL,TYPE

The option -p displays the full paths, for example /dev/sda1 instead of sda1It is more readable when you copy the output into a service note or when you compare it with an fstab line.

The manual pages of lsblk, blkid And findmnt They detail the columns and available options. No need to memorize everything. The most important thing is to know how to read the disk, the partition, the UUID, and the mount point before performing any irreversible action.

In short: lsblk is the first command to run when you have any doubt about a Linux disk. It doesn’t replace a backup, but it does prevent you from working blindly.