HostOnNet Blog

swap

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