Mike Kelly
2013-Apr-29 16:57 UTC
[Libguestfs] [PATCH] Fix make-fedora-img for btrfs minimum size
This first factors out all the partition sizing, and then resizes the images created to be 1GB instead of 512MB, to work around a size limitation with btrfs: mkfs_btrfs: /dev/vda2: device /dev/vda2 is too small (must be at least 256 MB)
---
tests/guests/guest-aux/make-fedora-img.pl | 32 +++++++++++++++++++++--------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/tests/guests/guest-aux/make-fedora-img.pl
b/tests/guests/guest-aux/make-fedora-img.pl
index 1875602..b509973 100755
--- a/tests/guests/guest-aux/make-fedora-img.pl
+++ b/tests/guests/guest-aux/make-fedora-img.pl
@@ -27,6 +27,18 @@ use warnings;
use Sys::Guestfs;
use File::Temp;
+my $IMAGE_SIZE = 512*1024*1024; # bytes
+my $LEADING_SECTORS = 64;
+my $TRAILING_SECTORS = 64;
+my $SECTOR_SIZE = 512; # bytes
+
+my @PARTITIONS = (
+ # 32k blank space
+ ['p', $LEADING_SECTORS, $IMAGE_SIZE/2/$SECTOR_SIZE-1],
+ ['p', $IMAGE_SIZE/2/$SECTOR_SIZE, -$TRAILING_SECTORS],
+ # 32k blank space
+);
+
my @images;
my $g = Sys::Guestfs->new ();
@@ -49,15 +61,16 @@ EOF
$bootdev = '/dev/sda1';
open (my $img, '>', "fedora.img.tmp.$$") or die;
- truncate ($img, 512*1024*1024) or die;
+ truncate ($img, $IMAGE_SIZE) or die;
close ($img) or die;
$g->add_drive ("fedora.img.tmp.$$");
$g->launch ();
$g->part_init ('/dev/sda', 'mbr');
- $g->part_add ('/dev/sda', 'p', 64, 524287);
- $g->part_add ('/dev/sda', 'p', 524288, -64);
+ foreach my $p (@PARTITIONS) {
+ $g->part_add('/dev/sda', @$p);
+ }
init_lvm_root ('/dev/sda2');
}
@@ -76,7 +89,7 @@ EOF
foreach my $img (@images) {
open (my $fh, '>', $img) or die;
- truncate ($fh, 512*1024*1024) or die;
+ truncate ($fh, $IMAGE_SIZE) or die;
close ($fh) or die;
$g->add_drive ($img);
@@ -85,10 +98,11 @@ EOF
$g->launch ();
# Format the disks.
- foreach ('a', 'b') {
- $g->part_init ("/dev/sd$_", 'mbr');
- $g->part_add ("/dev/sd$_", 'p', 64, 524287);
- $g->part_add ("/dev/sd$_", 'p', 524288, -64);
+ foreach my $d ('a', 'b') {
+ $g->part_init ("/dev/sd$d", 'mbr');
+ foreach my $p (@PARTITIONS) {
+ $g->part_add("/dev/sd$d", @$p);
+ }
}
$g->md_create ('boot', ['/dev/sda1',
'/dev/sdb1']);
@@ -127,7 +141,7 @@ EOF
$bootdev = '/dev/sda1';
open (my $img, '>', "fedora-btrfs.img.tmp.$$") or die;
- truncate ($img, 512*1024*1024) or die;
+ truncate ($img, $IMAGE_SIZE) or die;
close ($img) or die;
$g->add_drive ("fedora-btrfs.img.tmp.$$");
--
1.7.9.5
Mike Kelly
2013-Apr-29 16:57 UTC
[Libguestfs] [PATCH 2/2] Make a 1G test image instead, avoiding a size bug
mkfs_btrfs: /dev/vda2: device /dev/vda2 is too small (must be at least 256 MB) at .../libguestfs/tests/guests/guest-aux/make-fedora-img.pl line 140. --- tests/guests/guest-aux/make-fedora-img.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/guests/guest-aux/make-fedora-img.pl b/tests/guests/guest-aux/make-fedora-img.pl index b509973..7b0e0ad 100755 --- a/tests/guests/guest-aux/make-fedora-img.pl +++ b/tests/guests/guest-aux/make-fedora-img.pl @@ -27,7 +27,7 @@ use warnings; use Sys::Guestfs; use File::Temp; -my $IMAGE_SIZE = 512*1024*1024; # bytes +my $IMAGE_SIZE = 1024*1024*1024; # bytes my $LEADING_SECTORS = 64; my $TRAILING_SECTORS = 64; my $SECTOR_SIZE = 512; # bytes -- 1.7.9.5
Richard W.M. Jones
2013-Apr-29 17:03 UTC
[Libguestfs] [PATCH] Fix make-fedora-img for btrfs minimum size
On Mon, Apr 29, 2013 at 12:57:12PM -0400, Mike Kelly wrote:> This first factors out all the partition sizing, and then resizes the > images created to be 1GB instead of 512MB, to work around a size > limitation with btrfs: > > mkfs_btrfs: /dev/vda2: device /dev/vda2 is too small (must be at least > 256 MB)ACKed and pushed both of them. Thanks for your contribution, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Reasonably Related Threads
- [PATCH v2] test-data: Allow tests to be run when Btrfs is not available.
- [PATCH 0/3] tests: Various fixes for btrfs and aarch64.
- [PATCH] actions: expand partitions for btrfs_image test
- [PATCH 0/8] Add MD inspection support to libguestfs
- [PATCH 0/2] btrfs: add support to btrfs-image