Suspend / resuming with a loopback swap file (required by btrfs)

btrfspower-managementsuspend

I have a small SSD and want to be able to dynamically tune the size of my swap (using swappiness=1, my intention is to use it for suspend to disk only)

btrfs does not support using a swap file unless it is loop mounted. How do I suspend / resume with a swap file mounted via losetup?

I'm running Manjaro with Linux kernel 4.9. The btrfs is an LVM LV, on LUKS.

Best Answer

Upgrading Linux kernel to 5.0+ might help with this.

I haven't tried it myself, but according to the FAQ https://btrfs.wiki.kernel.org/index.php/FAQ#Does_btrfs_support_swap_files.3F

Does btrfs support swap files?

From kernel 5.0+ btrfs have native swap files support, but with some limitations. Swap file - must be fully allocated as NOCOW with no compression on one device.

Related Question