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