virt-make-fs(1)

πŸ’… virt-make-fs(1) β€” the manual page, but make it cute

okay so bestie, welcome to virt-make-fs, from section 1 of the manual (the "Virtualization Support" corner of the world 🧚). this is the whole page, nothing skipped, i promise πŸ’–


✨ NAME ✨

virt-make-fs β€” make a filesystem from a tar archive or files, no cap πŸŽ€


🌸 SYNOPSIS 🌸

 virt-make-fs [--options] input.tar output.img

 virt-make-fs [--options] input.tar.gz output.img

 virt-make-fs [--options] directory output.img

three whole ways to use it, we love a flexible icon πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so virt-make-fs is a command line tool that creates a filesystem from a tar archive, or from some files chilling in a directory. it's giving the same energy as tools like mkisofs(1), genisoimage(1) and mksquashfs(1). but unlike those guys, it can create common filesystem types like ext2/3 or NTFS β€” which is lowkey so useful if you wanna attach these filesystems to virtual machines that already exist (eg. to import large amounts of read-only data to a VM). slay πŸ’…

if you want to create blank disks, use virt-format(1). if you want complex layouts, use guestfish(1).

basic usage is literally this:

 virt-make-fs input output.img

where "input" is either a directory containing files you want to add, or a tar archive (either uncompressed tar or gzip-compressed tar); and output.img is a disk image. the input type is detected automatically, main character energy fr. the output disk image defaults to a raw ext2 sparse image unless you specify extra flags (see "OPTIONS" below) ✨

πŸ“ FILESYSTEM TYPE πŸ“

the default filesystem type is "ext2". just about any filesystem type that libguestfs supports can be used (but not read-only formats like ISO9660, don't even try πŸ™ˆ). here are some of the more common choices:

  • ext3 β€” note that ext3 filesystems contain a journal, typically 1-32 MB in size. if you're not gonna use the filesystem in a way that requires the journal, then this is just wasted overhead, ngl πŸ’€
  • ntfs or vfat β€” useful if exporting data to a Windows guest.
  • minix β€” lower overhead than "ext2", but certain limitations on filename length and total filesystem size.

EXAMPLE

 virt-make-fs --type=minix input minixfs.img

πŸ’œ TO PARTITION OR NOT TO PARTITION πŸ’œ

optionally virt-make-fs can add a partition table to the output disk.

adding a partition can make the disk image more compatible with certain virtualized operating systems which don't expect to see a filesystem directly located on a block device (Linux doesn't care and will happily handle both types, king behavior honestly πŸ‘‘).

on the other hand, if you have a partition table then the output image is no longer a straight filesystem. for example you cannot run fsck(8) directly on a partitioned disk image. (however libguestfs tools such as guestfish(1) and virt-resize(1) can still be used ✨)

EXAMPLE

add an MBR partition:

 virt-make-fs --partition -- input disk.img

if the output disk image could be terabyte-sized or larger, it's better to use an EFI/GPT-compatible partition table:

 virt-make-fs --partition=gpt --size=+4T --format=qcow2 input disk.img

🌈 EXTRA SPACE 🌈

unlike formats such as tar and squashfs, a filesystem does not "just fit" the files that it contains, but might have extra space. depending on how you're gonna use the output, you might think this extra space is wasted and want to minimize it, or you might want to leave space so that more files can be added later. virt-make-fs defaults to minimizing the extra space, but you can use the --size flag to leave space in the filesystem if you want it 🫢

an alternative way to leave extra space but not make the output image any bigger is to use an alternative disk image format (instead of the default "raw" format). using --format=qcow2 will use the native qemu/KVM qcow2 image format (check your hypervisor supports this before using it, fr fr). this allows you to choose a large --size but the extra space won't actually be allocated in the image until you try to store something in it. iconic ✨

don’t forget that you can also use local commands including resize2fs(8) and virt-resize(1) to resize existing filesystems, or rerun virt-make-fs to build another image from scratch.

EXAMPLE

 virt-make-fs --format=qcow2 --size=+200M input output.img

✨ OPTIONS ✨

  • --help β€” display brief help. short and sweet πŸŽ€
  • --blocksize=512, --blocksize=4096 β€” this parameter sets the sector size of the output disk image. the default is 512 bytes. see also "guestfs_add_drive_opts" in guestfs(3).
  • --floppy β€” create a virtual floppy disk πŸ’Ύ. currently this preselects the size (1440K), partition type (MBR) and filesystem type (VFAT). in future it may also choose the geometry.
  • --size=N, --size=+N, -s N, -s +N β€” use the --size (or -s) option to choose the size of the output image. if this option is not given, then the output image will be just large enough to contain all the files, with not much wasted space. to choose a fixed size output disk, specify an absolute number followed by b/K/M/G/T/P/E to mean bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Petabytes or Exabytes. this must be large enough to contain all the input files, else you will get an error 😭 to leave extra space, specify "+" (plus sign) and a number followed by b/K/M/G/T/P/E to mean bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Petabytes or Exabytes. for example: --size=+200M means enough space for the input files, and (approximately) an extra 200 MB free space. note that virt-make-fs estimates free space, and therefore will not produce filesystems containing precisely the free space requested. (it is much more expensive and time-consuming to produce a filesystem which has precisely the desired free space β€” respect the tradeoff bestie πŸ’…)
  • --format=FMT, -F FMT β€” choose the output disk image format. the default is "raw" (raw sparse disk image).
  • --type=FS, -t FS β€” choose the output filesystem type. the default is "ext2". any filesystem which is supported read-write by libguestfs can be used here.
  • --label=LABEL β€” set the filesystem label 🏷️.
  • --partition, --partition=PARTTYPE β€” if specified, this flag adds an MBR partition table to the output disk image. you can change the partition table type, eg. --partition=gpt for large disks. for MBR, virt-make-fs sets the partition type byte automatically.
  • -v, --verbose β€” enable debugging information.
  • -V, --version β€” display version number and exit.
  • -x β€” enable libguestfs trace.
ok that's literally all of them, we ate that list up πŸ”₯

πŸ‘‘ SEE ALSO πŸ‘‘

guestfish(1), virt-format(1), virt-resize(1), virt-tar-in(1), mkisofs(1), genisoimage(1), mksquashfs(1), mke2fs(8), resize2fs(8), guestfs(3), http://libguestfs.org/.

(the whole friend group 🫢)


🧚 AUTHOR 🧚

Richard W.M. Jones http://people.redhat.com/~rjones/ β€” we stan 🌟


Copyright (C) 2010-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.

yes that's the whole license text, i'm not skipping it, the boring parts are still part of the vibe check 😌

πŸ’€ 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. complete. unedited. no cropping, bestie πŸ™ˆ

🌸 okay that's the whole page!! this fabulous little doc is from guestfs-tools-1.57.3, dated 2026-09-16, and that's the sign-off β€” mwah πŸ’‹πŸ’–

πŸ“¦ where this page comes from