Swap: Difference between revisions

Line 127: Line 127:


= Tips and Tricks =
= Tips and Tricks =
== Mount options ==
=== discard ===
Solid state drives have fast random access times, which make them great for swap if you ignore the limited lifespan. Enabling TRIM (discard) on the swap files can help avoid unnecessary copy actions on the SSD, helping with performance and slightly reducing wear.
<syntaxhighlight lang="nix">
swapDevices = [{
  device = "/dev/sdXY";
  options = [ "discard" ]; # equivalent to swapon --discard
}];
</syntaxhighlight>


== Encrypt swap with random key ==
== Encrypt swap with random key ==