meta data for this page
This is an old revision of the document!
SWAP on Btrfs
SWAP on BTRFS is supported since Kernel 5.0.7. SWAP cannot be located on snapshoted volume. The best is to create seperate volume for swap file.
Get top level ID of BTRFS:
btrfs sub list / ID 256 gen 394 top level 5 path @ ID 258 gen 401 top level 5 path @home ...
mkdir -p /mnt/btrfs mount -o subvolid=5 /dev/... /mnt/btrfs cd /mnt/btrfs btrfs sub create @swap cd @swap truncate -s 0 ./swapfile chattr +C ./swapfile btrfs property set ./swapfile compression none fallocate --length 8.2GB swapfile chown root swapfile chmod 600 swapfile mkswap swapfile swapon swapfile umount /mnt/btrfs mkdir /.swap
UUID=1cf7e34b-8b09-45bd-80ae-f4658b3e0509 /.swap btrfs compress=none,nodatacow,noatime,subvol=@swap
</file>