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