LSBLK(8) | System Administration | LSBLK(8) |
NAME
lsblk - list block devices
SYNOPSIS
lsblk [options] [device...]
DESCRIPTION
lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information. If the udev db is not available or lsblk is compiled without udev support, then it tries to read LABELs, UUIDs and filesystem types from the block device. In this case root permissions are necessary.
By default, the command prints all block devices (except RAM disks) in a tree-like format. The same device can be repeated in the tree if it relates to other devices. The --merge option is recommended for more complicated setups to gather groups of devices and describe complex N:M relationships.
The tree-like output (or children[] array in the JSON output) is enabled only if NAME column it present in the output or when --tree command line option is used. See also --nodeps and --list to control the tree formatting.
The default output, as well as the default output from options like --fs and --topology, is subject to change. So whenever possible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using --output columns-list and --list in environments where a stable output is required.
Use lsblk --list-columns to get a list of all available columns.
Note that lsblk might be executed in time when udev does not have all information about recently added or modified devices yet. In this case it is recommended to use udevadm settle before lsblk to synchronize with udev.
The relationship between block devices and filesystems is not always one-to-one. The filesystem may use more block devices, or the same filesystem may be accessible by more paths. This is the reason why lsblk provides MOUNTPOINT and MOUNTPOINTS (pl.) columns. The column MOUNTPOINT displays only one mount point (usually the last mounted instance of the filesystem), and the column MOUNTPOINTS displays by multi-line cell all mount points associated with the device.
OPTIONS
-A, --noempty
-a, --all
-b, --bytes
By default, the unit, sizes are expressed in, is byte, and unit prefixes are in power of 2^10 (1024). Abbreviations of symbols are exhibited truncated in order to reach a better readability, by exhibiting alone the first letter of them; examples: "1 KiB" and "1 MiB" are respectively exhibited as "1 K" and "1 M", then omitting on purpose the mention "iB", which is part of these abbreviations.
-H, --list-columns
-D, --discard
-d, --nodeps
-E, --dedup column
The usual use case is to de-duplicate output on system multi-path devices, for example by -E WWN.
-e, --exclude list
-f, --fs
-I, --include list
-i, --ascii
-J, --json
-l, --list
-M, --merge
-m, --perms
-N, --nvme
-v, --virtio
-n, --noheadings
-o, --output list
The default list of columns may be extended if list is specified in the format +list (e.g., lsblk -o +UUID).
-O, --output-all
-P, --pairs
-p, --paths
-Q, --filter expr
This feature is EXPERIMENTAL. See also scols-filter(5). For example exclude sda and sdb, but print everything else ('!~' is a negative regular expression matching operator):
lsblk --filter 'NAME !~ "sd[ab]"'
--highlight expr
--ct name [: param [: function ]]
If the param is not specified, then the counter counts the number of lines. This feature is EXPERIMENTAL. See also --ct-filter.
For example, --ct MyCounter:SIZE:sum will count the summary for SIZE from all lines; and to count the number of SATA disks, it is possible to use:
lsblk --ct-filter 'TYPE=="disk" && TRAN=="sata"' --ct "Number of SATA devices"
--ct-filter expr
lsblk --ct-filter 'TYPE=="part"' --ct Partitions:SIZE:sum \ --ct-filter 'TYPE=="disk"' --ct WholeDisks:SIZE:sum
-r, --raw
-S, --scsi
-s, --inverse
-T, --tree[=column]
-t, --topology
-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,RA,WSAME.
-h, --help
-V, --version
-w, --width number
-x, --sort column
-y, --shell
-z, --zoned
--sysroot directory
EXIT STATUS
0
1
32
64
ENVIRONMENT
LSBLK_DEBUG=all
LIBBLKID_DEBUG=all
LIBMOUNT_DEBUG=all
LIBSMARTCOLS_DEBUG=all
LIBSMARTCOLS_DEBUG_PADDING=on
NOTES
For partitions, some information (e.g., queue attributes) is inherited from the parent device.
The lsblk command needs to be able to look up each block device by major:minor numbers, which is done by using /sys/dev/block. This sysfs block directory appeared in kernel 2.6.27 (October 2008). In case of problems with a new enough kernel, check that CONFIG_SYSFS was enabled at the time of the kernel build.
AUTHORS
Milan Broz <gmazyland@gmail.com>, Karel Zak <kzak@redhat.com>
SEE ALSO
REPORTING BUGS
For bug reports, use the issue tracker at https://github.com/util-linux/util-linux/issues.
AVAILABILITY
The lsblk command is part of the util-linux package which can be downloaded from Linux Kernel Archive https://www.kernel.org/pub/linux/utils/util-linux/.
2024-07-04 | util-linux 2.40.2 |