From f0979fae03bcc4767ac4df1cb8fad9277e952637 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Mon, 26 Feb 2024 14:39:12 +0100 Subject: debvm-create: switch from genext2fs to mkfs.ext4 Why? genext2fs is slow. It has O(n^2) behaviour, which becomes annoying with larger filesystems. It also creates an ext2 image and we have to upgrade it to ext4 in multiple steps. Even then, the image has an inode size of 128, which is incompatible with 2038 and does not allow storing sub-second precision time stamps. How? We use mkfs.ext4 from e2fsprogs (which is required anyway) instead. Running this from within a --customize-hook does not work, because the user namespace used for the hook often has no privileges to write to the output image. Instead, we now ask mmdebstrap to output to a directory and create the filesystem separately. We construct a special namespace that has both access to the tree and to the output image and perform the mkfs.ext4 there. As a consequence, we no longer support any mode but unshare and since mkfs.ext4 consumes the size parameter, the size syntax is reduced a bit. --- debian/control | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'debian/control') diff --git a/debian/control b/debian/control index d4dbda0..0474049 100644 --- a/debian/control +++ b/debian/control @@ -15,12 +15,12 @@ Depends: ${misc:Depends}, dpkg-dev, e2fsprogs, - genext2fs, mmdebstrap (>= 1.3.0), passwd, qemu-kvm (>> 1:8.0) | qemu-system-any, # Required for -device virtio-net-pci,netdev=net0 ipxe-qemu, + uidmap, Recommends: arch-test, file, @@ -29,8 +29,6 @@ Recommends: qemu-system, qemu-user-static, seabios, - uidmap | fakeroot, - uidmap | fakechroot, Suggests: qemu-system-gui, Description: create and run virtual machines for various Debian releases and architectures -- cgit v1.2.3 From 12d193bb8d108f5718dc12053ccf78a1b6a876ce Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Tue, 27 Feb 2024 07:50:50 +0100 Subject: debvm-create: fix --skip ext4 We were truncating the output file after generating it. Instead, split the logic and create the file prior to running mmdebstrap to make permission failures fail early. --- bin/debvm-create | 28 ++++++++++++++-------------- debian/control | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'debian/control') diff --git a/bin/debvm-create b/bin/debvm-create index a8d5727..0e1a969 100755 --- a/bin/debvm-create +++ b/bin/debvm-create @@ -409,6 +409,12 @@ else } fi +if check_skip ext4; then + set -- "$SUITE" "$IMAGE" "$@" + set -x + exec mmdebstrap "$@" +fi + TEMPROOT= cleanup() { if test -n "$TEMPROOT"; then @@ -416,23 +422,17 @@ cleanup() { fi } -if check_skip ext4; then - set -- "$IMAGE" "$@" -else - trap cleanup EXIT - trap 'exit 1' HUP INT QUIT TERM - TEMPROOT="$(mktemp -d)" - - set -- "$TEMPROOT" "$@" -fi +trap cleanup EXIT +trap 'exit 1' HUP INT QUIT TERM +TEMPROOT="$(mktemp -d)" -set -- "$SUITE" "$@" +set -- "$SUITE" "$TEMPROOT" "$@" set -ex -mmdebstrap "$@" - # Create and truncate the file with "normal" permission. : >"$IMAGE" -check_skip ext4 || - run_inside_userns /sbin/mkfs.ext4 -L debvm -d "$TEMPROOT" "$IMAGE" "$SIZE" + +mmdebstrap "$@" + +run_inside_userns /sbin/mkfs.ext4 -L debvm -d "$TEMPROOT" "$IMAGE" "$SIZE" diff --git a/debian/control b/debian/control index 0474049..341e8a7 100644 --- a/debian/control +++ b/debian/control @@ -20,7 +20,6 @@ Depends: qemu-kvm (>> 1:8.0) | qemu-system-any, # Required for -device virtio-net-pci,netdev=net0 ipxe-qemu, - uidmap, Recommends: arch-test, file, @@ -29,6 +28,7 @@ Recommends: qemu-system, qemu-user-static, seabios, + uidmap, Suggests: qemu-system-gui, Description: create and run virtual machines for various Debian releases and architectures -- cgit v1.2.3