1828793 Members
2655 Online
109985 Solutions
New Discussion

Re: swap question

 
Chakravarthi
Trusted Contributor

swap question

hi,

on my machine swap is not getting used, i have even tried creating a additional swap file and added it still no luck. this is happening on 2.2 kernel.

--chakri

11 REPLIES 11
Claudio Cilloni
Honored Contributor

Re: swap question

but... do you get "out of memory" errors?
Patrick Terlisten
Honored Contributor

Re: swap question

Hello Chakravarthi,

can you post the output of the command "free -m"? Did you get any errors because of insufficient memory? Linux don´t use swap if it not must.

Regards,
Patrick
Best regards,
Patrick
Kodjo Agbenu
Honored Contributor

Re: swap question

Hi,

After creating the swap partition, you need to format it by using :

mkswap

Then you can mount it with :

swapon

If you want this to be done automagically at boot, add the following line in /etc/fstab :

/dev/vg01/lvswap swap swap defaults 0 0

Good lcuk.
Kodjo
Learn and explain...
Ivan Ferreira
Honored Contributor

Re: swap question

"On my machine swap is not getting used"

This should be not a problem, the problem is if the swap is too used.

Why are you worried about the use of the swap.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ralph Grothe
Honored Contributor

Re: swap question

Why do you want your box swapping?

No seroiusly, you can check if and what swap device/file is enabled by

$ /sbin/swapon -s
Filename Type Size Used Priority
/dev/sda3 partition 1028152 79976 -1

alternatively look up in /proc

cat /proc/swaps
Filename Type Size Used Priority
/dev/sda3 partition 1028152 79976 -1

Usually, as already said by others creating and activating swap is as easy as using the two commands mkswap and swapon.

However, it could be that (for what ever reason) you have set a swapiness too low (if set at all)

Check by

# sysctl -a | grep swap

if it's set.
Also see
http://kerneltrap.org/node/3000/print
Madness, thy name is system administration
Chakravarthi
Trusted Contributor

Re: swap question

i'm left with very limited physical memory, and machine is tooo slow to work
Chakravarthi
Trusted Contributor

Re: swap question

free -m output

total used free shared buffers cached
Mem: 895 316 578 0 13 80
-/+ buffers/cache: 223 672
Swap: 2047 0 2047
Claudio Cilloni
Honored Contributor

Re: swap question

You have 578 MB of free memory out of 895 MB of available physical memory!
Your machine isn't using swap space because it isn't necessary.

Everything is ok.
Chakravarthi
Trusted Contributor

Re: swap question

that about this??

total used free shared buffers cached
Mem: 895 876 18 0 68 48
-/+ buffers/cache: 760 135
Swap: 2047 0 2047
Ivan Ferreira
Honored Contributor

Re: swap question

Linux will always use all memory available, but not for applications, but for buffer/cache. So, you probably won't see a Linux system with 50% of memory usage.

The -+buffers line in the free command shows the free memory without buffers.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Patrick Terlisten
Honored Contributor

Re: swap question

Hi,

short answer: 135MB of 895MB memory are free and your system does not need to swap. :)

Most linux-systems have a memory usage of over >50%, but the memory is used for cache and buffers. This memory will be used if an application needs more memory.

So everything´s right. :)

Regards,
Patrick
Best regards,
Patrick