What's the best way to disable swap entirely on a fleet of GNU/Linux hosts, using systemd and Ansible?
For whatever reason some of my virtual machines have a swap file configured in their /etc/fstab
, which gets automatically picked up at boot by systemd-fstab-generator
like this:
$ cat /run/systemd/generator/swapfile.swap
# Automatically generated by systemd-fstab-generator
[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
[Swap]
What=/swapfile
Some services running on those machines get terminally slow when using the swap file, for various reasons, so I need to prevent them from using it. My version of systemd doesn't yet include MemorySwapMax
.
I'd like to avoid messing up with /etc/fstab
and I don't mind having those swap files left in place.
For context, I'm using ansible-3.0.0, ansible-base-2.10.6; the machines are CentOS 7, with systemd 219.
/etc/fstab
with ansible. And yes, my goal is to get those processes killed as fast as possible by the kernel.