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

or

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
About 
Sysadmin on the everlasting journey of learning. Always in search for an opportunity to prove myself and to learn something new. My addiction is learning and my main goal is to excel in every aspect of Linux/Unix system administration.

2 Comments

  1. Tankiso Thebe

    2016-06-09 - 02:35
    Reply

    Thanks This is The simplest and yet working…

Leave a Reply

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