My Experiments with Oracle

By Sriram Sanka -The AUAA

How to Add Swap Memory using a file

Posted by sriram 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.




 

 

 

Advertisements

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 )

Google photo

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

Twitter picture

You are commenting using your Twitter 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: