Changing swap file on BTRFS

It’s unclear to me what the exact procedure to change the swap file on BTRFS.

According to wiki - Swap - Manjaro - it says I need to run

sudo truncate -s 0 /swapfile
sudo chattr +C /swapfile
sudo btrfs property set /swapfile compression none

before the sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress

But the file location is under /swap.
Or is it intentional in order to not mess with the original swapfile?
Also, do I need to disable the swapfile before running this?

What exactly are the commands and in what order they need to be executed in order to change the swapfile?

See here Btrfs - ArchWiki

1 Like

That doesn’t help me at all

It probably should, as all the information needed seems to be there, or linked to from the link @mithrial gave.

Firstly, I should state that I don’t use BTRFS and probably don’t understand it fully. However, I do know for example that BTRFS has sub volumes that must also be mounted. You will no doubt see the relevance of that as you work through the documentation.

Keep in mind that nobody is here to hand out step-by-step procedures for convenience, however, that too happens sometimes. It is expected that you read and understand information linked to, in order to scertain how it applies to your situation.

From what I can see, the information linked to is entirely relevant.

Cheers.

1 Like

Swapfile can whenever you want, but you should keep it in separate subvolume from main one, because you cannot snapshot a swapfile.

4 Likes

Two people have already posted this link.

separate subvolume because a swap file cannot be snapshotted and a subvolume is easy to exclude

and yes:
swapoff the present swap file before you create a new one or change the existing one

It does not get less hard than that.

1 Like