The wiki say also to chattr the directory and not the file only…
Swap files in Btrfs are supported since Linux kernel 5.0.[8] The proper way to initialize a swap file is to first create a non-snapshotted subvolume to host the file and then set the
No_COW
attribute on the whole directory with chattr.
# chattr +C */path/to/swapsubvolume*
From now on any new file created inside the swap subvolume will have theNo_COW
attribute set.
[joe@joe-virtualbox ~]$ sudo lsattr /swap
---------------C------ /swap/swapfile
[joe@joe-virtualbox ~]$ sudo lsattr /swap/swapfile
---------------C------ /swap/swapfile