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 4GB swap partition on /dev/sda2
and a 1GB swap file, /swapfile
. The Priority
column shows
that the OS writes 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
sudo free | grep Swap
Swap: 5128752 388 5128364