List information about block devices
The lsblk command lists information about all available or specified block devices. It displays dependencies between devices but does not list RAM disks. Block devices include hard drives, flash drives, CD-ROMs, etc. The lsblk command is part of the util-linux package.
-a, --all # Display all devices.
-b, --bytes # Print the SIZE column in bytes rather than in a human-readable format.
-d, --nodeps # Don't print device holders or slaves.
-D, --discard # Print information about the discarding capabilities (TRIM/UNMAP) for each device.
-e, --exclude <list> # Exclude devices by major number.
-f, --fs # Output info about file systems.
-h, --help # Display help information.
-i, --ascii # Use ASCII characters for tree formatting.
-m, --perms # Output info about device owner, group and mode.
-l, --list # Use list output format.
-n, --noheadings # Do not print a header line.
-o, --output <list> # Specify which output columns to print.
-P, --pairs # Use key="value" output format.
-r, --raw # Use raw output format.
-t, --topology # Output info about topology.
By default, lsblk lists block devices in a tree-like format:
lsblk
NAME MAJ:MIN rm SIZE RO type mountpoint
sda 8:0 0 232.9G 0 disk
├─sda1 8:1 0 46.6G 0 part /
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 190M 0 part /boot
├─sda6 8:6 0 3.7G 0 part [SWAP]
├─sda7 8:7 0 93.1G 0 part /data
└─sda8 8:8 0 89.2G 0 part /personal
sr0 11:0 1 1024M 0 rom
The columns are:
Show all devices, including empty ones:
lsblk -a
Show permissions and ownership:
lsblk -m
Show size in bytes for a specific device:
lsblk -b /dev/sda
# or
lsblk --bytes /dev/sda
List format without headings:
lsblk -nl
List SCSI devices:
lsblk -S
Reverse dependency order:
lsblk -s