How to Increase Swap Memory in CentOS 7 (Using Swap File)

Swap memory is a great way to avoid using excessive amounts of your system’s RAM. By using swap, your computer can temporarily store data that is not currently being used on your hard drive. When you start to use more RAM than is available on your computer, the operating system will start to load data from your swap file instead.

Swap File and CentOS 7

Swap File is a special type of file that you can use on your CentOS 7 server to increase your server’s memory. Swap File is used to store temporary data that your computer can use instead of using the regular disk space.

To increase your swap memory on CentOS 7, you first need to set up a swapfile. You can do this by creating a file called swapfile in the /etc directory. The size of the swapfile will depend on the amount of memory that you have installed on your server.

Once you have created the swapfile, you need to enable it by editing the /etc/swapfile/swapfile.conf file. The following line needs to be added to the bottom of the file:

Also Read :   How to Configure iSCSI Target with Two LUNs on CentOS 7 (Using HDD Partitions)


After you add this line, you need to make sure that your system has enough free space in the /var/lib/swap folder so that the swapfile can be created. You can check this by running the swapon command:

# swapon –all

If everything is correct, you should see something like this:

# swapon –all Files

How to create Swap File in CentOS 7?

In this blog, we will show you how to increase swap memory in CentOS 7 using Swap File. Swap File is a temporary storage space that can be used to increase the RAM available to your server.

Swap File can be created on any filesystem with enough free space. We recommend creating Swap File on a partition that is not currently used for anything else. This will allow your server to use all of the available disk space, which will improve performance.

To create a Swap File in CentOS 7, follow these steps:
1. First, determine how much RAM your server needs.
2. Next, calculate how much disk space you need for the Swap File.
3. Finally, create the Swap File using the following command:
# swapon -s < Swapon Size In MB > < Partition To Use For Swap Files >

How to use Swap File in CentOS 7?

The swap file is a temporary storage area on a computer that is used when the system is not able to use the regular memory. By default, CentOS 7 uses the swap file when the total amount of RAM on the computer is less than 4GB. The swap file can be used to temporarily store files that are needed but are not currently in use.

Also Read :   How to Disabling all SSL/TLS Protocols except TLSv1.2 in CentOS7/RHEL7

To increase swap memory in CentOS 7, you can create a swap file using the following command:

swapon -s 512M
Where is the name of the swap file that you want to create. The size of the swap file should be equal to or greater than the amount of RAM that you want to use. For example, if you want to use 1GB of RAM, your swap file should be at least 1GB in size.


Swap is a great tool for mitigating the impact of swap space shortages on systems, but it can be quite limiting. In this article, we will show you how to increase swap memory in CentOS 7 using a swap file. By following these simple steps, you will be able to free up more space on your system and improve your overall performance.


Swap memory is a mechanism that allows Linux systems to use physical memory as if it were extended beyond the system’s actual physical memory. This can be useful for applications that need more memory than the system provides, or for times when the system is running low on physical memory and needs to cache data from disk.

Also Read :   How to disable Trace/Track in Apache/httpd

There are two ways to increase swap memory in CentOS: by using a swap file or by using the swapon command.

To use a swap file, create a file called swapfile in your operating system’s root directory. The size of the swap file will be determined by your computer’s RAM configuration. After you create the swapfile, you must add it to your system’s bootloader so that it will be used when the system starts up. To do this, use the following command:

# swapon -s

To use the swapon command, type the following command:

# swapon

Leave a Comment