To create a swap file on CentOS 7, follow these steps:
Step 1 : Check current memory usage
Step 2 : Check disk space
Step 3 : Allocate space for the swap file (replace 2048 (2G) with desired size)
Step 4 : Set appropriate permissions
Step 5 : Set up swap space
Step 6 : Enable the swap file
Step 7 : Verify swap is active
Step 8 : Make the swap file permanent by editing /etc/fstab
Add the following line:
Congratulations! You have successfully created a swap file on CentOS 7.