summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorTuomas Tynkkynen <tuomas@tuxera.com>2018-05-05 19:02:50 +0300
committerTuomas Tynkkynen <tuomas@tuxera.com>2018-05-05 19:30:54 +0300
commitbc828721ed4ac138d791de47469a40e39046fb4a (patch)
tree040dbdb0c1e04c4253c69dd6f498731712ec7919 /nixos/lib
parent76d0e61e7b4878508af84268eb633fdc4ba53224 (diff)
downloadnixlib-bc828721ed4ac138d791de47469a40e39046fb4a.tar
nixlib-bc828721ed4ac138d791de47469a40e39046fb4a.tar.gz
nixlib-bc828721ed4ac138d791de47469a40e39046fb4a.tar.bz2
nixlib-bc828721ed4ac138d791de47469a40e39046fb4a.tar.lz
nixlib-bc828721ed4ac138d791de47469a40e39046fb4a.tar.xz
nixlib-bc828721ed4ac138d791de47469a40e39046fb4a.tar.zst
nixlib-bc828721ed4ac138d791de47469a40e39046fb4a.zip
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.
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/make-ext4-fs.nix9
1 files changed, 8 insertions, 1 deletions
diff --git a/nixos/lib/make-ext4-fs.nix b/nixos/lib/make-ext4-fs.nix
index 986d80ff1b99..4095d9c6d00d 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
     '';
 }