1virt-df(1) Virtualization Support virt-df(1)
2
3
4
6 virt-df - Display free space on virtual filesystems
7
9 All guests:
10
11 virt-df [--options]
12
13 Single guest:
14
15 virt-df [--options] -d domname
16
17 virt-df [--options] -a disk.img [-a disk.img ...]
18
19 Old style:
20
21 virt-df [--options] domname
22
23 virt-df [--options] disk.img [disk.img ...]
24
26 "virt-df" is a command line tool to display free space on virtual
27 machine filesystems. Unlike other tools, it doesn't just display the
28 size of disk allocated to a virtual machine, but can look inside disk
29 images to see how much space is really being used.
30
31 If used without any -a or -d arguments, "virt-df" checks with libvirt
32 to get a list of all active and inactive guests, and performs a
33 "df"-type operation on each one in turn, printing out the results.
34
35 If any -a or -d arguments are specified, "virt-df" performs a "df"-type
36 operation on either the single named libvirt domain, or on the disk
37 image(s) listed on the command line (which must all belong to a single
38 VM). In this mode (with arguments), "virt-df" will only work for a
39 single guest. If you want to run on multiple guests, then you have to
40 invoke "virt-df" multiple times.
41
42 Use the --csv option to get a format which can be easily parsed by
43 other programs. Other options are similar to the standard df(1)
44 command.
45
47 Show disk usage for a single libvirt guest called "F14x64". Make the
48 output human-readable:
49
50 # virt-df -d F14x64 -h
51 Filesystem Size Used Available Use%
52 F14x64:/dev/sda1 484M 66M 393M 14%
53 F14x64:/dev/vg_f13x64/lv_root 7.4G 3.4G 4.0G 46%
54
55 Show disk usage for a disk image file called "test.img":
56
57 $ virt-df -a test1.img
58 Filesystem 1K-blocks Used Available Use%
59 test1.img:/dev/sda1 99099 1551 92432 2%
60
61 If a single guest has multiple disks, use the -a option repeatedly. A
62 plus sign ("+") is displayed for each additional disk. Note: Do not do
63 this with unrelated guest disks.
64
65 $ virt-df -a Win7x32TwoDisks-a -a Win7x32TwoDisks-b
66 Filesystem 1K-blocks Used Available Use%
67 Win7x32TwoDisks-a+:/dev/sda1 102396 24712 77684 25%
68 Win7x32TwoDisks-a+:/dev/sda2 12478460 7403416 5075044 60%
69 Win7x32TwoDisks-a+:/dev/sdb1 521212 55728 465484 11%
70
72 --help
73 Display brief help.
74
75 -a file
76 --add file
77 Add file which should be a disk image from a virtual machine. If
78 the virtual machine has multiple block devices, you must supply all
79 of them with separate -a options.
80
81 The format of the disk image is auto-detected. To override this
82 and force a particular format use the --format=.. option.
83
84 -c URI
85 --connect URI
86 If using libvirt, connect to the given URI. If omitted, then we
87 connect to the default libvirt hypervisor.
88
89 If you specify guest block devices directly (-a), then libvirt is
90 not used at all.
91
92 --csv
93 Write out the results in CSV format (comma-separated values). This
94 format can be imported easily into databases and spreadsheets, but
95 read "NOTE ABOUT CSV FORMAT" below.
96
97 -d guest
98 --domain guest
99 Add all the disks from the named libvirt guest. Domain UUIDs can
100 be used instead of names.
101
102 --format=raw|qcow2|..
103 --format
104 The default for the -a option is to auto-detect the format of the
105 disk image. Using this forces the disk format for -a options which
106 follow on the command line. Using --format with no argument
107 switches back to auto-detection for subsequent -a options.
108
109 For example:
110
111 virt-df --format=raw -a disk.img
112
113 forces raw format (no auto-detection) for "disk.img".
114
115 virt-df --format=raw -a disk.img --format -a another.img
116
117 forces raw format (no auto-detection) for "disk.img" and reverts to
118 auto-detection for "another.img".
119
120 If you have untrusted raw-format guest disk images, you should use
121 this option to specify the disk format. This avoids a possible
122 security problem with malicious guests (CVE-2010-3851).
123
124 -h
125 --human-readable
126 Print sizes in human-readable format.
127
128 You are not allowed to use -h and --csv at the same time.
129
130 -i
131 --inodes
132 Print inodes instead of blocks.
133
134 --one-per-guest
135 Run one libguestfs appliance per guest. Normally "virt-df" will
136 add the disks from several guests to a single libguestfs appliance.
137
138 You might use this option in the following circumstances:
139
140 · If you think an untrusted guest might actively try to exploit
141 the libguestfs appliance kernel, then this prevents one guest
142 from interfering with the stats printed for another guest.
143
144 · If the kernel has a bug which stops it from accessing a
145 filesystem in one guest (see for example RHBZ#635373) then this
146 allows libguestfs to continue and report stats for further
147 guests.
148
149 --uuid
150 Print UUIDs instead of names. This is useful for following a guest
151 even when the guest is migrated or renamed, or when two guests
152 happen to have the same name.
153
154 Note that only domains that we fetch from libvirt come with UUIDs.
155 For disk images, we still print the disk image name even when this
156 option is specified.
157
158 -v
159 --verbose
160 Enable verbose messages for debugging.
161
162 -V
163 --version
164 Display version number and exit.
165
166 -x Enable tracing of libguestfs API calls.
167
169 "virt-df" (and df(1)) get information by issuing a statvfs(3) system
170 call. You can get the same information directly, either from the host
171 (using libguestfs) or inside the guest:
172
173 From the host
174 Run this command:
175
176 guestfish --ro -d GuestName -i statvfs /
177
178 (change "/" to see stats for other filesystems).
179
180 From inside the guest
181 Run this command:
182
183 python -c 'import os; s = os.statvfs ("/"); print s'
184
185 (change "/" to see stats for other filesystems).
186
188 Comma-separated values (CSV) is a deceptive format. It seems like it
189 should be easy to parse, but it is definitely not easy to parse.
190
191 Myth: Just split fields at commas. Reality: This does not work
192 reliably. This example has two columns:
193
194 "foo,bar",baz
195
196 Myth: Read the file one line at a time. Reality: This does not work
197 reliably. This example has one row:
198
199 "foo
200 bar",baz
201
202 For shell scripts, use "csvtool" (http://merjis.com/developers/csv also
203 packaged in major Linux distributions).
204
205 For other languages, use a CSV processing library (eg. "Text::CSV" for
206 Perl or Python's built-in csv library).
207
208 Most spreadsheets and databases can import CSV directly.
209
211 Libvirt guest names can contain arbitrary characters, some of which
212 have meaning to the shell such as "#" and space. You may need to quote
213 or escape these characters on the command line. See the shell manual
214 page sh(1) for details.
215
217 This program returns 0 if successful, or non-zero if there was an
218 error.
219
221 df(1), guestfs(3), guestfish(1), virt-filesystems(1),
222 http://libguestfs.org/.
223
225 Richard W.M. Jones http://people.redhat.com/~rjones/
226
228 Copyright (C) 2009-2013 Red Hat Inc.
229
231 This program is free software; you can redistribute it and/or modify it
232 under the terms of the GNU General Public License as published by the
233 Free Software Foundation; either version 2 of the License, or (at your
234 option) any later version.
235
236 This program is distributed in the hope that it will be useful, but
237 WITHOUT ANY WARRANTY; without even the implied warranty of
238 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
239 General Public License for more details.
240
241 You should have received a copy of the GNU General Public License along
242 with this program; if not, write to the Free Software Foundation, Inc.,
243 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
244
246 To get a list of bugs against libguestfs, use this link:
247 https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
248
249 To report a new bug against libguestfs, use this link:
250 https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
251
252 When reporting a bug, please supply:
253
254 · The version of libguestfs.
255
256 · Where you got libguestfs (eg. which Linux distro, compiled from
257 source, etc)
258
259 · Describe the bug accurately and give a way to reproduce it.
260
261 · Run libguestfs-test-tool(1) and paste the complete, unedited output
262 into the bug report.
263
264
265
266libguestfs-1.20.11 2013-08-27 virt-df(1)