From c6476ca11990e993f265eba077d65424b9e80d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20S=C3=BCtter?= Date: Fri, 11 Apr 2025 12:46:50 +0200 Subject: [PATCH] repart: Enable discard option systemd-repart can be configured to not automatically issue BLKDISCARD commands to the underlying hardware. This PR exposes this option in the repart module. --- nixos/modules/system/boot/systemd/repart.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nixos/modules/system/boot/systemd/repart.nix b/nixos/modules/system/boot/systemd/repart.nix index a8dc4745c26b..b7ca00cf6a03 100644 --- a/nixos/modules/system/boot/systemd/repart.nix +++ b/nixos/modules/system/boot/systemd/repart.nix @@ -72,6 +72,19 @@ in example = "require"; default = "refuse"; }; + + discard = lib.mkOption { + type = lib.types.bool; + description = '' + Controls whether to issue the BLKDISCARD I/O control command on the + space taken up by any added partitions or on the space in between them. + Usually, it's a good idea to issue this request since it tells the underlying + hardware that the covered blocks shall be considered empty, improving performance. + + See {manpage}`systemd-repart(8)` for details. + ''; + default = true; + }; }; systemd.repart = { @@ -163,6 +176,7 @@ in --definitions=/etc/repart.d \ --dry-run=no \ --empty=${initrdCfg.empty} \ + --discard=${lib.boolToString initrdCfg.discard} \ ${lib.optionalString (initrdCfg.device != null) initrdCfg.device} '' ];