lsblk Command: Checking Disk and Partition Layout and UUIDs

Test environmentRHEL familyAlmaLinux 9.8root account
Disk · mount commandslsblkLocation/usr/bin/lsblk

The lsblk command prints the disks and partitions connected to a server and their mount points as a tree, and shows disk sizes, file system types, and even UUIDs at a glance. When we ran lsblk on an AlmaLinux 9 server, the loop devices created by snap packages were listed before the disk, so we filtered them out with -e 7. Then we used -f to check the xfs file system and UUID of the root partition.

The disk sizes and UUIDs in the output below are example values.

1️⃣ Reading the basic output of the lsblk command

On a server where programs were installed with snap, running lsblk without options lists a loop device mounted for each package version before the disk, so specify 7, the device number of loop devices, with -e to leave them out.

lsblk -e 7
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
nvme0n1     259:0    0   80G  0 disk 
├─nvme0n1p1 259:1    0    1M  0 part 
├─nvme0n1p2 259:2    0  200M  0 part /boot/efi
├─nvme0n1p3 259:3    0    1G  0 part /boot
└─nvme0n1p4 259:4    0 78.8G  0 part /

nvme0n1 in the NAME column is the disk. nvme0n1p1 through nvme0n1p4, connected below it with [├─] and [└─], are the partitions that divide this disk. It is like the floor directory at a building entrance, which lists what is on each floor under the name of the building.

In the TYPE column, disks appear as [disk] and partitions as [part], and the MOUNTPOINTS column shows the folder where each partition is mounted. On the server we checked, the root partition nvme0n1p4 was mounted on / and nvme0n1p3 on /boot. The 1M nvme0n1p1 is a BIOS boot partition used for booting from a GPT disk, so it has no mount point.

MAJ:MIN are the major and minor numbers the kernel assigns to a device; loop devices are 7, and the NVMe disk we checked was 259. RM shows whether a device is removable and RO whether it is read-only, as 1 or 0.

It is easy to read SIZE as free space, but SIZE is the total size of the disk or partition. Check the free space of a file system in the FSAVAIL column, which appears when you add -f.

The diagram below lets you compare, step by step, how the rows and columns in the output change with each option.

🧭 lsblk output by option: disks and partitions
Explainer diagram
⚙️ Option
$ lsblk -f -d -p -e 7
Device name
Size
File System
Mount point
/dev/nvme0n1
80G
├─/dev/nvme0n1p1
1M
├─/dev/nvme0n1p2
200M
vfat, 5A1E-…
/boot/efi
├─/dev/nvme0n1p3
1G
xfs, 6d2f…
/boot
└─/dev/nvme0n1p4
78.8G
xfs, 2b9e…
/
🖥️ What is printed on the screen
1 disk line and 4 partition lines, 7 default columns (NAME to MOUNTPOINTS)
1 disk line and 4 partition lines, 8 file system columns (FSTYPE, UUID, FSAVAIL, etc.)
Only 1 disk line, 7 default columns
1 disk line and 4 partition lines, names start with /dev/
Without options, the partitions branch off below the disk. Sizes and mount points are shown as well.
-f prints the file system type, UUID, and free space instead of the size. The disk nvme0n1 and nvme0n1p1, which has no file system, are left blank.
-d leaves out the partition lines and prints only the disk line.
With -p, /dev/ is added in front of device names, so you can pass the printed paths straight to other commands.

2️⃣ lsblk -f: checking file systems and UUIDs

The basic output does not show file system types, so use -f to check how a partition was formatted. -f prints eight columns: NAME, FSTYPE, FSVER, LABEL, UUID, FSAVAIL, FSUSE%, and MOUNTPOINTS.

lsblk -f -e 7
NAME        FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1                                                                            
├─nvme0n1p1                                                                        
├─nvme0n1p2 vfat   FAT16       5A1E-3B7C                             192.1M     4% /boot/efi
├─nvme0n1p3 xfs                6d2f0c4e-8b1a-4f3d-a7e2-9c5b1d0e4f28  691.4M    28% /boot
└─nvme0n1p4 xfs                2b9e7f41-c3d6-4a85-b0f1-7e4a2c9d6b13   68.5G    13% /

When we ran it, the root and /boot partitions were xfs, and /boot/efi was vfat in the FAT16 version. The disk nvme0n1 and nvme0n1p1 have no file system, so they were left blank. A UUID is a unique number given to each file system, and /etc/fstab uses it to specify the partition to mount by UUID instead of by device name.

To check file system information most accurately, the blkid command is the one to use.

FSAVAIL and FSUSE% are the free space and usage rate of a mounted file system. Partitions that are not mounted show no values. The df command prints only the size and usage of mounted file systems. lsblk prints the disk and partition layout as well, whether or not they are mounted.

3️⃣ lsblk -o to choose columns and -b for bytes

Write column names after -o, separated by commas, and only those columns appear in that order. The available column names are listed at the end of [lsblk --help].

lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT -e 7
NAME         SIZE FSTYPE MOUNTPOINT
nvme0n1       80G        
├─nvme0n1p1    1M        
├─nvme0n1p2  200M vfat   /boot/efi
├─nvme0n1p3    1G xfs    /boot
└─nvme0n1p4 78.8G xfs    /

MOUNTPOINT prints only one mount point, while MOUNTPOINTS prints all of them when the same file system is mounted in several places. To add just one column after the default columns, put + in front of the column name, as in [-o +UUID].

-b prints sizes as integers in bytes. The default units are easier to read when comparing by eye, so -b suits scripts that calculate or compare sizes.

lsblk -b -o NAME,SIZE -e 7
NAME               SIZE
nvme0n1     85899345920
├─nvme0n1p1     1048576
├─nvme0n1p2   209715200
├─nvme0n1p3  1073741824
└─nvme0n1p4 84613774848

G and M in the default output are units of 1,024, so the 80G disk appears as 85,899,345,920 bytes.

4️⃣ lsblk -d for a disk list and -p for full paths

On a server with several disks, the partition lines get mixed in and make the disk list hard to read, so use -d to leave out the partitions and print only the disk lines.

lsblk -d -e 7
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:0    0  80G  0 disk 

Only the single line for the disk nvme0n1 remained in the output, and the four partition lines below it did not appear.

With -p, /dev/ is added in front of device names, and they appear as full paths. You can pass these paths straight to other commands such as mount.

lsblk -p -e 7
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
/dev/nvme0n1     259:0    0   80G  0 disk 
├─/dev/nvme0n1p1 259:1    0    1M  0 part 
├─/dev/nvme0n1p2 259:2    0  200M  0 part /boot/efi
├─/dev/nvme0n1p3 259:3    0    1G  0 part /boot
└─/dev/nvme0n1p4 259:4    0 78.8G  0 part /

Only the NAME column changes to full paths, from /dev/nvme0n1 to /dev/nvme0n1p4, and the other columns are the same as in the default output.

If you pass a device path as an argument, only that device and the partitions below it are printed; if you pass a partition path, only that one partition line appears.

lsblk /dev/nvme0n1p4
NAME      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
nvme0n1p4 259:4    0 78.8G  0 part /

Only the one line for nvme0n1p4 appears in the output, without the disk line or branch marks. When we passed a device path that does not exist, a [not a block device] error appeared and the exit code was 32.

5️⃣ lsblk command output and options for scripts

It is tempting to cut up the default output in scripts, but the column layout of the default output and of -f may change in the future, so in scripts specify the columns yourself with -o.

-n leaves out the header line and prints only the values, so it suits cases where you need a single value, such as the file system type of one partition.

lsblk -no FSTYPE /dev/nvme0n1p4
xfs

With no header line, only one word appears, xfs, the file system type of the root partition, so you can store it directly in a shell variable.

-P prints each column in the form [name=”value”] on one line. In util-linux 2.37 on AlmaLinux 9, adding -P alone renames columns so they are easy to read as shell variables, such as MAJ:MIN to MAJ_MIN and FSUSE% to FSUSE_PCT.

lsblk -P -o NAME,FSTYPE,MOUNTPOINT /dev/nvme0n1p4
NAME="nvme0n1p4" FSTYPE="xfs" MOUNTPOINT="/"

The three columns you specified appear on one line in the order NAME, FSTYPE, MOUNTPOINT. All values are enclosed in double quotes.

-J prints JSON. Without -d, partitions go into the children array under the disk. Used together with -b, only size turns into a number, and other size columns such as FSAVAIL stay strings.

lsblk -J -d -o NAME,SIZE,TYPE -e 7
{
   "blockdevices": [
      {
         "name": "nvme0n1",
         "size": "80G",
         "type": "disk"
      }
   ]
}

With -d, the blockdevices array holds only the disk, and the children array does not appear.

🔲 lsblk command options

OptionCopyDescription
-e, --excludeExcludes devices with the given major number. Specifying 7 leaves out loop devices.
-f, --fsPrints the file system type, UUID, free space, and usage rate.
-o, --outputPrints only the columns given, separated by commas, in that order.
-b, --bytesPrints the SIZE column as integers in bytes.
-d, --nodepsLeaves out partition lines and prints only disk lines.
-p, --pathsPrints device names as full paths starting with /dev/.
-n, --noheadingsLeaves out the header line and prints only the values.
-P, --pairsPrints column names and values in pairs on one line.
-J, --jsonPrints in JSON format.
-a, --allAlso prints empty devices with a size of 0.
OptionCopyDescription
-I, --includePrints only devices with the given major number.
-l, --listPrints in list format instead of a tree.
-r, --rawPrints in raw format without aligning the columns.
-i, --asciiPrints the tree lines with ASCII characters.
-s, --inverseReverses the dependencies and prints disks below partitions.
-S, --scsiPrints only SCSI device information.
-t, --topologyPrints topology information such as sector size and I/O scheduler.
-m, --permsPrints the owner, group, and permissions of devices.
-x, --sortSorts by the given column and prints in list format.
-O, --output-allPrints all available columns.

🔲 lsblk command simulator

In the simulator below, you can type the commands so far yourself and see how the output changes with each option.

lsblk Command Simulatorutil-linux 2.37.4
[root@server work]#
Use the ↑↓ keys to recall commands you typed earlier.

🔢 FAQ & Recommended Content

Running -f as a regular user printed UUID and FSAVAIL the same as the root account. lsblk reads sysfs and udev information. When udev information is not available, it has to read the device directly, which requires root privileges.

Right after a device is added or changed, udev may not have gathered all the information yet, so run udevadm settle and then run lsblk again.

-a also prints empty devices with a size of 0, so use it to check whether any device is missing from the default output. On the same server, adding -a printed one more line: a 0B loop device with nothing attached.

ℹ️ Affiliate Disclosure
This site's content contains affiliate links. When a visitor buys a product or service through one of them, the site receives a commission from the seller. The amount the buyer pays(it goes down during event discounts ↓)does not go up. Posted prices, discounts, and stock reflect the time of writing and may differ, so confirm with the seller before buying. Products are chosen and reviewed by our own standards, and commissions do not affect the order or content of reviews.

Leave a Reply

Your email address will not be published. Required fields are marked *

Prove your humanity: 0   +   3   =