diff options
author | Richard Marko <srk@48.io> | 2020-02-05 15:29:22 +0100 |
---|---|---|
committer | Richard Marko <srk@48.io> | 2020-02-09 17:18:21 +0100 |
commit | db894cb8ce2be173250c6e423cbc2622881e4496 (patch) | |
tree | 3ccbfce584305035a7d3511f7ad6240f88ab5f54 | |
parent | 8a14852fd34af6c8e5f413838ab0e9c679ee8b2c (diff) | |
download | nixpkgs-db894cb8ce2be173250c6e423cbc2622881e4496.tar nixpkgs-db894cb8ce2be173250c6e423cbc2622881e4496.tar.gz nixpkgs-db894cb8ce2be173250c6e423cbc2622881e4496.tar.bz2 nixpkgs-db894cb8ce2be173250c6e423cbc2622881e4496.tar.lz nixpkgs-db894cb8ce2be173250c6e423cbc2622881e4496.tar.xz nixpkgs-db894cb8ce2be173250c6e423cbc2622881e4496.tar.zst nixpkgs-db894cb8ce2be173250c6e423cbc2622881e4496.zip |
nixos/lib/make-ext4-fs: fall back to resize2fs -M if exact resize fails
See also - https://bugs.launchpad.net/ubuntu/+source/e2fsprogs/+bug/1415077/comments/4 - https://github.com/NixOS/nixpkgs/pull/62262
-rw-r--r-- | nixos/lib/make-ext4-fs.nix | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/nixos/lib/make-ext4-fs.nix b/nixos/lib/make-ext4-fs.nix index f46d3990c06..627ac324cf5 100644 --- a/nixos/lib/make-ext4-fs.nix +++ b/nixos/lib/make-ext4-fs.nix @@ -64,7 +64,7 @@ pkgs.stdenv.mkDerivation { echo "copying files to image..." cptofs -t ext4 -i $img ./files/* / - + export EXT2FS_NO_MTAB_OK=yes # I have ended up with corrupted images sometimes, I suspect that happens when the build machine's disk gets full during the build. if ! fsck.ext4 -n -f $img; then echo "--- Fsck failed for EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks) ---" @@ -72,21 +72,8 @@ pkgs.stdenv.mkDerivation { return 1 fi - ( - # Resizes **snugly** to its actual limits (or closer to) - free=$(dumpe2fs $img | grep '^Free blocks:') - blocksize=$(dumpe2fs $img | grep '^Block size:') - blocks=$(dumpe2fs $img | grep '^Block count:') - blocks=$((''${blocks##*:})) # format the number. - blocksize=$((''${blocksize##*:})) # format the number. - # System can't boot with 0 blocks free. - # Add 16MiB of free space - fudge=$(( 16 * 1024 * 1024 / blocksize )) - size=$(( blocks - ''${free##*:} + fudge )) - - echo "Resizing from $blocks blocks to $size blocks. (~ $((size*blocksize/1024/1024))MiB)" - EXT2FS_NO_MTAB_OK=yes resize2fs $img -f $size - ) + echo "Resizing to minimum allowed size" + resize2fs -M $img # And a final fsck, because of the previous truncating. fsck.ext4 -n -f $img |