HostOnNet Blog

swap

Looking for Linux Server Admin or WordPress Expert? We can help.

To add swap file to linux system, first create a swap file.

For 1 GB

dd if=/dev/zero of=/swapfile bs=1M count=1024

For 2 GB

dd if=/dev/zero of=/swapfile bs=1M count=2048

For 8 GB

dd if=/dev/zero of=/swapfile bs=1M count=8192

Now run following commands to make the file swap file, then enable swap.

mkswap /swapfile
chmod 0600 /swapfile
swapon /swapfile

Make Swap Active On Boot

To make it active on boot, edit /etc/fstab, add

vi /etc/fstab

Add

/swapfile swap swap defaults 0 0

Posted in Linux

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.