TLDR:
A fully updated ubuntu 22.04 server is still mounting swap even after removing it from /etc/fstab
I am about to pull my hair over this issue.
I've been reading the ubuntu documentation about swap for about 15 times and still can't figure out why this is happening.
I commented out the swap FS in /etc/fstab, did a reboot and my system is still listing a swap drive in /proc/swaps and free -h.
/proc/swaps
Filename Type Size Used Priority
/dev/dm-0 partition 2097148 0 -2
As I suspected systemd is the culprit.
dev-disk-by\x2duuid-8a852d8d\x2d56cf\x2d4478\x2da13e\x2d0405fa7239dc.swap - /dev/disk/by-uuid/8a852d8d-56cf-4648-a13e-0405fa7239dc
Loaded: loaded (/etc/fstab; generated)
Active: active since Tue 2023-01-10 12:49:44 CET; 2 weeks 2 days ago
What: /dev/disk/by-uuid/8a852d8d-56cf-4678-a13e-0405fa7239dc
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
Tasks: 0 (limit: 38460)
Memory: 200.0K
CGroup: /system.slice/dev-disk-by\x2duuid-8a852d8d\x2d56cf\x2d4478\x2da13e\x2d0405fa7239dc.swap
After reading a bit about systemd swap I realized that this drive is not mounted through a unit file since there does not appear to be one.
Now I suspect that systemd-gpt-auto-generator automatically mounts the swap drive through discovery.
https://man.archlinux.org/man/systemd-gpt-auto-generator.8
What I do not understand is how to safely disable only the swap mounting.
I don't really want to throw overboard all of this default configuration since it is running on many systems. And the risk of future updates depending on this and thus causing anomalies.
I could remove the swap partition altogether but this is really the ugliest of fixes and also not very linux like.
And I really don't want to have inexperienced admin's messing around with the deletion of partitions, it's just not worth the risk.
Another non-solution is to adjust swapiness but I really don't want swap.
Someone on stackexchange mentioned doing a swapoff post boot which really isn't a solution either.
rant: Systemd once again fixing what isn't broke and ignoring KISS as if designed by microsoft. These things used to be predictable.
Also: I am running software that really suffers from swap and i'd rather have it crash then being swapped.
Last but not least it is stunning how little information can be found on the subject, I can not possibly be the only one with this problem.
Any input is appreciated! Thanks in advance.
Edit
Per request:
output of swapon -s
Filename Type Size Used Priority
/dev/dm-0 partition 2097148 2316 -2
Output of /etc/fstab
UUID="f7285d85-d18f-4a10-9580-e54a2cd4581c" / ext4 defaults,errors=remount-ro 0 1
Output of systemctl --type swap
UNIT LOAD ACTIVE SUB DESCRIPTION
dev-dm\x2d0.swap loaded active active /dev/dm-0