virt-df(1)
π
virt-df(1) β like df but for your VMs, no cap
okay so this is a page from the Virtualization Support section of the manual, and it's literally about peeking inside virtual machine filesystems. buckle up bestie π
β¨ NAME β¨
virt-df β display free space on virtual filesystems π¦
πΈ SYNOPSIS πΈ
All guests:
virt-df [--options]
Single guest:
virt-df [--options] -d domname
virt-df [--options] -a disk.img [-a disk.img ...]
Old style:
virt-df [--options] domname
virt-df [--options] disk.img [disk.img ...]
π DESCRIPTION π
virt-df is a command line tool that shows you the free space on virtual machine filesystems. and likeβ¦ the way it's not like other tools? it doesn't just show you the size of disk allocated to a VM β it actually looks inside the disk images to see how much space is really being used. icon behavior fr fr π
If you run it with no -a or -d arguments at all, virt-df checks in with libvirt, gets a list of all active and inactive guests, and does a df-type operation on each one in turn, printing out the results. slay β¨
If you do specify any -a or -d arguments, virt-df performs a df-type operation on either the single named libvirt domain, or on the disk image(s) listed on the command line (which must all belong to a single VM). And heads up: in this mode (the one with arguments), virt-df will only work for a single guest. want multiple guests? you gotta invoke virt-df multiple times. one guest per era, iykyk π
Use the --csv option to get a format that other programs can parse easily. other options are similar to the standard df(1) command.
π EXAMPLES π
Show disk usage for a single libvirt guest called F14x64, and make the output human-readable:
# virt-df -d F14x64 -h
Filesystem Size Used Available Use%
F14x64:/dev/sda1 484M 66M 393M 14%
F14x64:/dev/vg_f13x64/lv_root 7.4G 3.4G 4.0G 46%
Show disk usage for a disk image file called test.img:
$ virt-df -a test1.img
Filesystem 1K-blocks Used Available Use%
test1.img:/dev/sda1 99099 1551 92432 2%
If a single guest has multiple disks, use the -a option repeatedly. A plus sign (+) is displayed for each additional disk. Note: Do not do this with unrelated guest disks. π
$ virt-df -a Win7x32TwoDisks-a -a Win7x32TwoDisks-b
Filesystem 1K-blocks Used Available Use%
Win7x32TwoDisks-a+:/dev/sda1 102396 24712 77684 25%
Win7x32TwoDisks-a+:/dev/sda2 12478460 7403416 5075044 60%
Win7x32TwoDisks-a+:/dev/sdb1 521212 55728 465484 11%
β OPTIONS β
--helpβ display brief help. short and sweet π«Ά-a FILE,--add FILEβ addFILE, which should be a disk image from a virtual machine. if the VM has multiple block devices, you must supply all of them with separate-aoptions.
the format of the disk image is auto-detected. to override this and force a particular format, use the --format=.. option.
-a URI,--add URIβ add a remote disk. seeADDING REMOTE STORAGEin guestfish(1) πΎ--blocksize=512,--blocksize=4096,--blocksizeβ this parameter sets the sector size of the disk image. it affects all explicitly added subsequent disks after this parameter. using--blocksizewith no argument switches the disk sector size to the default value, which is usually512bytes. see alsoguestfs_add_drive_optsin guestfs(3).-c URI,--connect URIβ if using libvirt, connect to the given URI. if omitted, then we connect to the default libvirt hypervisor.
if you specify guest block devices directly (-a), then libvirt is not used at all. none. zero. βοΈ
--csvβ write out the results in CSV format (comma-separated values). this format can be imported easily into databases and spreadsheets, but pls readNOTE ABOUT CSV FORMATbelow, bestie, it's important π-d guest,--domain guestβ add all the disks from the named libvirt guest. domain UUIDs can be used instead of names. π§--format=raw|qcow2|..,--formatβ the default for the-aoption is to auto-detect the format of the disk image. using this forces the disk format for-aoptions which follow on the command line. using--formatwith no argument switches back to auto-detection for subsequent-aoptions.
for example:
virt-df --format=raw -a disk.img
forces raw format (no auto-detection) for disk.img.
virt-df --format=raw -a disk.img --format -a another.img
forces raw format (no auto-detection) for disk.img and reverts to auto-detection for another.img.
if you have untrusted raw-format guest disk images, you should use this option to specify the disk format. this avoids a possible security problem with malicious guests (CVE-2010-3851). not me being serious for a sec β this one matters π₯
-h,--human-readableβ print sizes in human-readable format.
you are not allowed to use-hand--csvat the same time. pick a lane π
-i,--inodesβ print inodes instead of blocks.--one-per-guestβ since libguestfs 1.22, this is the default. this option does nothing and is left here for backwards compatibility with older scripts. it's giving legacy, but respectfully π«Ά-P nr_threadsβ since libguestfs 1.22,virt-dfis multithreaded and examines guests in parallel. by default the number of threads to use is chosen based on the amount of free memory available at the time thatvirt-dfis started. you can forcevirt-dfto use at mostnr_threadsby using the-Poption.
note that -P 0 means to autodetect, and -P 1 means to use a single thread. β
--uuidβ print UUIDs instead of names. this is useful for following a guest even when the guest is migrated or renamed, or when two guests happen to have the same name.
note that only domains that we fetch from libvirt come with UUIDs. for disk images, we still print the disk image name even when this option is specified. no cap π
-v,--verboseβ enable verbose messages for debugging. π-V,--versionβ display version number and exit.-xβ enable tracing of libguestfs API calls. π
π¦ STATVFS NUMBERS π¦
virt-df (and df(1)) get information by issuing a statvfs(3) system call. you can get the same information directly, either from the host (using libguestfs) or inside the guest:
π From the host
Run this command:
guestfish --ro -d GuestName -i statvfs /
(change / to see stats for other filesystems).
π From inside the guest
Run this command:
python -c 'import os; s = os.statvfs ("/"); print s'
(change / to see stats for other filesystems).
πΈ NOTE ABOUT CSV FORMAT πΈ
comma-separated values (CSV) is a deceptive format. it seems like it should be easy to parse, but it is definitely not easy to parse. π
Myth: just split fields at commas. Reality: this does not work reliably. this example has two columns:
"foo,bar",baz
Myth: read the file one line at a time. Reality: this does not work reliably. this example has one row:
"foo
bar",baz
for shell scripts, use csvtool (https://github.com/Chris00/ocaml-csv β also packaged in major Linux distributions).
for other languages, use a CSV processing library (eg. Text::CSV for Perl or Pythonβs built-in csv library).
most spreadsheets and databases can import CSV directly. so likeβ¦ it's fine, just don't hand-roll the parser π
π EXIT STATUS π
this program returns 0 if successful, or non-zero if there was an error.
π SEE ALSO π
df(1), guestfs(3), guestfish(1), virt-drivers(1), virt-filesystems(1), http://libguestfs.org/.
π AUTHOR π
Richard W.M. Jones β http://people.redhat.com/~rjones/
π COPYRIGHT π
Copyright (C) 2009-2025 Red Hat Inc.
π§ LICENSE π§
this program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
this program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see the GNU General Public License for more details.
you should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
π BUGS π
to get a list of bugs against libguestfs, use this link: https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
to report a new bug against libguestfs, use this link: https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
when reporting a bug, please supply:
- the version of libguestfs.
- where you got libguestfs (eg. which Linux distro, compiled from source, etc)
- describe the bug accurately and give a way to reproduce it.
- run libguestfs-test-tool(1) and paste the complete, unedited output into the bug report. yes, complete and unedited β don't be shy with it π
and that's the whole page!! this one's from guestfs-tools-1.57.3, dated 2026-09-16 β go forth and check your disk space, bestie, you've got this π«Άβ¨
π¦ where this page comes from
- centos-stream 10: guestfs-tools 1.57.3-1.el10 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms