diff --git a/make-btrfs-fs.nix b/make-btrfs-fs.nix index 10acc68..2762bc3 100644 --- a/make-btrfs-fs.nix +++ b/make-btrfs-fs.nix @@ -58,13 +58,9 @@ pkgs.stdenv.mkDerivation { # Make a crude approximation of the size of the target image. # If the script starts failing, increase the fudge factors here. numInodes=$(find ./rootImage | wc -l) - numDataBlocks=$(du -s -c -B 4096 --apparent-size ./rootImage | tail -1 | awk '{ print int($1 * 1.10) }') - bytes=$((2 * 4096 * $numInodes + 4096 * $numDataBlocks)) - echo "Creating a btrfs image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks)" - truncate -s $bytes $img - - faketime -f "1970-01-01 00:00:01" fakeroot mkfs.btrfs -L ${volumeLabel} -U ${uuid} -r ./rootImage $img + truncate -s 4G $img + faketime -f "1970-01-01 00:00:01" fakeroot mkfs.btrfs --shrink -L ${volumeLabel} -U ${uuid} -r ./rootImage $img if [ ${builtins.toString compressImage} ]; then echo "Compressing image"