1828216 Members
2214 Online
109975 Solutions
New Discussion

get SWAP Space

 
SOLVED
Go to solution
Tonatiuh
Super Advisor

get SWAP Space

Red Hat Enterprise Linux 3.0

How can I get the swap space of my system?

Thanks!
9 REPLIES 9
Tonatiuh
Super Advisor

Re: get SWAP Space

I mean, how can I know the swap space of my server?
HGN
Honored Contributor
Solution

Re: get SWAP Space

Hi

You can use the command free to check the swap
To create swap you need to mkswap and to activate it you need to use swapon.

Rgds

HGN
Alex Lavrov.
Honored Contributor

Re: get SWAP Space

Also you can see how many memory is swapped from/in disk with "vmstat".
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Tonatiuh
Super Advisor

Re: get SWAP Space

I am really newbie. Can you write the syntax of this commands to get the info requiered?
Alex Lavrov.
Honored Contributor

Re: get SWAP Space

It's just free ...

You can do "free -m" to view the amounts in megabytes, at the bottom you'll see the swapsize.

Also, you can look into /proc/meminfo, there at the bottom, you'll see the swap size too.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Stuart Browne
Honored Contributor

Re: get SWAP Space

If you just want to 'see' how much is available, you can use the 'top' command to get running info.

If you wan't to script it in the future, it's easiest to grab it directly from '/proc/meminfo', using something like 'grep ^Swap: /proc/meminfo'. These are the same numbers as shown in the 'top' output. It shows the number of 'bytes' allocated as swap, how many are in use, as well as how many are currently free.

To get a running idea of how swap is being used, you can use something like 'vmstat -ban 1', which takes a sample every second, and shows swap-in, and swap-out (si/so).

If you want general overview over a longer period of time, install the 'sysstat' RPM and use 'sar -r' (and it's variants).
One long-haired git at your service...
Gopi Sekar
Honored Contributor

Re: get SWAP Space


if you want to know available and used swap and RAM memory information run, free -m

it will give information in Megabytes. if you want to continuously watch for system memory, cpu and process related information then use top command.

Regards,
Gopi
Never Never Never Giveup
Ross Minkov
Esteemed Contributor

Re: get SWAP Space


/usr/bin/free | /bin/grep Swap: | /bin/awk '{printf "Swap: %5d MB\n",$2/1024}'
Mike Jagdis
Advisor

Re: get SWAP Space

And finally...

If you want it by swap partition/file rather than all totalled up:

cat /proc/swaps

Mike