Articles


How To Increase Swap Memory In Linux

How To Increase Swap Memory In Linux



Posted bynitheesh,2nd May 2016

Swap space is a portion of a hard disk drive that is used for virtual memory. Virtual memory is the use of space on a HDD to simulate additional main memory. Memory is used to hold portions of the operating system, programs and data that are currently in use or that are frequently used. Swap space is usually a dedicated partition that is created during the installation of the operating system. Such a partition is also referred to as a swap partition. However, swap space can also be a special file.

Method for increase swap memory

First, you must create a file

sudo dd if=/dev/zero of=/mnt/file.swap bs=1M count=512

Second, You are instructing linux to create a file of 512 blocks of 1Mb each. You may need to change that value according to your needs.

sudo mkswap /mnt/file.swap

After that, format the file ad swap

sudo swapon /mnt/file.swap

Atlast, add the file to system, so it can be used

That is only temporal for this session, if you want this to permanent, add the following line to the /etc/fstap file

/mnt/file.swap none swap sw 0 0