1753500 Members
3513 Online
108794 Solutions
New Discussion юеВ

Re: SWAP memory size

 
SOLVED
Go to solution
peterchu
Super Advisor

SWAP memory size

I want to change the swap memory size , could suggest how to check and change it ? Thx
9 REPLIES 9
Stuart Browne
Honored Contributor
Solution

Re: SWAP memory size

You can check your current configuration a few ways.

The easiest way to find out how much swap you've currently configured however is to just:

cat /proc/meminfo

To configure more swap, you can use one of three methods:

- If you've got available un-partitioned disk space, create a new swap partition in the available space.

- If you've got available disk-space, and want to resize an existing partition, reduce one, then do as above.

- Failing those two, create a paging 'file' on a filesystem (using dd) of the required size, then add that to the swap pool.

The first two methods should be pretty self explanatory.

The third however is a little more complex.

Basically you create a null-filled file of the required size by doing:

dd if=/dev/zero of=/myswapfile bs=1024b count=

You then 'mkswap /myswapfile' the file, and then swapon it.

If you need more details, drop a line, or read http://www.ibiblio.org/pub/Linux/docs/HOWTO/Swap-Space
One long-haired git at your service...
Hari Kumar
Trusted Contributor

Re: SWAP memory size

Hi peterchu

For Checking Swap Size and Usage,

Cat /proc/swaps

Adding a permanent swap file to the system is not recommended because it will lead to performance problems, instead u can add more physical memory.

Adding a Swap Space
Check this URL for more information.
http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/custom-guide/s1-swap-adding.html

Instead of using a raw device, u can a temporary file:

Try this
su - root
dd if=/dev/zero of=tmpswap bs=1k count=900000
chmod 600 tmpswap
mkswap tmpswap
swapon tmpswap

With Regards
Hari Kumar
Information is Wealth ; Knowledge is Power
Stuart Browne
Honored Contributor

Re: SWAP memory size

Ack! always forget about '/proc/swaps'! :)
One long-haired git at your service...
KapilRaj
Honored Contributor

Re: SWAP memory size

man mkswap
man swapon

Regds,

Kaps
Nothing is impossible
peterchu
Super Advisor

Re: SWAP memory size

thx all replies, one more question , we have the production db running on the system , is it possible to change the SWAP memory when the db was running , any impact to the system ? thx.
Stuart Browne
Honored Contributor

Re: SWAP memory size

So long as you dont *remove* the existing swap, it won't have any affect what-so-ever.

If none of the swap is currently in use, it also shouldn't have an effect if you remove the current swap.
One long-haired git at your service...
Hari Kumar
Trusted Contributor

Re: SWAP memory size

Hi

Dont Mind, assign some points if u got an acceptable answer through the forum. As these will be encouraging for the participants and keep the HP Forums go higher and higher

With Regards
Hari
Information is Wealth ; Knowledge is Power
SS_6
Valued Contributor

Re: SWAP memory size

#swapinfo -tam
Can also see by SAM, glance and I would suggest to create new SWAP and give same priority as you have on existing swap. SWAP filesystem is contigous and its always better to create new one in addition to current ones.
By providing solutions I am helping myself
Stuart Browne
Honored Contributor

Re: SWAP memory size

'swapinfo' isn't on every Linux distribution, and 'SAM' is a HP-UX command.
One long-haired git at your service...