Bug 816098

Summary: virt-make-fs fails to make a btrfs filesystem because it doesn't allocate enough space
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: dyasny, mbooth, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-03 15:49:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Richard W.M. Jones 2012-04-25 09:19:58 UTC
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:

Comment 1 Richard W.M. Jones 2012-04-25 09:25:29 UTC
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%

Comment 4 Richard W.M. Jones 2012-05-03 13:37:03 UTC
Patches posted to the upstream mailing list:
https://www.redhat.com/archives/libguestfs/2012-May/msg00015.html

Comment 5 Richard W.M. Jones 2012-05-03 15:49:08 UTC
Fixed in 1.17.39.