I'm playing around with nixos in a few VMs and at some point I realized I must have lost the swap configuration in one of my refactorings.
To my surprise, however, the VMs do use the swap partitions I had set up.
There is no mention on "swap" in my nix configuration (or in fstab
) and no .swap
units in /etc/systemd/system
; I do however have a swap partition labelled "swap".
Turns out there is a systemd unit (albeit not a corresponding file) that sets up swap:
[root@vm1:~]# free -hw
total used free shared buffers cache available
Mem: 2.8Gi 664Mi 955Mi 4.0Mi 3.0Mi 1.3Gi 2.0Gi
Swap: 3.7Gi 0B 3.7Gi
[root@vm1:~]# systemctl list-dependencies swap.target
swap.target
● └─dev-disk-by\x2ddiskseq-1\x2dpart3.swap
I'm wondering where the unit comes from? Can I rely on this and never configure swap ever again?
Apparently they still get auto-mounted even if they aren't in your config. You can check the wiki.