1832831 Members
2968 Online
110047 Solutions
New Discussion

Swap space for Linux

 
Shehan
Super Advisor

Swap space for Linux

Hi All

I am going to install RHEL5 for the DL580 server. It has 8GB RAM. But I don't know most suitable swap space for the 8GB RAM Space. Please help me to solve this out.

Regards
Nirukshitha
14 REPLIES 14
Sajjad Sahir
Honored Contributor

Re: Swap space for Linux

Dear Friend

The reality is the amount of swap space a system needs is not really a function of the amount of RAM it has but rather the memory workload that is running on that system. A Red Hat Enterprise Linux 5 system will run just fine with no swap space at all as long as the sum of anonymous memory and system V shared memory is less than about 3/4 the amount of RAM. In this case the system will simply lock the anonymous and system V shared memory into RAM and use the remaining RAM for caching file system data so when memory is exhausted the kernel only reclaims pagecache memory.

Considering that 1) At installation time when configuring the swap space there is no easy way to predetermine the memory a workload will require, and 2) The more RAM a system has the less swap space it typically needs, a better swap space

Swap space == Equal RAM size (if RAM < 2GB)
Swap space == 2GB size (if RAM > 2GB)
Swap space == Equal RAM size (if RAM < 8GB)
Swap space == 0.50 times the size of RAM (if RAM > 8GB)


thanks and regards

Sajjad Sahir
Shehan
Super Advisor

Re: Swap space for Linux

Dear Sahir

As per the customer requested, I kept 32GB SWAP sapce for 16GB memory. My HDD is 146GB and created 8GB x 4 SWAP sapce instead of creating 32GB swap sapce. So let me know that any thing wrong with this config.

Regards
Nirukshitha
Michal Kapalka (mikap)
Honored Contributor

Re: Swap space for Linux

hi,

i think the SWAP space should be contignues if its on one HDD, if each SWAP is on separated physical HDD them your option will be the best to the performance.

mikap
Shehan
Super Advisor

Re: Swap space for Linux

Hi
I have created these all swaps on a one disk.So may I able to get all 4 swaps into one swap now? Or else , if i use this as it is, will it be issue for the perfomance?

Regards
Nirukshitha
Michal Kapalka (mikap)
Honored Contributor

Re: Swap space for Linux

Hi,

check fdisk -l /dev/your_disk

and if the swaps are together it could be ok,

but if there are some partitions between the disk wiil be slower as if you are use one SWAP.

mikap

PS : in my opinion is to use better one swap instead of many on the same disk !!!.

the swap shhould be always contigues, if isn;t the head on the HDD will spin betveen 2-4 swap areas, and of course the speed will be decreesed !!!
Shehan
Super Advisor

Re: Swap space for Linux

Hi
What is the possibility of deleting all 4 existing swaps and create one 32GB swap?

Regards
Nirukshitha
dirk dierickx
Honored Contributor

Re: Swap space for Linux

just remove them and create a new one, nothing special about it. can be done on a running system.
Shehan
Super Advisor

Re: Swap space for Linux

Dear Dirk

Can you please point out the commands?

Regards
Nirukshitha
Ben Stokes
Frequent Advisor

Re: Swap space for Linux

Hi

Just my humble opinion but 32Gb of disk space for swap is wasteful.

Official guidance from Red Hat is a minimum of 16Gb of swap for 32Gb of RAM. http://kbase.redhat.com/faq/docs/DOC-15252

Personally I would stick to the 16Gb minimum - in my experience once a server has used more than around 4Gb of swap performance of the whole server will be significantly affected.

32G of physical RAM should be ample for most applications, but the rules for swap are different for some applications, for example Oracle has specific guidlines for their own software. What are you planning to run on this server?
Shehan
Super Advisor

Re: Swap space for Linux

Hi

This is going to be installed Oracle. Oracle Vender asked us to keep the swap space as 32GB because applications may take lot of memory.Accordingly we kept 32 GB and 32GB was devided in to 4 and kept 4 x 8GB swap space in the same disk.

Regards
Nirukshitha
Ben Stokes
Frequent Advisor

Re: Swap space for Linux

Hi, Oracle recommendations are to use 0.75 x the amount of physical RAM for servers with more than 8Gb of RAM. Therefore 26Gb of swap if you have 32Gb of physical RAM.
loco_vikide
Frequent Advisor

Re: Swap space for Linux

The old thumb of rules for swap size no longer apply with modern hardware and OS. Read the following article for your reference. There are many articles out there that say about the same thing:

http://www.cyberciti.biz/tips/linux-swap-space.html

Cheers.
John McNulty_2
Frequent Advisor

Re: Swap space for Linux

I agree with loco; old rules do not apply any more.

Splitting swap into 4 partitions on the same disk doesn't gain you anything. Better to keep it as one area.

Same thing goes for contiguous swap partitions. Swap files are just as fast as raw partitions now on 2.6, and are not contiguous. In fact a default Redhat install will create an LVM Logical Volume for swap, and that is definitely not contiguous by default. The default allocation policy for an LV is "inherit" which copies the default "normal" allocation policy from the Volume Group. You can change an LV's allocation policy to contiguous if you want with lvchange, and the allocation policy changes accordingly as seen in lvdisplay.
Steven E. Protter
Exalted Contributor

Re: Swap space for Linux

Shalom,

The old rule that swap needs to be twice RAM simply does not apply on large ram systems.

You need swap to be at least 50% ram to have adequate swap reservation space for processes.

I find a 1 to 1 ratio works on big systems.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com