about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2020-03-03 11:19:59 +0000
committerJörg Thalheim <joerg@thalheim.io>2020-03-03 11:22:07 +0000
commit8f543ed80d450556f6b442d32a8a433731b49f01 (patch)
tree62794281b5f1a97ef8c8b5828ca367d07fdbef4b /nixos
parentaca5d04f3eba035af237a967d7f573bc3de2ccc7 (diff)
downloadnixlib-8f543ed80d450556f6b442d32a8a433731b49f01.tar
nixlib-8f543ed80d450556f6b442d32a8a433731b49f01.tar.gz
nixlib-8f543ed80d450556f6b442d32a8a433731b49f01.tar.bz2
nixlib-8f543ed80d450556f6b442d32a8a433731b49f01.tar.lz
nixlib-8f543ed80d450556f6b442d32a8a433731b49f01.tar.xz
nixlib-8f543ed80d450556f6b442d32a8a433731b49f01.tar.zst
nixlib-8f543ed80d450556f6b442d32a8a433731b49f01.zip
nixos/zfs: continue trimming also if one pool fails
fixes https://github.com/NixOS/nixpkgs/issues/81602
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/tasks/filesystems/zfs.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix
index d14ba98ec48b..09c7e074e121 100644
--- a/nixos/modules/tasks/filesystems/zfs.nix
+++ b/nixos/modules/tasks/filesystems/zfs.nix
@@ -623,7 +623,11 @@ in
         after = [ "zfs-import.target" ];
         path = [ packages.zfsUser ];
         startAt = cfgTrim.interval;
-        serviceConfig.ExecStart = "${pkgs.runtimeShell} -c 'zpool list -H -o name | xargs --no-run-if-empty -n1 zpool trim'";
+        # By default we ignore errors returned by the trim command, in case:
+        # - HDDs are mixed with SSDs
+        # - There is a SSDs in a pool that is currently trimmed.
+        # - There are only HDDs and we would set the system in a degraded state
+        serviceConfig.ExecStart = ''${pkgs.runtimeShell} -c 'for pool in $(zpool list -H -o name); do zpool trim $pool;  done || true' '';
       };
     })
   ];