2 # virt-list-filesystems
3 # Copyright (C) 2009-2010 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 use Sys::Guestfs::Lib qw(open_guest);
26 use Locale::TextDomain 'libguestfs';
32 virt-list-filesystems - List filesystems in a virtual machine or disk image
36 virt-list-filesystems [--options] domname
38 virt-list-filesystems [--options] disk.img [disk.img ...]
42 C<virt-list-filesystems> is a command line tool to list
43 the filesystems that are contained in a virtual machine or
46 C<virt-list-filesystems> is just a simple wrapper around
47 L<libguestfs(3)> functionality. For more complex cases you should
48 look at the L<guestfish(1)> tool.
68 Display version number and exit.
74 =item B<--connect URI> | B<-c URI>
76 If using libvirt, connect to the given I<URI>. If omitted, then we
77 connect to the default libvirt hypervisor.
79 If you specify guest block devices directly, then libvirt is not used
88 Specify the format of disk images given on the command line. If this
89 is omitted then the format is autodetected from the content of the
92 If disk images are requested from libvirt, then this program asks
93 libvirt for this information. In this case, the value of the format
96 If working with untrusted raw-format guest disk images, you should
97 ensure the format is always specified.
103 =item B<-l> | B<--long>
105 With this option, C<virt-list-filesystems> displays the type of
106 each filesystem too (where "type" means C<ext3>, C<xfs> etc.)
112 =item B<-a> | B<--all>
114 Normally we only show mountable filesystems. If this option
115 is given then swap devices are shown too.
121 # Configure bundling, otherwise '-al' is treated as '--all'.
122 Getopt::Long::Configure ("bundling");
124 GetOptions ("help|?" => \$help,
125 "version" => \$version,
126 "connect|c=s" => \$uri,
127 "format=s" => \$format,
131 pod2usage (1) if $help;
133 my $g = Sys::Guestfs->new ();
134 my %h = $g->version ();
135 print "$h{major}.$h{minor}.$h{release}$h{extra}\n";
139 pod2usage (__"virt-list-filesystems: no image or VM name given")
144 $g = open_guest (\@ARGV, address => $uri, format => $format);
146 $g = open_guest (\@ARGV, format => $format);
151 # List of filesystems.
152 my %fses = $g->list_filesystems ();
155 foreach $dev (sort keys %fses) {
156 $fstype = $fses{$dev};
158 if ($all || ($fstype ne "swap" && $fstype ne "unknown")) {
159 print canonicalize($dev);
167 # The reverse of device name translation, see
168 # BLOCK DEVICE NAMING in guestfs(3).
173 if (m{^/dev/[hv]d([a-z]\d)$}) {
181 Libvirt guest names can contain arbitrary characters, some of which
182 have meaning to the shell such as C<#> and space. You may need to
183 quote or escape these characters on the command line. See the shell
184 manual page L<sh(1)> for details.
192 L<virt-list-partitions(1)>,
194 L<Sys::Guestfs::Lib(3)>,
196 L<http://libguestfs.org/>.
200 Richard W.M. Jones L<http://people.redhat.com/~rjones/>
204 Copyright (C) 2009 Red Hat Inc.
206 This program is free software; you can redistribute it and/or modify
207 it under the terms of the GNU General Public License as published by
208 the Free Software Foundation; either version 2 of the License, or
209 (at your option) any later version.
211 This program is distributed in the hope that it will be useful,
212 but WITHOUT ANY WARRANTY; without even the implied warranty of
213 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
214 GNU General Public License for more details.
216 You should have received a copy of the GNU General Public License
217 along with this program; if not, write to the Free Software
218 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.