31.4 Adding a Swap File to a Fedora 31 System
Additional swap may be added to the system by creating a file and assigning it as swap. Begin by creating the swap file using the dd command. The size of the file can be changed by adjusting the count= variable. The following command-line, for example, creates a 2.0 GB file:
# dd if=/dev/zero of=/newswap bs=1024 count=2000000
2000000+0 records in
2000000+0 records out
2048000000 bytes (2.0 GB, 1.9 GiB) copied, 3.62697 s, 565 MB/s
Before converting the file to a swap file, it is important to make sure the file has secure permissions set:
# chmod 0600 /newswap
Once a suitable file has been created, it needs to be converted into a swap file using the mkswap command:
# mkswap /newswap
Setting up swapspace version 1, size = 1.9 GiB (2047995904 bytes)
no label, UUID=4ffc238d-7fde-4367-bd98-c5c46407e535
With the swap file created and configured it can be added to the system in real-time using the swapon utility...