8 Creating Swap Files on a Btrfs File System
Swap space is used in Oracle Linux when the amount of physical memory (RAM) is full. If the system needs more memory resources, and the RAM is full, inactive pages in memory are moved to the swap space. Although swap space is helpful for systems with a small amount of RAM, don't use swap space as a replacement for more RAM. You can allocate swap space to a dedicated swap partition, which is the recommended method. Or, you can use a swap file; or, you can combine the use of swap partitions and swap files.
Swap files in Btrfs are supported with the following limitations:
-
A swap file can't be on a snapshotted subvolume. Instead, we recommend that you create a subvolume on which to place the swap file.
-
Btrfs doesn't support swap files on file systems that span several devices.
The following are step-by-step instructions for creating a swap file in Btrfs. Before creating the new swap file, calculate the size of the swap file in MB. Then, multiply that number by 1024 to find the number of blocks the file requires. For example, the block size of a 64 MB swap file is 65536.