summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorArtturi <Artturin@artturin.com>2021-11-16 22:12:55 +0200
committerGitHub <noreply@github.com>2021-11-16 22:12:55 +0200
commitc3660247776a57e788e848a2b2f20f5d23ef9c91 (patch)
tree49c8a054c22f8d0cc86e0f757f60a03f2e211b9b /nixos
parentf140fdb18de9f833d6ff0e7cd934232032a2b958 (diff)
parent17c61e97723ef2b10b60fd497b0e4eebe3b8655c (diff)
downloadnixpkgs-c3660247776a57e788e848a2b2f20f5d23ef9c91.tar
nixpkgs-c3660247776a57e788e848a2b2f20f5d23ef9c91.tar.gz
nixpkgs-c3660247776a57e788e848a2b2f20f5d23ef9c91.tar.bz2
nixpkgs-c3660247776a57e788e848a2b2f20f5d23ef9c91.tar.lz
nixpkgs-c3660247776a57e788e848a2b2f20f5d23ef9c91.tar.xz
nixpkgs-c3660247776a57e788e848a2b2f20f5d23ef9c91.tar.zst
nixpkgs-c3660247776a57e788e848a2b2f20f5d23ef9c91.zip
Merge pull request #145758 from Artturin/swapdd
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/config/swap.nix7
1 files changed, 1 insertions, 6 deletions
diff --git a/nixos/modules/config/swap.nix b/nixos/modules/config/swap.nix
index 9b005021086..2b94b954cb8 100644
--- a/nixos/modules/config/swap.nix
+++ b/nixos/modules/config/swap.nix
@@ -203,7 +203,6 @@ in
     ];
 
     # Create missing swapfiles.
-    # FIXME: support changing the size of existing swapfiles.
     systemd.services =
       let
 
@@ -223,11 +222,7 @@ in
                 ${optionalString (sw.size != null) ''
                   currentSize=$(( $(stat -c "%s" "${sw.device}" 2>/dev/null || echo 0) / 1024 / 1024 ))
                   if [ "${toString sw.size}" != "$currentSize" ]; then
-                    fallocate -l ${toString sw.size}M "${sw.device}" ||
-                      dd if=/dev/zero of="${sw.device}" bs=1M count=${toString sw.size}
-                    if [ "${toString sw.size}" -lt "$currentSize" ]; then
-                      truncate --size "${toString sw.size}M" "${sw.device}"
-                    fi
+                    dd if=/dev/zero of="${sw.device}" bs=1M count=${toString sw.size}
                     chmod 0600 ${sw.device}
                     ${optionalString (!sw.randomEncryption.enable) "mkswap ${sw.realDevice}"}
                   fi