Create a swap space in Debian

First, connect to your server with the root access.

Then create the storage file :

dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

Give the permission to the file :

chown root:root /swapfile1
chmod 0600 /swapfile1

Setup a swap area :

mkswap /swapfile1

Enable the swap file :

swapon /swapfile1

Edit the fstab :

nano /etc/fstab

Add the following line at the end of the fstab :

/swapfile1 none swap sw 0 0

Finally, check if it is working :

free -m

You should get values instead of the zero inside the swap line.

See more : https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/

Share

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz