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