nixos/swap: make sure all kernel modules are loaded before creating swap devices. (#239163)

Co-authored-by: iliana etaoin <iliana@buttslol.net>
This commit is contained in:
Ramses 2023-07-13 17:12:54 +02:00 committed by GitHub
parent 6e7938422d
commit 1bee79f9f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -252,6 +252,11 @@ in
let realDevice' = escapeSystemdPath sw.realDevice;
in nameValuePair "mkswap-${sw.deviceName}"
{ description = "Initialisation of swap device ${sw.device}";
# The mkswap service fails for file-backed swap devices if the
# loop module has not been loaded before the service runs.
# We add an ordering constraint to run after systemd-modules-load to
# avoid this race condition.
after = [ "systemd-modules-load.service" ];
wantedBy = [ "${realDevice'}.swap" ];
before = [ "${realDevice'}.swap" ];
path = [ pkgs.util-linux pkgs.e2fsprogs ]