Selected topic

Lsblk

Disk Management

Prefer practical output? Use related tools below while reading.

lsblk is a command-line utility in Linux that provides detailed information about disk devices, including partitions and file systems. It's an essential tool for system administrators, developers, and power users who need to manage disks, partitions, and file systems.

Key Features of lsblk:


  1. Disk Information: lsblk displays the list of block devices (disks) attached to the system.
  2. Partition Information: It shows details about disk partitions, including their size, start sector, and UUID.
  3. File System Information: The command provides information about file systems on each partition, such as type, size, and mount points.

Example Usage:


Let's consider a scenario where we have two disks attached to our system:

  • /dev/sda with three partitions (sda1, sda2, and sda3)
  • /dev/sdb with one partition (sdb1)
We can run the following command to see the disk information:
bash
lsblk -o NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE,RO
This will output:
NAME  FSTYPE    LABEL MOUNTPOINT  SIZE RO
sda   vfat      boot  /boot       256M 
├─sda1 vfat      boot  /boot       255M 
└─sda2 ext4               /         32G  
sda3  swap              [SWAP]    512M ro
sdb   ntfs               -        1000G
└─sdb1 ntfs               C:       999G
In this example, we can see:
  • NAME: The disk device name.
  • FSTYPE: The file system type (e.g., vfat for /dev/sda).
  • LABEL: A label assigned to the partition (not always present).
  • MOUNTPOINT: The mount point of the partition (if it's mounted).
  • SIZE: The size of the disk or partition.
  • RO: Whether the file system is read-only.
You can customize the output by specifying specific columns using the -o option, as shown above.