How to Create a Swap File on Rocky Linux 9

To create a swap file on Rocky Linux 9, follow these steps.

Step 1 : Begin by checking the available system memory using the command:

Step 2 : Verify the available disk space using:

Step 3 : Allocate 2GB of space for the swap file using the fallocate command.

Step 4 : Set proper permissions on the swap file.

Step 5 : Configure the swap file using mkswap.

Step 6 : Activate the swap file.

Step 7 : Verify the swap file is active.

Step 8 : Update /etc/fstab

- Ensure the swap file is persistent across reboots by modifying the /etc/fstab file:

- Add the following line:

Congratulations! You have successfully created and configured a swap file on Rocky Linux 9.