Run these commands as root to create a 512 megabyte swap.
fallocate -l 512m /media/state/512MiB.swap
chmod 600 /media/state/512MiB.swap
mkswap /media/state/512MiB.swap
Create a unit file at /media/state/units/swapon.service
with these contents:
[Unit]
Description=Turn on swap
[Service]
Type=oneshot
ExecStart=/sbin/swapon /media/state/512MiB.swap
[Install]
WantedBy=local.target
systemctl enable --runtime /media/state/units/swapon.service
systemctl start swapon
On your next reboot the swap will be turned on automatically.
I'm getting this:
Mar 01 11:50:03 www.szeremi.org systemd[1]: swapon.service: Failed with result 'exit-code'.
Mar 01 11:50:03 www.szeremi.org swapon[23089]: swapon: stat of /media/state/512MiB.swap failed: No such file or directory