virt-format(1)
π virt-format(1) β the erase-and-blank-slate era π
okay so bestie, welcome to virt-format(1), part of the virtualisation support squad β¨ β this is the page where we take a disk and absolutely wipe it into a beautiful blank canvas. no cap.
β¨ NAME β¨
virt-format β erase and make a blank disk π§Όπ«§
πΈ SYNOPSIS πΈ
virt-format [--options] -a disk.img [-a disk.img ...]
π¨ WARNING π¨ (read this one, i'm serious π)
Using virt-format on live virtual machines, or concurrently with other disk editing tools, can be dangerous, potentially causing disk corruption. π
The virtual machine must be shut down before you use this command, and disk images must not be edited concurrently.
fr fr, don't be the main character who ignores this. shut the VM down first. π€
π¦ DESCRIPTION π¦
virt-format takes an existing disk file (or it can be a host partition, LV etc), erases all data on it, and formats it as a blank disk. it can optionally create partition tables, empty filesystems, logical volumes and more. literally giving blank-canvas energy β¨
ngl, if what you actually want is a disk containing data, you may be better off using virt-make-fs(1). and if you're creating a blank disk to use in guestfish(1), you should instead use the guestfish -N option. iykyk π
Normal usage would be something like this:
virt-format -a disk.qcow
or this:
virt-format -a /dev/VG/LV
disk.qcow or /dev/VG/LV must exist already. β οΈ Any data on these disks will be erased by these commands. These commands will create a single empty partition covering the whole disk, with no filesystem inside it.
Additional parameters can be used to control the creation of partitions, filesystems, etc. The most commonly used options are:
--filesystem=[ext3|ntfs|vfat|...]β create an empty filesystem (ext3,ntfsetc) inside the partition. cute little filesystem, no files in it π--lvm[=/dev/VG/LV]β create a Linux LVM2 logical volume on the disk. when used with--filesystem, the filesystem is created inside the LV. nesting doll situation πͺ
For more information about these and other options, see "OPTIONS" below. π
The format of the disk is normally auto-detected, but you can also force it by using the --format option (q.v.). In situations where you do not trust the existing content of the disk, then it is advisable to use this option to avoid possible exploits. π΅οΈββοΈπ
π OPTIONS π
--helpβ display brief help. little helper π«Ά-afile,--addfile β add file, a disk image, host partition, LV, external USB disk, etc. the disk image format is auto-detected; to override this and force a particular format use the--format=..option. β οΈ Any existing data on the disk is erased.-aURI,--addURI β add a remote disk π. see "ADDING REMOTE STORAGE" inguestfish(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 usually 512 bytes. see also "guestfs_add_drive_opts" inguestfs(3).--filesystem=ext3|ntfs|vfat|...β create an empty filesystem of the specified type. many filesystem types are supported by libguestfs. β¨--filesystem=noneβ create no filesystem. this is the default. π«₯--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-format --format=raw -a disk.img
forces raw format (no auto-detection) for disk.img.
virt-format --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). π
--label=LABELβ set the filesystem label. name tag for your fs π·οΈ--lvm=/dev/VG/LVβ create a Linux LVM2 logical volume called/dev/VG/LV. you can change the name of the volume group and logical volume. π--lvmβ create a Linux LVM2 logical volume with the default name (/dev/VG/LV).--lvm=noneβ create no logical volume. this is the default. π«₯--partitionβ create either an MBR or GPT partition covering the whole disk. MBR is chosen if the disk size is < 2 TB, GPT if β₯ 2 TB. this is the default. π«--partition=gptβ create a GPT partition.--partition=mbrβ create an MBR partition.--partition=noneβ create no partition table. note that Windows may not be able to see these disks. π-v,--verboseβ enable verbose messages for debugging. chatty era π£οΈ-V,--versionβ display version number and exit.--wipeβ normallyvirt-formatdoes not wipe data from the disk (because that takes a long time). thus if there is data on the disk, it is only hidden and partially overwritten byvirt-format, and it might be recovered by disk editing tools. π¬
If you use this option, virt-format writes zeroes over the whole disk so that previous data is not recoverable. π₯ gone gone gone.
-xβ enable tracing of libguestfs API calls.
π EXIT STATUS π
This program returns 0 on success, or 1 on failure. simple as that π
β SEE ALSO β
guestfs(3), guestfish(1), virt-filesystems(1), virt-make-fs(1), virt-rescue(1), virt-resize(1), http://libguestfs.org/. the whole friend group π«Ά
π AUTHOR π
Richard W.M. Jones http://people.redhat.com/~rjones/ β the icon who wrote it π«‘
πΈ COPYRIGHT πΈ
Copyright (C) 2012 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.
bestie pls don't skip the test-tool output, the maintainers need the full unedited receipt π§Ύπ
and that's the whole page!! brought to you by guestfs-tools-1.57.3, dated 2026-09-16 β mwah, go format something blank and iconic πβ¨π
π¦ 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