18.2.1 Viewing Swap Space Usage

To view a system's usage of swap space, examine the contents of /proc/swaps:

# cat /proc/swaps
Filename                Type        Size      Used   Priority
/dev/sda2               partition   4128760   388    -1
/swapfile               file        999992    0      -2

In this example, the system is using both a 4-gigabyte swap partition on /dev/sda2 and a one-gigabyte swap file, /swapfile. The Priority column shows that the system preferentially swaps to the swap partition rather than to the swap file.

You can also view /proc/meminfo or use utilities such as free, top, and vmstat to view swap space usage, for example:

# grep Swap /proc/meminfo
SwapCached:          248 kB
SwapTotal:       5128752 kB
SwapFree:        5128364 kB
# free | grep Swap
Swap:      5128752        388    5128364