rusty-snake's Tips & Tricks

Collection of useful commands and configs.

View on GitHub
4 July 2024

Linux swapfile with systemd

by rusty-snake

Preliminary notes:

Create the swapfile

mkswap --check -U clear --size 4G --file /swapfile

Create a systemd swap unit for it

systemctl edit --full --force swapfile.swap
systemctl enable --now swapfile.swap
[Unit]
Description=Disk Swap on /swapfile

[Swap]
What=/swapfile
Priority=50
Options=discard

[Install]
WantedBy=swap.target
tags: swap - swapfile - systemd