lsblk Command

Purpose

Lists block devices such as disks, partitions, LVM, RAID, loop in a tree-like or list format with detailed system information.

Syntax

lsblk [ -a ] [ -b ] [ -d ] [ -D ] [ -e ] [ -f ] [ -h ] [ -i ] [ -I ] [ -J ] [ -l ] [ -m ] [ -n ] [ -o ] [ -O ] [ -p ] [ -P ] [ -r ] [ -s ] [ -S ] [ -t ] [ -T ] [ -V ] [ -x ] [ -z ]

Description

The lsblk command lists block devices such as disks, partitions, LVM, RAID, loop in a tree-like or list format with detailed system information. In PowerVC virtual appliance, only read-only display is allowed for security. Device modification, mounting, or writing is not allowed.

Flags

Table 1. Flags
Item Description
-a or --all Lists all devices, including empty, holder-less, or disabled devices. For example, unpartitioned disks, loop devices without backing files.
-b or --bytes Prints the capacity in raw bytes instead of human-readable format. For example, the capacity is displayed as, 2000398934016 instead of 1.8 T. This option is ideal for scripting.
-d or --nodeps Lists only the base devices. For example, this option shows /dev/sda but does not list its partitions.
-D or --discard Displays information about discard (TRIM) capabilities of block devices. For example DISC-ALN, DISC-GRAN, DISC-MAX, DISC-ZERO.
-e list or --exclude list Lists devices by excluding the devices based on the specified major device number. The list is comma-separated major device numbers that must be excluded. If no major device number is specified, the RAM disks (1) and loop disks (7) are excluded by default.
-f or --fs Displays the file system information. For example, FSTYPE, LABEL, UUID, MOUNTPOINT.
-h or --help Displays help about the lsblk command.
-i or --ascii Uses only ASCII characters for tree lines. This option does not use the UTF-8 box-drawing characters. The output of this option is safe for logs and scripts.
-I list or --include list Displays the devices with the specified major device numbers. The list is comma-separated major device numbers for which the information must be displayed.
-J or --json Redirects the results in a JSON format for scripting and automation.
-l or --list Displays the output in a list format. This option displays information about one device per line. The output of this option is easier to parse.
-m or --perms Displays the devices along with their file system permissions. For example, OWNER, GROUP, MODE of device nodes.
-n or --noheadings Displays the device list without the column headers in a simple format. Then output of this option is ideal to work with grep or awk command.
-o column_list or --output column_list Displays device information only for the specified columns headings. A list of column headers can be specified separated by commas. For more information about the available column headers, see Column headers.
-O or --output-all Displays all the available columns.
-p or --paths Displays the full device paths. For example, this option displays /dev/sda1 instead of sda1.
-P or --pairs Displays the device information as Key="value" pair. The information is displayed one line at a time. This option is idle for shell parsing.
-r or --raw Displays raw output. The output is not aligned. Only minimum formatting is done to the data.
-s or --inverse Display device information in an inverted, dependency-based order. The lsblk command prints the mount point or partition first, followed by the physical disk it resides on, reversing the standard output tree.
-S or --scsi Displays only the Small Computer System Interface (SCSI) devices.
-t or --topology Displays I/O topology. For example, ALIGNMENT, MIN-IO, OPT-IO, PHY-SEC, LOG-SEC, SCHED, RQ-SIZE.
-T or --tree Displays the device information in a tree format. The default view of the output of the lsblk command is in tree format.
-V or --version Displays version information.
-x column or --sort column Sorts the output by a specific column.
-z or --zoned Displays zoned storage model in the ZONED column. For zoned namespace (ZNS) Solid-State Drives (SSDs). For example, none, host-aware, host-managed.

Column headers

The -o parameter is followed by a list of columns that must be displayed in the output. The device information has the following column headings:
Table 2. Column headers
Column headers Description
NAME Specifies the device name.
KNAME Specifies the internal kernel name of the device.
MAJ:MIN Specifies the major or minor device number.
FSTYPE Specifies the file system type.
MOUNTPOINT Specifies the mount path.
LABEL Specifies the file system label.
UUID Specifies the file system Universally Unique Identifier (UUID).
PARTLABEL Specifies the GUID Partition Table (GPT) partition label.
PARTUUID Specifies the GPT partition UUID.
SIZE Specifies the total capacity.
RO Specifies whether the devices are read-only. If the value is 1, the device is read-only.
RM Specifies whether the devices are removable. If the value is 1, the device is removable.
MODEL Specifies the disk model name.
SERIAL Specifies the serial number of the devices.
STATE Specifies the state of the devices. For example, running, suspended.
TYPE Specifies the type of the devices. For example, disk, part, lvm, loop, rom.
ZONED Specifies the zone model of a device.
TRAN Specifies the device transport type.
SCHED Specifies the I/O scheduler name that is used for the device.

Examples

  1. To list block devices in a tree structure, enter the following command:
    lsblk
  2. To list all the devices that include empty devices, enter the following command:
    lsblk -a
  3. To list only the base devices, enter the following command:
    lsblk -d
  4. To list file systems and mount points, enter the following command:
    lsblk -f
  5. To direct the output without any column headers to a JSON file, enter the following command:
    lsblk -J -n
  6. To display only the NAME, SIZE, TYPE, FSTYPE, and MOUNTPOINT columns, enter the following command:
    lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT
  7. To display all the columns, enter the following command:
    lsblk -O
  8. To display the NAME, SIZE, and FSTYPE columns in a key=value pair, enter the following command:
    lsblk -P -o NAME,SIZE,FSTYPE
  9. To display the SSD TRIM support, enter the following command:
    lsblk -D -o NAME,DISC-GRAN,DISC-MAX,DISC-ZERO
  10. To sort disks by size in descending order and display the NAME, SIZE, and MODEL columns, enter the following command:
    lsblk -d -x SIZE -o NAME,SIZE,MODEL
  11. To display the device information in an inverted, dependency-based order, enter the following command:
    lsblk -s