diff options
author | Samuel Dionne-Riel <samuel@dionne-riel.com> | 2020-02-09 14:35:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-09 14:35:08 -0500 |
commit | cebb0b49d4fb41339200a54f3b1691755e15efa5 (patch) | |
tree | 001fdaf04fe218b0c90084e17ee85e54b4af4c2a /nixos | |
parent | 513482763b05ef9cc56409885957cf57f31012ab (diff) | |
parent | db894cb8ce2be173250c6e423cbc2622881e4496 (diff) | |
download | nixpkgs-cebb0b49d4fb41339200a54f3b1691755e15efa5.tar nixpkgs-cebb0b49d4fb41339200a54f3b1691755e15efa5.tar.gz nixpkgs-cebb0b49d4fb41339200a54f3b1691755e15efa5.tar.bz2 nixpkgs-cebb0b49d4fb41339200a54f3b1691755e15efa5.tar.lz nixpkgs-cebb0b49d4fb41339200a54f3b1691755e15efa5.tar.xz nixpkgs-cebb0b49d4fb41339200a54f3b1691755e15efa5.tar.zst nixpkgs-cebb0b49d4fb41339200a54f3b1691755e15efa5.zip |
Merge pull request #79368 from sorki/ext4resize
nixos/lib/make-ext4-fs: fall back to resize2fs -M if exact resize fails
Diffstat (limited to 'nixos')
-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 |