If you are using btrfs, it is /swap
that should be a subvolume. You then put the swapfile inside that subvolume.
If /swap
isn’t already a subvolume, you should create one there first.
The reason you use a separate subvolume for swap is that you cannot activate a swapfile on a subvolume that has snapshots. That is why you use a separate subvolume.
As a side note, you no longer need to follow all the above steps. If /swap
is a subvolume, you can do this instead:
sudo btrfs filesystem mkswapfile --size 8G /swap/swapfile
sudo swapon swapfile