Create Linux Swapfile

1. Add Swap File

$ sudo fallocate -l 1G /swapfile

Create a 1GB swap file on Linux system

2. Set Swap File Permission

$ sudo chmod 600 /swapfile

3. Setup Linux Swap Area

$ sudo mkswap /swapfile

4. Enable the Swap

$ sudo swapon /swapfile

Modify /etc/fstab to enable the entry. Append the following line in the file

/swapfile swap swap defaults 0 0

5. Verify the swap status

$ sudo swapon --show

Leave a Reply

Your email address will not be published. Required fields are marked *