How to find swap space and usage in Solaris - UNIX command

Swap space in Solaris or any UNIX host is a vital disk space that is used for the swapping process from physical memory (RAM)  to disk. Virtual memory allowed a process to run even if physical memory gets full by using swap space (which is located on your hard disk) to swap out memory pages which are not currently in use. In this UNIX command tutorial, we will see some Solaris commands to find configured and current usage of swap space. Remember if your machine runs out of swap space then you can not start a new process and also an old process which will try to expand themselves will likely to fail. 

Another interesting point about swap space is that every process reserved swap space, equivalent to its physical memory requirement so that it can swap out completely when required. Which means current usage of swap space denotes total memory used by all process at that time. 

This UNIX command tutorial is next in our series of articles e.g. UNIX command to find links , grep command examples in UNIX and  10 most popular Linux Interview questions.

Solaris command to find Swap memory

Here is an example of the Solaris “swap” command to find how much swap memory is left on the server. Remember if your host runs out of swap you can not start a new process, so be careful with how much swap space you set, and your process doesn’t eat all swap memory available in Solaris host.

And, if you need a refresher about virtual memory in Linux, here is a nice diagram by Julia Evans:

Solaris command to find swap memory in host

Here is the output of swap command with both swap -l and swap -s option to see how much swap space is left in the machine:

test ~ $ swap -l
swapfile             dev  swaplo blocks   free
/dev/sd/dsk/swap 181,2       8 134217720 134217720

test ~ $ swap -s
total: 22189856k bytes allocated + 8594616k reserved = 30784472k used, 80563112k available

That’s all on how to find swap space usage in Solaris or How much swap space is used currently, how much swap space is available now etc. There are a couple of more Solaris commands which display information about swap space, e.g. vminfo and sar.  

You can further check The Linux Command Line: A Complete Introduction to learning more about useful commands like viminfo and sar

How to find swap space in Solaris - command

You can also look on the internet on How to use them to find swap space and then cross check with the output of swap command. By the way, I always prefer swap command to find swap usage in the Solaris operating system.

Other UNIX and Linux Command Tutorials for Beginners
Linux Command Line Basics
Linux Command Line Interface (CLI) Fundamentals
Learn Linux in 5 Days and Level Up Your Career

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.