@@ -64,7 +64,7 @@ pkgs.stdenv.mkDerivation {
6464 echo "copying files to image..."
6565 cptofs -t ext4 -i $img ./files/* /
6666
67−
67+ export EXT2FS_NO_MTAB_OK=yes
6868 # I have ended up with corrupted images sometimes, I suspect that happens when the build machine's disk gets full during the build.
6969 if ! fsck.ext4 -n -f $img; then
7070 echo "--- Fsck failed for EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks) ---"
@@ -72,21 +72,8 @@ pkgs.stdenv.mkDerivation {
7272 return 1
7373 fi
7474
75− (
76− # Resizes **snugly** to its actual limits (or closer to)
77− free=$(dumpe2fs $img | grep '^Free blocks:')
78− blocksize=$(dumpe2fs $img | grep '^Block size:')
79− blocks=$(dumpe2fs $img | grep '^Block count:')
80− blocks=$((''${blocks##*:})) # format the number.
81− blocksize=$((''${blocksize##*:})) # format the number.
82− # System can't boot with 0 blocks free.
83− # Add 16MiB of free space
84− fudge=$(( 16 * 1024 * 1024 / blocksize ))
85− size=$(( blocks - ''${free##*:} + fudge ))
86−
87− echo "Resizing from $blocks blocks to $size blocks. (~ $((size*blocksize/1024/1024))MiB)"
88− EXT2FS_NO_MTAB_OK=yes resize2fs $img -f $size
89− )
75+ echo "Resizing to minimum allowed size"
76+ resize2fs -M $img
9077
9178 # And a final fsck, because of the previous truncating.
9279 fsck.ext4 -n -f $img