git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #145758 from Artturin/swapdd
commitc3660247776a57e788e848a2b2f20f5d23ef9c91 authorArtturi <Artturin@artturin.com> dateTue 16 Nov 2021, 22:12 (5 years ago) parentf140fdb17c61e9
1 file changed+1−6
nixos/modules/config/swap.nix+1−6
nixos/modules/config/swap.nix+1−6
@@ -203,7 +203,6 @@ in
203203 ];
204204
205205 # Create missing swapfiles.
206− # FIXME: support changing the size of existing swapfiles.
207206 systemd.services =
208207 let
209208
@@ -223,11 +222,7 @@ in
223222 ${optionalString (sw.size != null) ''
224223 currentSize=$(( $(stat -c "%s" "${sw.device}" 2>/dev/null || echo 0) / 1024 / 1024 ))
225224 if [ "${toString sw.size}" != "$currentSize" ]; then
226− fallocate -l ${toString sw.size}M "${sw.device}" ||
227− dd if=/dev/zero of="${sw.device}" bs=1M count=${toString sw.size}
228− if [ "${toString sw.size}" -lt "$currentSize" ]; then
229− truncate --size "${toString sw.size}M" "${sw.device}"
230− fi
225+ dd if=/dev/zero of="${sw.device}" bs=1M count=${toString sw.size}
231226 chmod 0600 ${sw.device}
232227 ${optionalString (!sw.randomEncryption.enable) "mkswap ${sw.realDevice}"}
233228 fi