Create a swapfile afterwards, problems with btrfs

hi,

i am new in garuda and btrfs and I also forgot to create a swap partition. The file system is encrypted with luks, so I don’t want to create a new partition but use a swap file instead.

sudo dd if=/dev/zero of=/swap/swapfile bs=1M count=32768
sudo chmod 600 /swap/swapfile
sudo mkswap /swap/swapfile
sudo swapon /swap/swapfile

swapon /swap/swapfile produces an error, “the argument is invalid”

I found the following warning in the log files:

Jan 24 21:30:47 hp kernel: BTRFS warning (device dm-0): swapfile must not be copy-on-write

How do I activate my swapfile in the btrfs file system?

You need to create a separate subvolume for the swapfile because you cannot use a swapfile on a subvolume that has snapshots.

Then create the swap file this way:

sudo btrfs filesystem mkswapfile --size 4g --uuid clear /path/to/swapfile
5 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.