To create a swap file on Ubuntu 23.04, follow these steps:
Step 1 : Begin the process by checking disk space and available memory using df -h
and free -m
commands.
Step 2 : Allocate a 2GB swap file using the command:
Step 3 : Set appropriate permissions for the swap file:
Step 4 : Mark the file as swap space:
Step 5 : Activate the swap file:
Step 6 : Confirm that the swap file is active:
Step 7 : Update the /etc/fstab
file to automatically mount the swap file on boot by adding the line:
Congratulations! You have successfully created a swap file on your Ubuntu 23.04 system.