How do I create swapfile in btrfs?

If you are working from a system with root mounted, this should work for all scenarios:

findmnt / -no UUID

That is if you need that root UUID.

EDIT: It seems you posted the same thing at the same time :slight_smile:

2 Likes

I used before the UUID for the / for resume=UUID=… as well but it didn’t work or perhaps I miscalculated the resume_offset.

My @swap is on the root of the BTRFS partition.
I mount it at /swap and then I follow exactly the steps in the Wiki to set it up.
Swap works just fine but I don’t seem to get it right in the kernel boot options.

free -m
               total        used        
free      shared  buff/cache   available
Mem:           15899        2498        9170        1399        4229       11698
Swap:          16383           0       16383

From cat /etc/fstab:

UUID=c1f8bfe7-8e93-40af-8624-368452eab280    /swap        btrfs     subvol=/@swap
/swap/swapfile                               none         swap      defaults 0 0

https://raw.githubusercontent.com/endeavouros-team/snippets/main/BTRFS-resume-creator
seem sto work now :wink:

1 Like

2022-01-14_20-36
2022-01-14_20-36_1

at least defaults must be there and the 0 0 dump should be in the mount line for /swap

1 Like

Thanks!
I’ll try a report back in a bit.