]> git.ipfire.org Git - thirdparty/util-linux.git/blame - misc-utils/lsblk.8.adoc
Merge branch 'sed' of https://github.com/t-8ch/util-linux
[thirdparty/util-linux.git] / misc-utils / lsblk.8.adoc
CommitLineData
295b3979 1//po4a: entry man manual
6c64d12d
MB
2= lsblk(8)
3:doctype: manpage
4:man manual: System Administration
5:man source: util-linux {release-version}
6:page-layout: base
7:command: lsblk
8
9== NAME
10
11lsblk - list block devices
12
13== SYNOPSIS
14
15*lsblk* [options] [_device_...]
16
17== DESCRIPTION
18
19*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.
20
46ead6f9 21By 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.
6c64d12d 22
ac9e7e75
KZ
23The 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.
24
6c64d12d
MB
25The 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.
26
c1b1b22e 27Use *lsblk --list-columns* to get a list of all available columns.
46ead6f9 28
6c64d12d
MB
29Note 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.
30
31The 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.
32
33== OPTIONS
34
554e866b
KZ
35*-A*, *--noempty*::
36Don't print empty devices.
37
6c64d12d 38*-a*, *--all*::
aab112dd 39Disable all built-in filters and list all empty devices and RAM disk devices too.
6c64d12d
MB
40
41*-b*, *--bytes*::
4c989ad4 42include::man-common/in-bytes.adoc[]
6c64d12d 43
ed02618d
KZ
44*-H*, *--list-columns*::
45List the available columns, use with *--json* or *--raw* to get output in machine-readable format.
46
6c64d12d 47*-D*, *--discard*::
2c646c80 48Print information about the discarding capabilities (TRIM, UNMAP) for each device.
6c64d12d
MB
49
50*-d*, *--nodeps*::
2c646c80 51Do not print holder devices or slaves. For example, *lsblk --nodeps /dev/sda* prints information about the sda device only.
6c64d12d
MB
52
53*-E*, *--dedup* _column_::
2c646c80
MB
54Use _column_ as a de-duplication key to de-duplicate output tree. If the key is not available for the device, or the device is a partition and parental whole-disk device provides the same key than the device is always printed.
55+
56The usual use case is to de-duplicate output on system multi-path devices, for example by *-E WWN*.
6c64d12d 57
3f347f95 58*-e*, *--exclude* _list_::
2c646c80 59Exclude the devices specified by the comma-separated _list_ of major device numbers. Note that RAM disks (major=1) are excluded by default if *--all* is not specified. The filter is applied to the top-level devices only. This may be confusing for *--list* output format where hierarchy of the devices is not obvious.
6c64d12d
MB
60
61*-f*, *--fs*::
2c646c80 62Output info about filesystems. This option is equivalent to *-o NAME,FSTYPE,FSVER,LABEL,UUID,FSAVAIL,FSUSE%,MOUNTPOINTS*. The authoritative information about filesystems and raids is provided by the *blkid*(8) command.
6c64d12d 63
6c64d12d 64*-I*, *--include* _list_::
2c646c80 65Include devices specified by the comma-separated _list_ of major device numbers. The filter is applied to the top-level devices only. This may be confusing for *--list* output format where hierarchy of the devices is not obvious.
6c64d12d
MB
66
67*-i*, *--ascii*::
2c646c80 68Use ASCII characters for tree formatting.
6c64d12d
MB
69
70*-J*, *--json*::
ac9e7e75 71Use JSON output format. It's strongly recommended to use *--output* and also *--tree* if necessary. Note that *children[]* is used only if NAME column or *--tree* is used.
6c64d12d
MB
72
73*-l*, *--list*::
2c646c80 74Produce output in the form of a list. The output does not provide information about relationships between devices and since version 2.34 every device is printed only once if *--pairs* or *--raw* not specified (the parsable outputs are maintained in backwardly compatible way).
6c64d12d
MB
75
76*-M*, *--merge*::
2c646c80 77Group parents of sub-trees to provide more readable output for RAIDs and Multi-path devices. The tree-like output is required.
6c64d12d
MB
78
79*-m*, *--perms*::
2c646c80 80Output info about device owner, group and mode. This option is equivalent to *-o NAME,SIZE,OWNER,GROUP,MODE*.
6c64d12d 81
97afabf7 82*-N*, *--nvme*::
83Output info about NVMe devices only.
84
1b3e8f5d 85*-v*, *--virtio*::
86Output info about virtio devices only.
87
6c64d12d 88*-n*, *--noheadings*::
2c646c80 89Do not print a header line.
6c64d12d
MB
90
91*-o*, *--output* _list_::
ed02618d 92Specify which output columns to print. Use *--list-columns* to get a list of all supported columns. The columns may affect tree-like output. The default is to use tree for the column 'NAME' (see also *--tree*).
2c646c80
MB
93+
94The default list of columns may be extended if _list_ is specified in the format _+list_ (e.g., *lsblk -o +UUID*).
6c64d12d
MB
95
96*-O*, *--output-all*::
2c646c80 97Output all available columns.
6c64d12d
MB
98
99*-P*, *--pairs*::
25fb0638 100Produce output in the form of key="value" pairs. The output lines are still ordered by dependencies. All potentially unsafe value characters are hex-escaped (\x<code>). See also option *--shell*.
6c64d12d
MB
101
102*-p*, *--paths*::
2c646c80 103Print full device paths.
6c64d12d 104
c1b1b22e
KZ
105*-Q*, *--filter* _expr_::
106Print only the devices that meet the conditions specified by the expr. The
107filter is assessed prior to lsblk collecting data for all output columns. Only
108the necessary data for the lazy evaluation of the expression is retrieved from
109the system. This approach can enhance performance when compared to
110post-filtering, as commonly done by tools such as grep(1).
111+
112This feature is EXPERIMENTAL. See also *scols-filter*(5). For example
113exclude sda and sdb, but print everything else ('!~' is a negative regular
114expression matching operator):
115____
116 lsblk --filter 'NAME !~ "sd[ab]"'
117____
118
119*--highlight* _expr_::
120Colorize lines matching the expression.
121This feature is EXPERIMENTAL. See also *scols-filter*(5).
122
123*--ct* _name_ [: _param_ [: _function_ ]]::
124Define a custom counter. The counters are printed after the standard output.
125The _name_ is the custom name of the counter, the optional _param_ is the name of the column
126to be used for the counter, and the optional _function_ specifies
127the aggregation function, supported functions are: count, min, max, or sum. The
128default is count.
129+
130If the _param_ is not specified, then the counter counts the number of lines. This
131feature is EXPERIMENTAL. See also *--ct-filter*.
132+
133For example, *--ct MyCounter:SIZE:sum* will count the summary for SIZE from all lines;
134and to count the number of SATA disks, it is possible to use:
135____
136
137 lsblk --ct-filter 'TYPE=="disk" && TRAN=="sata"' --ct "Number of SATA devices"
138____
139
140
141*--ct-filter* _expr_::
142Define a restriction for the next counter. This feature is EXPERIMENTAL. See also *--ct*
143and *scols-filter*(5). For example, aggregate sizes by device type:
144____
145 lsblk --ct-filter 'TYPE=="part"' --ct Partitions:SIZE:sum \
146 --ct-filter 'TYPE=="disk"' --ct WholeDisks:SIZE:sum
147____
148
6c64d12d 149*-r*, *--raw*::
2c646c80 150Produce output in raw format. The output lines are still ordered by dependencies. All potentially unsafe characters are hex-escaped (\x<code>) in the NAME, KNAME, LABEL, PARTLABEL and MOUNTPOINT columns.
6c64d12d
MB
151
152*-S*, *--scsi*::
2c646c80 153Output info about SCSI devices only. All partitions, slaves and holder devices are ignored.
6c64d12d
MB
154
155*-s*, *--inverse*::
2c646c80 156Print dependencies in inverse order. If the *--list* output is requested then the lines are still ordered by dependencies.
6c64d12d
MB
157
158*-T*, *--tree*[**=**__column__]::
2c646c80 159Force tree-like output format. If _column_ is specified, then a tree is printed in the column. The default is NAME column.
6c64d12d
MB
160
161*-t*, *--topology*::
2c646c80
MB
162Output info about block-device topology. This option is equivalent to
163+
164*-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,RA,WSAME*.
6c64d12d 165
2b2d3172 166include::man-common/help-version.adoc[]
6c64d12d
MB
167
168*-w*, *--width* _number_::
2c646c80 169Specifies output width as a number of characters. The default is the number of the terminal columns, and if not executed on a terminal, then output width is not restricted at all by default. This option also forces *lsblk* to assume that terminal control characters and unsafe characters are not allowed. The expected use-case is for example when *lsblk* is used by the *watch*(1) command.
6c64d12d
MB
170
171*-x*, *--sort* _column_::
2c646c80 172Sort output lines by _column_. This option enables *--list* output format by default. It is possible to use the option *--tree* to force tree-like output and than the tree branches are sorted by the _column_.
6c64d12d 173
25fb0638 174*-y*, *--shell*::
bd67ca44 175The column name will be modified to contain only characters allowed for shell variable identifiers, for example, MIN_IO and FSUSE_PCT instead of MIN-IO and FSUSE%. This is usable, for example, with *--pairs*. Note that this feature has been automatically enabled for *--pairs* in version 2.37, but due to compatibility issues, now it's necessary to request this behavior by *--shell*.
25fb0638 176
6c64d12d 177*-z*, *--zoned*::
e7252840 178Print the zone related information for each device.
6c64d12d
MB
179
180*--sysroot* _directory_::
2c646c80 181Gather data for a Linux instance other than the instance from which the *lsblk* command is issued. The specified directory is the system root of the Linux instance to be inspected. The real device nodes in the target directory can be replaced by text files with udev attributes.
6c64d12d
MB
182
183== EXIT STATUS
184
1850::
2c646c80 186success
6c64d12d
MB
187
1881::
2c646c80 189failure
6c64d12d
MB
190
19132::
2c646c80 192none of specified devices found
6c64d12d
MB
193
19464::
2c646c80 195some specified devices found, some not found
6c64d12d
MB
196
197== ENVIRONMENT
198
e6743239 199*LSBLK_DEBUG*=all::
2c646c80 200enables *lsblk* debug output.
6c64d12d 201
e6743239 202*LIBBLKID_DEBUG*=all::
2c646c80 203enables *libblkid* debug output.
6c64d12d 204
e6743239 205*LIBMOUNT_DEBUG*=all::
2c646c80 206enables *libmount* debug output.
6c64d12d 207
e6743239 208*LIBSMARTCOLS_DEBUG*=all::
2c646c80 209enables *libsmartcols* debug output.
6c64d12d 210
e6743239 211*LIBSMARTCOLS_DEBUG_PADDING*=on::
28af0586 212use visible padding characters.
6c64d12d
MB
213
214== NOTES
215
216For partitions, some information (e.g., queue attributes) is inherited from the parent device.
217
e6743239 218The *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.
6c64d12d
MB
219
220== AUTHORS
221
67b8731f 222mailto:gmazyland@gmail.com[Milan Broz],
6c64d12d
MB
223mailto:kzak@redhat.com[Karel Zak]
224
225== SEE ALSO
226
6c64d12d
MB
227*blkid*(8),
228*findmnt*(8)
c1b1b22e
KZ
229*ls*(1),
230*scols-filter*(5)
6c64d12d 231
625e9c61 232include::man-common/bugreports.adoc[]
6c64d12d 233
625e9c61 234include::man-common/footer.adoc[]
6c64d12d
MB
235
236ifdef::translation[]
625e9c61 237include::man-common/translation.adoc[]
6c64d12d 238endif::[]