Creating / Removing a Swap File

Last modified: January 23, 2019
You are here:
Estimated reading time: < 1 min

Create Swap File:

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Make Swap File Permanent:

sudo nano /etc/fstab

Add to the end:

/swapfile none swap sw 0 0

Removing a Swap File:

sudo vi /etc/fstab

Remove from the end:

/swapfile none swap sw 0 0
(line aforementioned may vary on configuration)

Was this article helpful?
Dislike 0
Views: 1
Menu