3

When looking vmstat, this is what I got:

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 2872 0 0 0 0 8 17 0 14 3 1 94 2 0


the cache is 0. I have no idea how much the whole swap I have.

But when not enough RAM (256 MB), the swap will be used and look like below:

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
3 1 2468 0 0 0 0 0 8 17 0 16 3 1 94 2 0

5 Answers5

2

Assuming this is on Linux - free -m will show you how much memory/swap you have in MB. Or cat /proc/meminfo

James
  • 7,553
  • 2
  • 24
  • 33
2

To see information about swap files currently in use on Linux:

cat /proc/swaps

or refer to swap information in meminfo for less detail:

cat /proc/meminfo | grep Swap

Kl4m
  • 361
  • 2
  • 6
1

One of the header lines in top will be Swap info, and it's very clearly broken down.

This also has the advantage of working on any platform where top is installed (Every Linux/BSD I know of. Most Solaris, AIX & HP-UX machines (if it didn't come with the system some admin usually got around to installing it)).

voretaq7
  • 79,345
  • 17
  • 128
  • 213
  • (I got from top) Swap: 0k total, 0k used, 0k free, 0k cached –  Jan 29 '10 at 18:18
  • 2
    Sounds like you don't have any swap configured (or it's not attached/enabled) -- that's a bit unusual but not impossible. Are there any lines in /etc/fstab with type "swap"? If so try "swapon -a" (as root) & the system will try to enable them. – voretaq7 Jan 29 '10 at 20:15
  • 1
    True that top is almost everywhere, but I was surprised to find it missing on Tru64. Not that anyone cares about that any more... – Mei Dec 24 '10 at 21:23
  • `htop` is a more friendly version. :) – EricR Nov 04 '11 at 17:42
  • @EricR - True, but `htop` isn't everywhere (for that matter neither is `top`, but you know it will be there on the systems I listed). I suppose the *truly* portable alternative is `swapinfo`, but that requires you to do your own math for totals if you have more than one swap partition - `top` does it for you :-) – voretaq7 Nov 04 '11 at 18:22
0

Many systems have some command to detail this information outright: the commands are usually one of: swap or swapinfo or swapon (with appropriate option). Look up the man pages for these commands to find the specific information.

Mei
  • 4,560
  • 8
  • 44
  • 53
0

Execute

mkswap /path/to/dev

Then run

swapon -a
quanta
  • 50,327
  • 19
  • 152
  • 213
Greg C
  • 9
  • 1