Description of problem: btrfs has a minimum filesystem size of 256 MB. virt-make-fs doesn't take this into account when estimating the size of filesystem to create, so if the input files are less than this size it will fail with an error similar to: mkfs: btrfs: /dev/vda1: device /dev/vda1 is too small (must be at least 256 MB) at /usr/bin/virt-make-fs line 451. Version-Release number of selected component (if applicable): 1.17.33 How reproducible: 100% Steps to Reproduce: 1. Choose a small tarball (much smaller than 256 MB in size) 2. virt-make-fs -F qcow2 -t btrfs --partition=mbr input.tar output.qcow2 Actual results: Fails with an error as above. Expected results: It should increase the estimate to the minimum size and thus not fail. Additional info:
Note that the overhead of btrfs is much larger than expected. eg: With a 6 MB tarball, a 512 MB disk doesn't have enough space: $ virt-make-fs -F qcow2 -t btrfs --partition=mbr --size=512M \ libguestfs-1.17.1.tar.gz /tmp/disk.qcow2 Formatting '/tmp/disk.qcow2', fmt=qcow2 size=536870912 encryption=off cluster_size=65536 virt-make-fs: error copying contents into filesystem An error here usually means that the program did not estimate the filesystem size correctly. Please read the BUGS section of the manpage. tar_in: tar subcommand failed on directory: /: tar: libguestfs-1.17.1/ChangeLog: Cannot write: No space left on device tar: libguestfs-1.17.1/.gitignore: Cannot write: No space left on device [...] With a 1 GB filesystem, only 388 MB is usable, indicating an overhead of 636 MB just for btrfs(!) $ virt-make-fs ... --size=1G ... $ virt-df -h /tmp/disk.qcow2 Filesystem Size Used Available Use% disk.qcow2:/dev/sda1 1.0G 37M 351M 4%
See also: https://btrfs.wiki.kernel.org/articles/f/a/q/FAQ_1fe9.html#Why_does_df_show_incorrect_free_space_for_my_RAID_volume.3F
Link should be: https://btrfs.wiki.kernel.org/index.php/FAQ#Why_are_there_so_many_ways_to_check_the_amount_of_free_space.3F
Patches posted to the upstream mailing list: https://www.redhat.com/archives/libguestfs/2012-May/msg00015.html
Fixed in 1.17.39.