Operating System - Linux
1755752 Members
4931 Online
108837 Solutions
New Discussion юеВ

Re: swap space recommendation on linux

 
SOLVED
Go to solution
skt_skt
Honored Contributor

swap space recommendation on linux

# cat /etc/redhat-release
Red Hat Linux Advanced Server release 2.1AS (Pensacola)

# uname -a
Linux hostname 2.4.9-e.71smp #1 SMP Thu Nov 23 11:51:48 EST 2006 i686 unknown

i have 4GB RAM and 4GB swap currently. often the swap goes beyond 85%.

What would be the ideal RAM/SWAP ratio?what are the recommendations when we add the swap online?I would like to add additinal swap space from an existing disk /dev/sdb. I dont have LVM.My plan is to create one 2GB partion on /dev/sdb


# swapon -s
Filename Type Size Used Priority
/dev/sda2 partition 2097136 1548124 -1
/dev/sdb1 partition 2097136 1268328 -2

10 REPLIES 10
Ivan Ferreira
Honored Contributor
Solution

Re: swap space recommendation on linux

According to the installation guide, swap should be:

Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then 1x physical RAM for any amount above 2 GB, but never less than 32 MB.

Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Stuart Browne
Honored Contributor

Re: swap space recommendation on linux

Your swap utilization is over 85% ?!?

I'd be suggesting you invest in more memory!
One long-haired git at your service...
dirk dierickx
Honored Contributor

Re: swap space recommendation on linux

there is no ideal formula. it depends on the type of app you're running and the load caused by that app.

all our linux servers share the same install, but you'll find different swap utilization on all of them.
~sesh
Esteemed Contributor

Re: swap space recommendation on linux

Ideally for a system with 4 GB of memory swap file utilization should be minimum.

Normally swap file is set to 1.5 - 2.0x the physical memory. However, as the memory increases, the rule need not be adhered to.

There is also a parameter called swappiness (/proc/sys/vm/swappiness), if you are sure that the physical memory is sufficient for the operations and that swap file need not be used much you can reduce the swappiness.

It goes from 0 - 100, higher the number, greater the tendency to use the swap file. You can read more about swappiness at:

http://kerneltrap.org/node/3000
Jeroen Peereboom
Honored Contributor

Re: swap space recommendation on linux

If your system is swapping, either investigate why it needs so much memory or just buy more memory. IMHO a server should use minimal swap space.

JP
skt_skt
Honored Contributor

Re: swap space recommendation on linux

below is the information i see ..As per that i cannot add another swap partition if the same disk is already in use as FS or a swap partition.

"How do I add a swap partition to my system in Red Hat Enterprise Linux? Resolution:To add a swap partition (assuming /dev/hdb2 is the swap partition you want to add): The hard drive can not be in use (partitions can not be mounted, and swap space can not be enabled). The partition table should not be modified while in use because the kernel may not properly recognize the changes. Data could be overwitten by writing to the wrong partition because the partition table and partitions mounted do not match. The easiest way to achieve this is to boot your system in rescue mode. When prompted to mount the file system, select Skip.

Alternately, if the drive does not contain any partitions in use, you can unmount them and turn off all the swap space on the hard drive with the swapoff command."

is there anyway i can achieve adding another swap partition from same disk w/o taking down time?
Stuart Browne
Honored Contributor

Re: swap space recommendation on linux

If there is available space on the disk, then you should be able to.

If you've got no available space (unpartitioned space), but available space in a filesystem, then you can create 'swap files', and use them as swap space instead to get you past a temporary issue.

The details on how to do that are in the 'mkswap' man page.
One long-haired git at your service...
skt_skt
Honored Contributor

Re: swap space recommendation on linux


But the recommendation/warning posted in "quote" (from parted)do NOT allow me to go ahead and try this. Also this is a PROD box and dont want to give a chance

i have enough space on this particular disk. But there is an existing swap partition on the same disk.

I started with fdisk ; created a partion with id 82(Linux-swap)

But swapon was failing .

#swapon /dev/sdb2
swapon: /dev/sdb2: No such device or address

Then i started with parted. So what i posted in quote earlier are the recommendations from parted.

"mkpart PART-TYPE [FS-TYPE] START END make a partition"
skt_skt
Honored Contributor

Re: swap space recommendation on linux


the ansers to "swap space recommendation on linux" were pretty help full.

but adding swap online from an existing disk(swap enabled with one partion) is not possible with 2.1 kernel.

other choice to add file swap whihc i dont prefer for this scenario.