How to Create a Swap File on Ubuntu 26.04

To create a swap file on Ubuntu 26.04, add a file and enable it in fstab.

Step 1 : Check RAM.

Step 2 : Check disk space.

Step 3 : Create a 2G file.

Step 4 : Restrict permissions.

Step 5 : Format as swap.

Step 6 : Enable.

Step 7 : Verify.

Step 8 : Make it persistent.

You have created a swap file on Ubuntu 26.04.