To create a swap file on Ubuntu 23.10, follow these steps:
Step 1 : Start by creating a swap file. Check your system's memory usage with:
and disk space with:
Step 2 : Allocate space for the swap file (replace 2G with the desired size):
Step 3 : Set proper permissions for security:
Step 4 : Format the file as swap:
Step 5 : Activate the swap file:
Step 6 : Confirm that the swap is active:
Step 7 : Make the changes permanent by adding the swap file to the /etc/fstab
file. Open the file with a text editor:
and add the following line at the end:
Save and exit the text editor.
Congratulations! You have successfully created a swap file on your Ubuntu 23.10 system.