Welcome to the Linux Foundation Forum!

[Lab 16.1] Swap files and openSUSE

albertgoma Posts: 9
edited March 18 in LFS207 Class Forum

Due to the fact that openSUSE's default filesystem is BTRFS, it doesn't allow creating swap files in the conventional way. The following must be done instead (As seen on the ArchWiki):

opensuse:~ # btrfs subvolume create /swap
Create subvolume '//swap'
opensuse:~ # btrfs filesystem mkswapfile --size 1g --uuid clear /swap/swapfile
create swapfile /swap/swapfile size 1.00GiB (1073741824)
opensuse:~ # swapon /swap

And then we can see the results:

opensuse:~ # cat /proc/swaps 
Filename                Type        Size        Used        Priority
/swap/swapfile                          file        1048572     0       -3

I assume the creation of a dedicated subvolume for the swap file must be to prevent it from being accidentally snapshotted alongside with other parts of the filesystem (i.e. by tools such as zypper and YaST when used with Snapper, such as in the default install).



Upcoming Training