lsblk
List block devices
TLDR
List all storage devices in a tree-like format
Also list empty devices
Print the SIZE column in bytes rather than in a human-readable format
Output info about filesystems
Use ASCII characters for tree formatting
Output info about block-device topology
Exclude the devices specified by the comma-separated list of major device numbers
Display a customized summary using a comma-separated list of columns
SYNOPSIS
lsblk [options] [device...]
PARAMETERS
-a, --all
List all block devices. The default is to exclude empty devices.
-b, --bytes
Print SIZE in bytes rather than in human-readable format.
-d, --nodeps
Don't print slaves or holders.
-D, --discard
Print discard (trim) capabilities.
-e, --exclude list
Exclude devices by major number (list is a comma-separated list).
-f, --fs
Output filesystem information.
-i, --ascii
Use ASCII characters for tree formatting.
-I, --inode
Print inode information.
-J, --json
Use JSON output format.
-l, --list
Use list format.
-m, --perms
Output permissions information.
-n, --noheadings
Don't print headings.
-o, --output list
Output columns. See below for a list of available columns.
-O, --output-all
Output all columns.
-P, --pairs
Use key="value" output format.
-r, --raw
Use raw output format.
-S, --scsi
Output SCSI information.
-t, --topology
Output topology information.
-v, --version
Display version information and exit.
-w, --width width
Specify output width.
-x, --sort column
Sort output by column.
DESCRIPTION
The `lsblk` command is a utility used to list information about block devices on a Linux system. It displays information about all available block devices (except RAM disks) and provides details about their partitions, sizes, mount points, and other related attributes. Unlike `fdisk`, `lsblk` does not provide partition management capabilities; it's purely an information tool. `lsblk` is part of the util-linux package, making it widely available across different Linux distributions. It reads the /sys filesystem to gather information about the connected storage devices, offering a more user-friendly output compared to directly reading the device files. `lsblk` is valuable for system administrators and users who need to quickly identify storage devices and their configurations, troubleshoot storage-related problems, or understand the overall storage layout of a system. It is particularly helpful in environments with complex storage configurations, such as those involving RAID arrays or logical volumes.
CAVEATS
The information displayed by `lsblk` is read from the `/sys` filesystem. Therefore, the command requires appropriate permissions (usually root) to access all device information. It also may not represent the actual device configuration if devices have been changed without informing the system, and will fail if /sys is not mounted or accessible.
OUTPUT COLUMNS
The `--output` option allows you to specify which columns to display. Some common columns include:
NAME: Device name
MAJ:MIN: Major:minor device number
RM: Removable device
SIZE: Size of the device
RO: Read-only
TYPE: Device type (disk, partition, etc.)
MOUNTPOINT: Mount point
FSTYPE: Filesystem type
LABEL: Filesystem label
UUID: Filesystem UUID
JSON OUTPUT
The `--json` option is useful for scripting and automation. It provides a structured output format that can be easily parsed by other tools.
HISTORY
The `lsblk` command was introduced as part of the util-linux package. It's been widely adopted across various Linux distributions due to its ease of use and comprehensive display of block device information. Its development aimed to provide a more user-friendly interface to underlying device information than directly parsing files in `/dev` or using `fdisk`.