]> git.ipfire.org Git - thirdparty/util-linux.git/blame - misc-utils/lsblk.8
lsblk: fix sysfs_devno_to_devname() usage
[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
2a4c734b 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
BS
32.I columns-list
33in environments where a stable output is required.
3c2e64b0
KZ
34.PP
35Note that
36.B lsblk
37might be executed in time when
38.B udev
39does not have all information about recently added or modified devices yet. In this
40case it is recommended to use
41.B "udevadm settle"
42before lsblk to synchronize with udev.
2a4c734b 43.SH OPTIONS
ceefa682
BS
44.TP
45.BR \-a , " \-\-all"
3d15a5e8 46Also list empty devices and RAM disk devices.
ceefa682
BS
47.TP
48.BR \-b , " \-\-bytes"
49Print the SIZE column in bytes rather than in a human-readable format.
50.TP
51.BR \-D , " \-\-discard"
52Print information about the discarding capabilities (TRIM, UNMAP) for each device.
53.TP
f2df4365
DLM
54.BR \-z , " \-\-zoned"
55Print the zone model for each device.
56.TP
ceefa682
BS
57.BR \-d , " \-\-nodeps"
58Do not print holder devices or slaves. For example, \fBlsblk --nodeps /dev/sda\fR prints
f31505fe 59information about the sda device only.
ceefa682
BS
60.TP
61.BR \-e , " \-\-exclude " \fIlist\fP
62Exclude the devices specified by the comma-separated \fIlist\fR of major device numbers.
3d15a5e8
KZ
63Note that RAM disks (major=1) are excluded by default if \fB\-\-all\fR is no specified.
64The filter is applied to the top-level devices only.
ceefa682
BS
65.TP
66.BR \-f , " \-\-fs"
67Output info about filesystems. This option is equivalent to
a79b7cab 68.BR -o\ NAME,FSTYPE,LABEL,UUID,MOUNTPOINT .
8d7f2904 69The authoritative information about filesystems and raids is provided by the
2a4c734b
MB
70.BR blkid (8)
71command.
ceefa682
BS
72.TP
73.BR \-h , " \-\-help"
b4362b6f 74Display help text and exit.
ceefa682
BS
75.TP
76.BR \-I , " \-\-include " \fIlist\fP
77Include devices specified by the comma-separated \fIlist\fR of major device numbers.
78The filter is applied to the top-level devices only.
79.TP
80.BR \-i , " \-\-ascii"
6ea1bdd3 81Use ASCII characters for tree formatting.
ceefa682 82.TP
4a102a48
KZ
83.BR \-J , " \-\-json"
84Use JSON output format.
85.TP
ceefa682
BS
86.BR \-l , " \-\-list"
87Produce output in the form of a list.
88.TP
89.BR \-m , " \-\-perms"
90Output info about device owner, group and mode. This option is equivalent to
91.BR -o\ NAME,SIZE,OWNER,GROUP,MODE .
92.TP
93.BR \-n , " \-\-noheadings"
2a4c734b 94Do not print a header line.
ceefa682
BS
95.TP
96.BR \-o , " \-\-output " \fIlist\fP
8d7f2904 97Specify which output columns to print. Use
ceefa682 98.B \-\-help
8d7f2904 99to get a list of all supported columns.
36fb1007 100
37684203
BS
101The default list of columns may be extended if \fIlist\fP is
102specified in the format \fI+list\fP (e.g. \fBlsblk -o +UUID\fP).
ceefa682 103.TP
b06c1ca6 104.BR \-O , " \-\-output\-all "
1b4d2a4a
MY
105Output all available columns.
106.TP
ceefa682
BS
107.BR \-P , " \-\-pairs"
108Produce output in the form of key="value" pairs.
109All potentially unsafe characters are hex-escaped (\\x<code>).
110.TP
c7e76cd1
KZ
111.BR \-p , " \-\-paths"
112Print full device paths.
113.TP
ceefa682
BS
114.BR \-r , " \-\-raw"
115Produce output in raw format. All potentially unsafe characters are hex-escaped
116(\\x<code>) in the NAME, KNAME, LABEL, PARTLABEL and MOUNTPOINT columns.
117.TP
118.BR \-S , " \-\-scsi"
119Output info about SCSI devices only. All partitions, slaves and holder devices are ignored.
120.TP
121.BR \-s , " \-\-inverse"
091683a8
KZ
122Print dependencies in inverse order. If the \fB\-\-list\fR output is requested then
123the lines are still ordered by dependencies.
ceefa682
BS
124.TP
125.BR \-t , " \-\-topology"
126Output info about block-device topology.
127This option is equivalent to
a79b7cab 128.BR -o\ NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,RA,WSAME .
ceefa682
BS
129.TP
130.BR \-V , " \-\-version"
b4362b6f 131Display version information and exit.
642048e4
KZ
132.TP
133.BR \-x , " \-\-sort " \fIcolumn\fP
1d9e35cc
KZ
134Sort output lines by \fIcolumn\fP. This option enables \fB\-\-list\fR output format by default.
135It is possible to use the option \fI\-\-tree\fP to force tree-like output and
136than the tree branches are sorted by the \fIcolumn\fP.
9830eca5 137.SH NOTES
68eebd53
PU
138For partitions, some information (e.g. queue attributes) is inherited from the
139parent device.
f65b3bb6
SK
140.PP
141The
142.B lsblk
ceefa682
BS
143command needs to be able to look up each block device by major:minor numbers,
144which is done by using
46f057ed 145.IR /sys/dev/block .
ceefa682
BS
146This sysfs block directory appeared in kernel 2.6.27 (October 2008).
147In case of problems with a new enough kernel, check that CONFIG_SYSFS
148was enabled at the time of the kernel build.
1539750f
KZ
149
150.SH RETURN CODES
151.IP 0
152success
153.IP 1
154failure
155.IP 32
e12364cd 156none of specified devices found
1539750f
KZ
157.IP 64
158some specified devices found, some not found
159
2a4c734b
MB
160.SH AUTHORS
161.nf
162Milan Broz <mbroz@redhat.com>
163Karel Zak <kzak@redhat.com>
164.fi
ca3dbca1 165.SH ENVIRONMENT
3476084d
KZ
166.IP LSBLK_DEBUG=all
167enables lsblk debug output.
68e422ec
KZ
168.IP LIBBLKID_DEBUG=all
169enables libblkid debug output.
170.IP LIBMOUNT_DEBUG=all
171enables libmount debug output.
172.IP LIBSMARTCOLS_DEBUG=all
173enables libsmartcols debug output.
37948503
KZ
174.IP LIBSMARTCOLS_DEBUG_PADDING=on
175use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
2a4c734b 176.SH SEE ALSO
f053ff1e 177.BR ls (1),
2a4c734b 178.BR blkid (8),
f053ff1e 179.BR findmnt (8)
2a4c734b 180.SH AVAILABILITY
601d12fb 181The lsblk command is part of the util-linux package and is available from
d673b74e 182https://www.kernel.org/pub/linux/utils/util-linux/.