How to use a file as a swap memory ?
When the physical memory of the system (RAM) is full, swap memory is used. Swap memory is created at the time of operating system installation. We can later use a file as a swap memory. We need to first create a file.
dd if=/dev/zero of=/swapfile bs=1024 count=65535
This will create a 64Mb of swapfile. To create more larger swap file increase count value. count can be calculated as (count= ‘block size’ * ‘file size in Mb’).
sudo mkswap /swapfile sudo swapon /swapfile
To check if swapfile is active or not run the command,