I have installed a Ubuntu 18.04 with manual disk partitioning as simple as it gets (one primary partition with ext4 filesystem, mount point "/", reserved blocks 0%, bootable flag on, no swap!).
I have noticed now that there is active swap space anyway:
:~$ free -m|awk 'NR==1{print} /Swap/ {print}'
total used free shared buff/cache available
Swap: 397 0 397
And it's created as a file:
:~$ grep swap /etc/fstab
/swapfile none swap sw 0 0
I could go ahead a simply turn off the swap space and delete the file as well as the fstab entry. But I would like to understand how to properly remove it from systemd as well. I can see a target defined for swap and I was wondering how to deactivate it and remove it from the list of targets before I eventually kill the swap file:
:~$ systemctl -t target |grep swap
swap.target loaded active active Swap
Any ideas?
UPDATE
If the service is masked, it won't appear in the target list anymore and the fstab entry is ignored:
:~$ systemctl mask swap.target
Created symlink /etc/systemd/system/swap.target → /dev/null.