Linux – how to check what is in swap

linuxswap

On my system i have some amount of swap used:

undefine@uml:~$ free
             total       used       free     shared    buffers     cached
Mem:      16109684   15848264     261420     633496      48668    6096984
-/+ buffers/cache:    9702612    6407072
Swap:     15622140        604   15621536

How to check what is in swap?

I try to check it via processes, but for every pid on system VmSwap is 0:

undefine@uml:~$ awk '/VmSwap/ {print $2}' /proc/*/status |uniq
0

What else can be in swap?
I thought about tmpfs – but i reread all files on tmpfs-es – and it doesn't flush swap size.


Best Answer

smem is the standard tool for this. It's clean and simple.

On a Debian based system, install it via package manager:

 sudo apt-get install smem

A sample (clipped) output from my system:

$ smem -s swap -t -k -n
  PID User     Command                         Swap      USS      PSS      RSS 
  831 1000     /bin/bash                          0     3.8M     3.8M     5.5M 
 3931 1000     bash /usr/bin/sage -c noteb   276.0K     4.0K    20.0K     1.2M 
17201 1000     /usr/bin/dbus-launch --exit   284.0K     4.0K     8.0K   500.0K 
17282 1000     /usr/bin/mate-settings-daem   372.0K    11.0M    11.7M    21.8M 
17284 1000     marco                         432.0K    16.7M    18.1M    29.5M 
17053 1000     mate-session                  952.0K     3.3M     3.5M     9.2M 
 3972 1000     python /usr/lib/sagemath/sr     2.7M   101.8M   102.1M   104.3M 
-------------------------------------------------------------------------------
  141 1                                        5.2M     3.9G     4.0G     4.5G 
Related Question