How to increase Swap Memory in CentOS 7

0 votes

In the terminal, on giving free -m command, I was able to see that my swap space in the memory was just 2048 MB. But for my work and for Oracle database I need to increase the swap space. I have enough memory space. How can I do that? Please let me know.

Oct 5, 2018 in Linux Administration by Neha
• 6,300 points
15,842 views

1 answer to this question.

0 votes

Follow the below steps and procedures:

Prerequisites

Must have free space on mounted disk. You can check by using df -Th command.

Next follow these:

1. Create swapfile-additional file with dd command in / (root). You can select any other partition but it should be mounted (For eg. /opt, /usr ,/NewMountedPartition)

dd if=/dev/zero of=/swapfile-additional bs=1M count=4048

dd = It is a unix command used for convert and copy a file
if = read from FILE instead of stdin
/dev/zero = /dev/zero is a special file in Unix-like operating systems that provides as many null characters (ASCII NUL, 0x00) as are read from it
of = write to FILE instead of stdout
/swapfile-additional = file named swapfile-additional will be created in /
bs = Read and write bytes at a time but if you do not mention MB or GB like only number it will read as bytes. for eg. bs=1024 means 1024 bytes
count = Copy input blocks in our case it is 1024 (1M * 4048 = 4GB)

2. Run mkswap command to make swap area

mkswap /swapfile-additional

3. Change the permission of file swapfile-additional

chmod 600 /swapfile-additional

4. Permanent mounting the swap space by editing the /etc/fstab file .
Use your file editor, I generally use vi editor.

vi /etc/fstab

Paste below given content in /etc/fstab file

/swapfile-additional swap swap    0   0

5. Now mount the swap area, run below given command.

mount -a

6. Enable the swap area

swapon -a

7. Check the number swap space mounted on your system

swapon -s

8. To check how much is swap space available on system. Run below given command

free -m


Hope it helps!

Enroll with Linux training online and learn in detail about Linux.

Thanks.

answered Oct 5, 2018 by Frankie
• 9,830 points

Related Questions In Linux Administration

0 votes
1 answer

How to configure SSH server in RHEL/CentOS?

Hi@MD, To configure SSH server to your system, ...READ MORE

answered Mar 30, 2020 in Linux Administration by akhtar
• 38,260 points
1,009 views
0 votes
1 answer

How to install nginx web server in CentOS/RHEL?

Hi@akhtar, To install nginx in your system, you ...READ MORE

answered Apr 24, 2020 in Linux Administration by MD
• 95,460 points
796 views
0 votes
1 answer

How to break root password in CentOS/RHEL 8?

Hi@akhtar, Reboot the system and interrupt the boot ...READ MORE

answered May 11, 2020 in Linux Administration by MD
• 95,460 points
1,797 views
0 votes
1 answer

How to increase Logical Volume Size in Linux?

Hi@akhtar, To increase the Logical Volume Size, the ...READ MORE

answered Jul 9, 2020 in Linux Administration by MD
• 95,460 points
1,223 views
0 votes
1 answer

How do I enable Oracle automatically on systemboot?

To enable the database service to start ...READ MORE

answered Oct 5, 2018 in Database by Frankie
• 9,830 points
671 views
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 12, 2020 in Database by Prachi
• 140 points
1,151 views
0 votes
1 answer

Access progrs prompt without switching accounts

Use the following to get the postgres prompt ...READ MORE

answered Mar 22, 2019 in Database by Mahi
785 views
0 votes
1 answer

Create new role - postgresql on ubuntu

If you are logged in as the postgres account, ...READ MORE

answered Mar 22, 2019 in Database by Danny
816 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP