My Experiences with Databases & More

Oracle-MySQL-SQL SERVER-Python-Azure-AWS-Oracle Cloud-GCP etc

  • Enter your email address to follow this blog and receive notifications of new posts by email.

  • Total Views

    • 558,488 hits
  • $riram $anka


    The experiences, Test cases, views, and opinions etc expressed in this website are my own and does not reflect the views or opinions of my employer. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content.Product and company names mentioned in this website may be the trademarks of their respective owners.

How to Add Swap Memory using a file

Posted by Sriram Sanka on December 22, 2018


 

Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space.

Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.

We can Create Swap file and make use of it as described below .

Step 1: Create a file with required size

To create the file we need to use dd command as root user .

 

I am adding 64G of Swap to my server so the count is 67108864 (1024 * 1024 * 64) 

dd if=/dev/zero of=/u03/extra_swap bs=1024 count=67108864

 

Step 2: Change the file Permission using

chmod 0600 /u03/extra_swap

Step 3 : Set Up linux Swap Area.

[root@idc ~]# mkswap /u03/extra_swap


Step 4 :Execute the Following To enable the swap file immediately, You can Check the Added swap using free -g Command .

swapon /u03/extra_swap


Step 5: Add an Entry in /etc/fstab to Make this Swap file Enabled at boot Time

/u03/extra_swap swap swap defaults 0 0

We can use swapon or /proc/swap to Get the Swap info.




 

 

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: