diff options
Diffstat (limited to 'nixos/lib/make-ext4-fs.nix')
-rw-r--r-- | nixos/lib/make-ext4-fs.nix | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/nixos/lib/make-ext4-fs.nix b/nixos/lib/make-ext4-fs.nix index 416beeb32f2fa..b8e1b8d24c48b 100644 --- a/nixos/lib/make-ext4-fs.nix +++ b/nixos/lib/make-ext4-fs.nix @@ -78,6 +78,15 @@ pkgs.stdenv.mkDerivation { # get rid of the unnecessary slack here--but see # https://github.com/NixOS/nixpkgs/issues/125121 for caveats. + # shrink to fit + resize2fs -M $img + + # Add 16 MebiByte to the current_size + new_size=$(dumpe2fs -h $img | awk -F: \ + '/Block count/{count=$2} /Block size/{size=$2} END{print (count*size+16*2**20)/size}') + + resize2fs $img $new_size + if [ ${builtins.toString compressImage} ]; then echo "Compressing image" zstd -v --no-progress ./$img -o $out |