Ivan Tomica

Swap file

First step is to create empty file (I’ll create 1GB one). You can do that by issuing one of the following commands (you’ll need to be root):

fallocate -l 1G /swapfile


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

After that change permissions on that file so nobody else can read it:

chmod 600 /swapfile

Make swap:

mkswap /swapfile

And at last, activate it:

swapon /swapfile

If you want your system to mount that swap automatically on boot you should add following entry to your /etc/fstab file:

/swapfile    swap    swap    defaults    0 0
Sysadmin on the everlasting journey of learning.


  1. Tankiso Thebe

    2016-06-09 - 02:35

    Thanks This is The simplest and yet working…

Leave a Reply

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