]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test: determine rootfs size dynamically
authorBenjamin Drung <benjamin.drung@canonical.com>
Sat, 8 Nov 2025 13:54:43 +0000 (14:54 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Tue, 25 Nov 2025 23:19:22 +0000 (18:19 -0500)
Do not hard-code the size of the rootfs, but determine the needed size
dynamically. This will speed up the creation time for smaller content
and prevent failures in case of bigger content.

test/test-functions

index dc93361e40f20e6707540cf5367cda169922087a..4664665308501310aaa69be35d92b77fa6455066 100644 (file)
@@ -177,7 +177,12 @@ build_ext4_image() {
     local image="$2"
     local label="$3"
 
-    dd if=/dev/zero of="$image" bs=200MiB count=1 status=none
+    local size
+    size="$(du --summarize --block-size 1 "${source_dir}" | cut -f 1)"
+    # Add 8 MB for ext4 journal
+    size="$((size + 8000000))"
+
+    dd if=/dev/zero of="$image" bs="$size" count=1 status=none
     sync "$image"
     mkfs.ext4 -q -L "$label" -d "$source_dir" "$image"
     sync "$image"