tests: Split images -> tests/data + tests/guests
[libguestfs.git] / cat / virt-filesystems.pod
1 =encoding utf8
2
3 =head1 NAME
4
5 virt-filesystems - List filesystems, partitions, block devices, LVM in a virtual machine or disk image
6
7 =head1 SYNOPSIS
8
9  virt-filesystems [--options] -d domname
10
11  virt-filesystems [--options] -a disk.img [-a disk.img ...]
12
13 =head1 DESCRIPTION
14
15 This tool allows you to discover filesystems, partitions, logical
16 volumes, and their sizes in a disk image or virtual machine.  It is a
17 replacement for L<virt-list-filesystems(1)> and
18 L<virt-list-partitions(1)>.
19
20 One use for this tool is from shell scripts to iterate over all
21 filesystems from a disk image:
22
23  for fs in $(virt-filesystems -a disk.img); do
24    # ...
25  done
26
27 Another use is to list partitions before using another tool to modify
28 those partitions (such as L<virt-resize(1)>).  If you are curious
29 about what an unknown disk image contains, use this tool along with
30 L<virt-inspector(1)>.
31
32 Various command line options control what this program displays.  You
33 need to give either I<-a> or I<-d> options to specify the disk image
34 or libvirt guest respectively.  If you just specify that then the
35 program shows filesystems found, one per line, like this:
36
37  $ virt-filesystems -a disk.img
38  /dev/sda1
39  /dev/vg_guest/lv_root
40
41 If you add I<-l> or I<--long> then the output includes extra
42 information:
43
44  $ virt-filesystems -a disk.img -l
45  Name                   Type         VFS   Label  Size
46  /dev/sda1              filesystem   ext4  boot   524288000
47  /dev/vg_guest/lv_root  filesystem   ext4  root   10212081664
48
49 If you add I<--extra> then non-mountable (swap, unknown) filesystems
50 are shown as well:
51
52  $ virt-filesystems -a disk.img --extra
53  /dev/sda1
54  /dev/vg_guest/lv_root
55  /dev/vg_guest/lv_swap
56  /dev/vg_guest/lv_data
57
58 If you add I<--partitions> then partitions are shown instead of filesystems:
59
60  $ virt-filesystems -a disk.img --partitions
61  /dev/sda1
62  /dev/sda2
63
64 Similarly you can use I<--logical-volumes>, I<--volume-groups>,
65 I<--physical-volumes>, I<--block-devices> to list those items.
66
67 You can use these options in combination as well (if you want a
68 combination including filesystems, you have to add I<--filesystems>).
69 Notice that some items fall into several categories (eg. C</dev/sda1>
70 might be both a partition and a filesystem).  These items are listed
71 several times.  To get a list which includes absolutely everything
72 that virt-filesystems knows about, use the I<--all> option.
73
74 UUIDs (because they are quite long) are not shown by default.  Add the
75 I<--uuid> option to display device and filesystem UUIDs in the long
76 output.
77
78 I<--all --long --uuid> is a useful combination to display all possible
79 information about everything.
80
81  $ virt-filesystems -a win.img --all --long --uuid -h
82  Name      Type       VFS  Label           Size Parent   UUID
83  /dev/sda1 filesystem ntfs System Reserved 100M -        F81C92571C92112C
84  /dev/sda2 filesystem ntfs -               20G  -        F2E8996AE8992E3B
85  /dev/sda1 partition  -    -               100M /dev/sda -
86  /dev/sda2 partition  -    -               20G  /dev/sda -
87  /dev/sda  device     -    -               20G  -        -
88
89 For machine-readable output, use I<--csv> to get Comma-Separated Values.
90
91 =head1 OPTIONS
92
93 =over 4
94
95 =item B<--help>
96
97 Display brief help.
98
99 =item B<-a> file
100
101 =item B<--add> file
102
103 Add I<file> which should be a disk image from a virtual machine.  If
104 the virtual machine has multiple block devices, you must supply all of
105 them with separate I<-a> options.
106
107 The format of the disk image is auto-detected.  To override this and
108 force a particular format use the I<--format=..> option.
109
110 =item B<--all>
111
112 Display everything.  This is currently the same as specifying these
113 options: I<--filesystems>, I<--extra>, I<--partitions>,
114 I<--block-devices>, I<--logical-volumes>, I<--volume-groups>,
115 I<--physical-volumes>.  (More may be added to this list in future).
116
117 See also I<--long>.
118
119 =item B<--blkdevs>
120
121 =item B<--block-devices>
122
123 Display block devices.
124
125 =item B<-c> URI
126
127 =item B<--connect> URI
128
129 If using libvirt, connect to the given I<URI>.  If omitted, then we
130 connect to the default libvirt hypervisor.
131
132 If you specify guest block devices directly (I<-a>), then libvirt is
133 not used at all.
134
135 =item B<--csv>
136
137 Write out the results in CSV format (comma-separated values).  This
138 format can be imported easily into databases and spreadsheets, but
139 read L</NOTE ABOUT CSV FORMAT> below.
140
141 =item B<-d> guest
142
143 =item B<--domain> guest
144
145 Add all the disks from the named libvirt guest.  Domain UUIDs can be
146 used instead of names.
147
148 =item B<--echo-keys>
149
150 When prompting for keys and passphrases, virt-filesystems normally
151 turns echoing off so you cannot see what you are typing.  If you are
152 not worried about Tempest attacks and there is no one else in the room
153 you can specify this flag to see what you are typing.
154
155 =item B<--extra>
156
157 This causes filesystems that are not ordinary, mountable filesystems
158 to be displayed.  This category includes swapspace, and filesystems
159 that are empty or contain unknown data.
160
161 This option implies I<--filesystems>.
162
163 =item B<--filesystems>
164
165 Display mountable filesystems.  If no display option was selected then
166 this option is implied.
167
168 With I<--extra>, non-mountable filesystems are shown too.
169
170 =item B<--format=raw|qcow2|..>
171
172 =item B<--format>
173
174 The default for the I<-a> option is to auto-detect the format of the
175 disk image.  Using this forces the disk format for I<-a> options which
176 follow on the command line.  Using I<--format> with no argument
177 switches back to auto-detection for subsequent I<-a> options.
178
179 For example:
180
181  virt-filesystems --format=raw -a disk.img
182
183 forces raw format (no auto-detection) for C<disk.img>.
184
185  virt-filesystems --format=raw -a disk.img --format -a another.img
186
187 forces raw format (no auto-detection) for C<disk.img> and reverts to
188 auto-detection for C<another.img>.
189
190 If you have untrusted raw-format guest disk images, you should use
191 this option to specify the disk format.  This avoids a possible
192 security problem with malicious guests (CVE-2010-3851).
193
194 =item B<-h>
195
196 =item B<--human-readable>
197
198 In I<--long> mode, display sizes in human-readable format.
199
200 =item B<--keys-from-stdin>
201
202 Read key or passphrase parameters from stdin.  The default is
203 to try to read passphrases from the user by opening C</dev/tty>.
204
205 =item B<-l>
206
207 =item B<--long>
208
209 Display extra columns of data ("long format").
210
211 A title row is added unless you also specify I<--no-title>.
212
213 The extra columns displayed depend on what output you select, and the
214 ordering of columns may change in future versions.  Use the title row,
215 I<--csv> output and/or L<csvtool(1)> to match columns to data in
216 external programs.
217
218 Use I<-h> if you want sizes to be displayed in human-readable format.
219 The default is to show raw numbers of I<bytes>.
220
221 Use I<--uuid> to display UUIDs too.
222
223 =item B<--lvs>
224
225 =item B<--logvols>
226
227 =item B<--logical-volumes>
228
229 Display LVM logical volumes.  In this mode, these are displayed
230 irrespective of whether the LVs contain filesystems.
231
232 =item B<--no-title>
233
234 In I<--long> mode, don't add a title row.
235
236 Note that the order of the columns is not fixed, and may change in
237 future versions of virt-filesystems, so using this option may give you
238 unexpected surprises.
239
240 =item B<--parts>
241
242 =item B<--partitions>
243
244 Display partitions.  In this mode, these are displayed
245 irrespective of whether the partitions contain filesystems.
246
247 =item B<--pvs>
248
249 =item B<--physvols>
250
251 =item B<--physical-volumes>
252
253 Display LVM physical volumes.
254
255 =item B<--uuid>
256
257 =item B<--uuids>
258
259 In I<--long> mode, display UUIDs as well.
260
261 =item B<-v>
262
263 =item B<--verbose>
264
265 Enable verbose messages for debugging.
266
267 =item B<-V>
268
269 =item B<--version>
270
271 Display version number and exit.
272
273 =item B<--vgs>
274
275 =item B<--volgroups>
276
277 =item B<--volume-groups>
278
279 Display LVM volume groups.
280
281 =item B<-x>
282
283 Enable tracing of libguestfs API calls.
284
285 =back
286
287 =head1 COLUMNS
288
289 Note that columns in the output are subject to reordering and change
290 in future versions of this tool.
291
292 =over 4
293
294 =item B<Name>
295
296 The filesystem, partition, block device or LVM name.
297
298 For device and partition names these are displayed as canonical
299 libguestfs names, so that for example C</dev/sda2> is the second
300 partition on the first device.
301
302 If the I<--long> option is B<not> specified, then only the name column
303 is shown in the output.
304
305 =item B<Type>
306
307 The object type, for example C<filesystem>, C<lv>, C<device> etc.
308
309 =item B<VFS>
310
311 If there is a filesystem, then this column displays the filesystem
312 type if one could be detected, eg. C<ext4>.
313
314 =item B<Label>
315
316 If the object has a label (used for identifying and mounting
317 filesystems) then this column contains the label.
318
319 =item B<MBR>
320
321 The partition type byte, displayed as a two digit hexadecimal number.
322 A comprehensive list of partition types can be found here:
323 L<http://www.win.tue.nl/~aeb/partitions/partition_types-1.html>
324
325 This is only applicable for DOS (MBR) partitions.
326
327 =item B<Size>
328
329 The size of the object in bytes.  If the I<--human> option is used
330 then the size is displayed in a human-readable form.
331
332 =item B<Parent>
333
334 The parent column records the parent relationship between objects.
335 For example, if the object is a partition, then this column contains
336 the name of the containing device.  If the object is a logical volume,
337 then this column is the name of the volume group.
338
339 =item B<UUID>
340
341 If the object has a UUID (used for identifying and mounting
342 filesystems and block devices) then this column contains the UUID as a
343 string.
344
345 The UUID is only displayed if the I<--uuid> option is given.
346
347 =back
348
349 =head1 NOTE ABOUT CSV FORMAT
350
351 Comma-separated values (CSV) is a deceptive format.  It I<seems> like
352 it should be easy to parse, but it is definitely not easy to parse.
353
354 Myth: Just split fields at commas.  Reality: This does I<not> work
355 reliably.  This example has two columns:
356
357  "foo,bar",baz
358
359 Myth: Read the file one line at a time.  Reality: This does I<not>
360 work reliably.  This example has one row:
361
362  "foo
363  bar",baz
364
365 For shell scripts, use C<csvtool> (L<http://merjis.com/developers/csv>
366 also packaged in major Linux distributions).
367
368 For other languages, use a CSV processing library (eg. C<Text::CSV>
369 for Perl or Python's built-in csv library).
370
371 Most spreadsheets and databases can import CSV directly.
372
373 =head1 SHELL QUOTING
374
375 Libvirt guest names can contain arbitrary characters, some of which
376 have meaning to the shell such as C<#> and space.  You may need to
377 quote or escape these characters on the command line.  See the shell
378 manual page L<sh(1)> for details.
379
380 =head1 EXIT STATUS
381
382 This program returns 0 if successful, or non-zero if there was an
383 error.
384
385 =head1 SEE ALSO
386
387 L<guestfs(3)>,
388 L<guestfish(1)>,
389 L<virt-cat(1)>,
390 L<virt-df(1)>,
391 L<virt-list-filesystems(1)>,
392 L<virt-list-partitions(1)>,
393 L<csvtool(1)>,
394 L<http://libguestfs.org/>.
395
396 =head1 AUTHOR
397
398 Richard W.M. Jones L<http://people.redhat.com/~rjones/>
399
400 =head1 COPYRIGHT
401
402 Copyright (C) 2010 Red Hat Inc.
403
404 This program is free software; you can redistribute it and/or modify
405 it under the terms of the GNU General Public License as published by
406 the Free Software Foundation; either version 2 of the License, or
407 (at your option) any later version.
408
409 This program is distributed in the hope that it will be useful,
410 but WITHOUT ANY WARRANTY; without even the implied warranty of
411 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
412 GNU General Public License for more details.
413
414 You should have received a copy of the GNU General Public License
415 along with this program; if not, write to the Free Software
416 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.