Swapfile error after update

After updating my system to the latest master branch, I started getting this error when rebuilding my system, and on reboot

Oct 10 08:54:29 nixos systemd\[1\]: Activating swap /swapfile...
Oct 10 08:54:29 nixos swapon\[4880\]: swapon: /swapfile: swap format pagesize does not match.
Oct 10 08:54:29 nixos swapon\[4880\]: swapon: /swapfile: reinitializing the swap.
Oct 10 08:54:29 nixos swapon\[4885\]: swapon: failed to execute mkswap: No such file or directory
Oct 10 08:54:29 nixos systemd\[1\]: swapfile.swap: Swap process exited, code=exited, status=255/EXCEPTION
Oct 10 08:54:29 nixos systemd\[1\]: swapfile.swap: Failed with result 'exit-code'.
Oct 10 08:54:29 nixos systemd\[1\]: Failed to activate swap /swapfile.

Sounds like there’s something wrong with your swapfile and you just need to do mkswap /swapfile again. The swapon command that systemd runs should be doing this itself, but looks like we’ve got a nixos bug where that swapon command can’t find mkswap for itself. Probably worth opening an issue about if there isn’t one already

1 Like

Yeah, though im running impermanence so the swapfile needs to be re-created every boot.

Anyway, where should I report this bug? Nixpkgs?

If it’s being created every boot then there must be something wrong with whatever you’re doing to create it.

Yep, but check if an issue already exists.

This makes me suspect something is wrong with your config rather than nixpkgs.

Well, I’ve already done some experimentation and confirmed there is a NixOS bug here. If swapon determines that it needs to fixup your swapfile with mkswap, it will fail because we don’t have mkswap on the default PATH for .swap systemd units. So that’s intended util-linux behavior that isn’t working on NixOS.

But yes, there’s clearly also an issue in @mg95’s config in terms of how their impermanence setup is creating the swapfile; for some reason it’s creating a swapfile that swapon later thinks needs fixing up.

1 Like