]> git.ipfire.org Git - thirdparty/util-linux.git/blame - misc-utils/lsblk.8
libsmartcols: sanitize variable names on export output
[thirdparty/util-linux.git] / misc-utils / lsblk.8
CommitLineData
ceefa682 1.TH LSBLK 8 "February 2013" "util-linux" "System Administration"
2a4c734b
MB
2.SH NAME
3lsblk \- list block devices
4.SH SYNOPSIS
5.B lsblk
f49ccec2 6[options]
ceefa682 7.RI [ device ...]
2a4c734b
MB
8.SH DESCRIPTION
9.B lsblk
ceefa682 10lists information about all available or the specified block devices. The
2a4c734b 11.B lsblk
8d7f2904 12command reads the
3c2e64b0
KZ
13.B sysfs
14filesystem and
15.B udev db
4aabe429
MK
16to gather information. If the udev db is not available or
17.B lsblk
18is compiled without udev support, then it
06a27566
KZ
19tries to read LABELs, UUIDs and filesystem types from the block device. In this case root permissions
20are necessary.
2a4c734b 21.PP
8d7f2904
BS
22The command prints all block devices (except RAM disks) in a tree-like format
23by default. Use
1c4c6024 24.B "lsblk \-\-help"
8d7f2904 25to get a list of all available columns.
980358f1 26.PP
ceefa682 27The default output, as well as the default output from options like
0bb7e904 28.B \-\-fs
ceefa682
BS
29and
30.BR \-\-topology ,
31is subject to change. So whenever possible, you should avoid using default
32outputs in your scripts. Always explicitly define expected columns by using
980358f1 33.B \-\-output
ceefa682 34.I columns-list
b9c088f2
KZ
35and
36.B \-\-list
ceefa682 37in environments where a stable output is required.
3c2e64b0
KZ
38.PP
39Note that
40.B lsblk
41might be executed in time when
42.B udev
43does not have all information about recently added or modified devices yet. In this
44case it is recommended to use
45.B "udevadm settle"
4aabe429
MK
46before
47.B lsblk
48to synchronize with udev.
2a4c734b 49.SH OPTIONS
ceefa682
BS
50.TP
51.BR \-a , " \-\-all"
3d15a5e8 52Also list empty devices and RAM disk devices.
ceefa682
BS
53.TP
54.BR \-b , " \-\-bytes"
55Print the SIZE column in bytes rather than in a human-readable format.
56.TP
57.BR \-D , " \-\-discard"
58Print information about the discarding capabilities (TRIM, UNMAP) for each device.
59.TP
60.BR \-d , " \-\-nodeps"
1c4c6024 61Do not print holder devices or slaves. For example, \fBlsblk \-\-nodeps /dev/sda\fR prints
f31505fe 62information about the sda device only.
ceefa682 63.TP
0bd05f5e
KZ
64.BR \-E , " \-\-dedup " \fIcolumn\fP
65Use \fIcolumn\fP as a de-duplication key to de-duplicate output tree. If the
66key is not available for the device, or the device is a partition and parental
67whole-disk device provides the same key than the device is always printed.
68
69The usual use case is to de-duplicate output on system multi-path devices, for
70example by \fB\-E WWN\fR.
71.TP
ceefa682
BS
72.BR \-e , " \-\-exclude " \fIlist\fP
73Exclude the devices specified by the comma-separated \fIlist\fR of major device numbers.
fd5f21ca
AE
74Note that RAM disks (major=1) are excluded by default if \fB\-\-all\fR is not specified.
75The filter is applied to the top-level devices only. This may be confusing for
881953d7 76\fB\-\-list\fR output format where hierarchy of the devices is not obvious.
ceefa682
BS
77.TP
78.BR \-f , " \-\-fs"
79Output info about filesystems. This option is equivalent to
1c4c6024 80.BR \-o\ NAME,FSTYPE,LABEL,UUID,FSAVAIL,FSUSE%,MOUNTPOINT .
8d7f2904 81The authoritative information about filesystems and raids is provided by the
2a4c734b
MB
82.BR blkid (8)
83command.
ceefa682
BS
84.TP
85.BR \-h , " \-\-help"
b4362b6f 86Display help text and exit.
ceefa682
BS
87.TP
88.BR \-I , " \-\-include " \fIlist\fP
89Include devices specified by the comma-separated \fIlist\fR of major device numbers.
fd5f21ca 90The filter is applied to the top-level devices only. This may be confusing for
881953d7 91\fB\-\-list\fR output format where hierarchy of the devices is not obvious.
ceefa682
BS
92.TP
93.BR \-i , " \-\-ascii"
6ea1bdd3 94Use ASCII characters for tree formatting.
ceefa682 95.TP
4a102a48 96.BR \-J , " \-\-json"
fb376180
KZ
97Use JSON output format. It's strongly recommended to use \fB\-\-output\fR and
98also \fB\-\-tree\fR if necessary.
4a102a48 99.TP
ceefa682 100.BR \-l , " \-\-list"
0bd05f5e
KZ
101Produce output in the form of a list. The output does not provide information
102about relationships between devices and since version 2.34 every device is
91b636b5
KZ
103printed only once if \fB\-\-pairs\fR or \fB\-\-raw\fR not specified (the
104parsable outputs are maintained in backwardly compatible way).
ceefa682 105.TP
0bd05f5e
KZ
106.BR \-M , " \-\-merge"
107Group parents of sub-trees to provide more readable output for RAIDs and
108Multi-path devices. The tree-like output is required.
dc4662f0 109.TP
ceefa682
BS
110.BR \-m , " \-\-perms"
111Output info about device owner, group and mode. This option is equivalent to
1c4c6024 112.BR \-o\ NAME,SIZE,OWNER,GROUP,MODE .
ceefa682
BS
113.TP
114.BR \-n , " \-\-noheadings"
2a4c734b 115Do not print a header line.
ceefa682
BS
116.TP
117.BR \-o , " \-\-output " \fIlist\fP
8d7f2904 118Specify which output columns to print. Use
ceefa682 119.B \-\-help
fb376180
KZ
120to get a list of all supported columns. The columns may affect tree-like output.
121The default is to use tree for the column 'NAME' (see also \fB\-\-tree\fR).
36fb1007 122
37684203 123The default list of columns may be extended if \fIlist\fP is
1c4c6024 124specified in the format \fI+list\fP (e.g., \fBlsblk \-o +UUID\fP).
ceefa682 125.TP
c5178f27 126.BR \-O , " \-\-output\-all"
1b4d2a4a
MY
127Output all available columns.
128.TP
ceefa682 129.BR \-P , " \-\-pairs"
91b636b5 130Produce output in the form of key="value" pairs. The output lines are still ordered by
58b510e5
KZ
131dependencies. All potentially unsafe value characters are hex-escaped (\\x<code>).
132The key (variable name) will be modified to contain only characters allowed for a shell variable
133identifiers, for example, MIN_IO and FSUSE_PCT instead of MIN-IO and FSUSE%.
ceefa682 134.TP
c7e76cd1
KZ
135.BR \-p , " \-\-paths"
136Print full device paths.
137.TP
ceefa682 138.BR \-r , " \-\-raw"
91b636b5
KZ
139Produce output in raw format. The output lines are still ordered by
140dependencies. All potentially unsafe characters are hex-escaped
ceefa682
BS
141(\\x<code>) in the NAME, KNAME, LABEL, PARTLABEL and MOUNTPOINT columns.
142.TP
143.BR \-S , " \-\-scsi"
144Output info about SCSI devices only. All partitions, slaves and holder devices are ignored.
145.TP
146.BR \-s , " \-\-inverse"
091683a8
KZ
147Print dependencies in inverse order. If the \fB\-\-list\fR output is requested then
148the lines are still ordered by dependencies.
ceefa682 149.TP
b9c088f2
KZ
150.BR \-T , " \-\-tree" [ =\fIcolumn ]
151Force tree-like output format. If \fIcolumn\fP is specified, then a tree is printed in the column.
152The default is NAME column.
153.TP
ceefa682
BS
154.BR \-t , " \-\-topology"
155Output info about block-device topology.
156This option is equivalent to
1c4c6024 157.BR \-o\ NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,RA,WSAME .
ceefa682
BS
158.TP
159.BR \-V , " \-\-version"
b4362b6f 160Display version information and exit.
642048e4 161.TP
7636d906
KZ
162.BR \-w , " \-\-width " \fInumber\fP
163Specifies output width as a number of characters. The default is the number of
164the terminal columns, and if not executed on a terminal, then output width is not
165restricted at all by default. This option also forces lsblk to assume that terminal
166control characters and unsafe characters are not allowed. The expected use-case is
167for example when lsblk used by
168.BR watch (1)
169command.
170.TP
642048e4 171.BR \-x , " \-\-sort " \fIcolumn\fP
1d9e35cc
KZ
172Sort output lines by \fIcolumn\fP. This option enables \fB\-\-list\fR output format by default.
173It is possible to use the option \fI\-\-tree\fP to force tree-like output and
174than the tree branches are sorted by the \fIcolumn\fP.
498d1486 175.TP
0bd05f5e
KZ
176.BR \-z , " \-\-zoned"
177Print the zone model for each device.
178.TP
498d1486 179.BR " \-\-sysroot " \fIdirectory\fP
4aabe429
MK
180Gather data for a Linux instance other than the instance from which the
181.B lsblk
498d1486 182command is issued. The specified directory is the system root of the Linux
6f74ede5
KZ
183instance to be inspected. The real device nodes in the target directory can
184be replaced by text files with udev attributes.
498d1486 185
7e765c93 186.SH EXIT STATUS
1539750f
KZ
187.IP 0
188success
189.IP 1
190failure
191.IP 32
e12364cd 192none of specified devices found
1539750f
KZ
193.IP 64
194some specified devices found, some not found
195
ca3dbca1 196.SH ENVIRONMENT
3476084d 197.IP LSBLK_DEBUG=all
4aabe429
MK
198enables
199.B lsblk
200debug output.
68e422ec
KZ
201.IP LIBBLKID_DEBUG=all
202enables libblkid debug output.
203.IP LIBMOUNT_DEBUG=all
204enables libmount debug output.
205.IP LIBSMARTCOLS_DEBUG=all
206enables libsmartcols debug output.
37948503
KZ
207.IP LIBSMARTCOLS_DEBUG_PADDING=on
208use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
67e63c12
MK
209.SH NOTES
210For partitions, some information (e.g., queue attributes) is inherited from the
211parent device.
212.PP
213The
214.B lsblk
215command needs to be able to look up each block device by major:minor numbers,
216which is done by using
217.IR /sys/dev/block .
218This sysfs block directory appeared in kernel 2.6.27 (October 2008).
219In case of problems with a new enough kernel, check that CONFIG_SYSFS
220was enabled at the time of the kernel build.
221
ade04bb8
MK
222.SH AUTHORS
223.nf
224Milan Broz <mbroz@redhat.com>
225Karel Zak <kzak@redhat.com>
226.fi
2a4c734b 227.SH SEE ALSO
f053ff1e 228.BR ls (1),
2a4c734b 229.BR blkid (8),
f053ff1e 230.BR findmnt (8)
2a4c734b 231.SH AVAILABILITY
601d12fb 232The lsblk command is part of the util-linux package and is available from
d673b74e 233https://www.kernel.org/pub/linux/utils/util-linux/.