From bc828721ed4ac138d791de47469a40e39046fb4a Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Sat, 5 May 2018 19:02:50 +0300 Subject: [PATCH] nixos/lib/make-ext4-fs: Add a sanity check I ended up with a corrupted image with the debugfs contraption once, and given I couldn't reproduce the problem I suppose that happens if the filesystem of the builder runs out of space. At least in this instance fsck could detect it, so let's add it as a sanity check. --- nixos/lib/make-ext4-fs.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nixos/lib/make-ext4-fs.nix b/nixos/lib/make-ext4-fs.nix index 986d80ff1b9..4095d9c6d00 100644 --- a/nixos/lib/make-ext4-fs.nix +++ b/nixos/lib/make-ext4-fs.nix @@ -14,7 +14,7 @@ in pkgs.stdenv.mkDerivation { name = "ext4-fs.img"; - nativeBuildInputs = with pkgs; [e2fsprogs libfaketime perl]; + nativeBuildInputs = with pkgs; [e2fsprogs.bin libfaketime perl]; buildCommand = '' @@ -83,5 +83,12 @@ pkgs.stdenv.mkDerivation { echo "--- Failed to create EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks) ---" return 1 fi + + # 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 $out; then + echo "--- Fsck failed for EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks) ---" + cat errorlog + return 1 + fi ''; }