Linux Commands to Check Swap Size and Utilization

Use these read-only commands to check configured swap capacity, current usage and paging activity on Linux. Other UNIX systems, such as Solaris and AIX, have different commands.

Check configured swap devices

swapon --show
cat /proc/swaps

On older Linux systems, swapon -s displays a similar summary. Check each swap device or file, its size, current usage and priority.

Check overall memory and swap usage

free -h
grep -E '^(SwapTotal|SwapFree|SwapCached):' /proc/meminfo

The difference between SwapTotal and SwapFree is the amount of swap allocated. SwapCached is not the same as swap currently being written.

Check active paging

vmstat 1 5
top

In vmstat, review the si and so columns for swap-in and swap-out activity across successive samples. Existing swap usage alone does not establish current memory pressure. Correlate sustained paging with MemAvailable, application memory and disk I/O before taking corrective action.

Reference

Linux manual: swapon(8)

You May Also Like

Leave a Reply?