# How can I test swap function??

## cgmd

Hi, all..

I'm trying to relate a memory issue I'm experiencing, to what I suspect to be a failed swap partition.

Is there a means to check the swap partition for functionality? How can I tell if it's corrupted?

Thanks!

----------

## desultory

You can check the swap partition, if it is not in use, using badblocks (consult man 8 badblocks for more information).

----------

## cgmd

Awesome...

Thanks!

----------

## cgmd

But... Having run badblocks 

```
badblocks -v /dev/hda2

Checking blocks 0 to 987997

Checking for bad blocks (read-only test): done

Pass completed, 0 bad blocks found.

```

I know only that swap has no bad blocks...

How can I now tell if swap is actually being used, as necessary, by the kernel? 

I seem to be experiencing a fatal memory drain without swap coming into play, before the system crashes.  :Confused: 

Thanks!

----------

## Jaglover

man 8 swapon

----------

## NeddySeagoon

cgmd,

Watch memory and swap use in top.

```
top - 20:41:44 up 10:10,  3 users,  load average: 0.40, 0.11, 0.04

Tasks:  97 total,   2 running,  95 sleeping,   0 stopped,   0 zombie

Cpu(s):  1.3%us,  0.7%sy,  0.0%ni, 97.3%id,  0.0%wa,  0.0%hi,  0.7%si,  0.0%st

Mem:   1036032k total,   478028k used,   558004k free,    52580k buffers

Swap:  2008104k total,        0k used,  2008104k free,   266932k cached
```

Not everything can be swapped. e.g. buffers in the ouput queue to be written are not swappable, the kernel cannot be swapped, there are other things too.

----------

## cgmd

NeddySeagoon wrote: *Quote:*   

> Watch memory and swap use in top

 

Thank you for that tip... I get:

```
Tasks:  53 total,   2 running,  51 sleeping,   0 stopped,   0 zombie

Cpu(s):  1.7% us,  5.0% sy,  0.0% ni, 72.3% id, 15.3% wa,  3.3% hi,  2.3% si

Mem:   1034072k total,  1020016k used,    14056k free,    13936k buffers

Swap:   987988k total,        0k used,   987988k free,   941664k cached

```

Unfortunately, that doesn't help with the ongoing problem that I raised in a different thread. It appears one of my gentoo machines is losing free memory, across my network, to the point of crashing. I can't find any evidence that swap is being utilized, and I'm trying to find a way to test swap function on that machine. I have 1gb of memory in that machine, and I can't believe it's being exhausted.

Do you know of any other way I could approach this problem?? I very much value your opinion!

Thanks!

----------

## Section_8

cgmd,

I'm not sure if this is any help - but if you just want force swap usage, set up a tmpfs partition and start filling it up - it should eventually expand into swap.

----------

## laffel

if you want to check if swap is used try vmstat. It will report the swap-in/swap-out operations

----------

