--------memory---------- ---swap-- -----io------ -system-- -----cpu------ r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 0 5242880 12345 678901 0 0 0 0 123 456 2 1 97 0 0
Key swap-related columns:
- `swpd`: used swap in kilobytes (here 0 — swap is not in use).
- `si` (swap in): amount of memory moved from swap to RAM per second (kilobytes). Non-zero values indicate the system is reading data from swap, which slows down performance.
- `so` (swap out): amount of memory moved from RAM to swap per second (kilobytes). High values indicate active writing to swap.
Consistently non-zero values in `si` and `so` signal that the system is actively using swap, which can be a sign of insufficient RAM.
::in-article-ad
::
## Checking the Result
After completing the steps, you should have a clear picture of swap usage:
- The `free -h` command showed overall values: if `used` in the Swap line is non-zero, swap is active.
- `/proc/swaps` identified all swap devices and their status. If the file is empty, swap is not configured.
- `top` allowed real-time monitoring of swap and identification of processes using it (if any).
- `vmstat` provided statistics on swap in/out operations, helping assess the load.
If swap is not in use (all metrics are zero) but you expect it to be present, check if swap is activated via `swapon --show` or in `/etc/fstab`. If swap is missing, create it by following the swap file setup guide.
## Possible Issues
### Swap does not appear or shows zero values
If `free` and `/proc/swaps` show zero swap, swap is likely not configured. Solution:
1. Check for a swap partition using `lsblk` or `fdisk -l`.
2. If no partition exists, create a swap file: `sudo fallocate -l 2G /swapfile`, then `chmod 600 /swapfile`, `mkswap /swapfile`, `swapon /swapfile`.
3. Add an entry to `/etc/fstab` for permanent mounting: `/swapfile none swap sw 0 0`.
### "Permission denied" error when reading /proc/swaps
Usually `/proc/swaps` is readable by everyone. If an error occurs, the system may have hardened security settings (e.g., SELinux in enforcing mode). Try running with `sudo`, but this is rarely required for diagnostics. Check permissions: `ls -l /proc/swaps` (should be `-r--r--r--`).
### top command does not show the swap column
Ensure you have correctly added the `SWAP` field in `top` settings. In some versions (e.g., `htop`), swap is displayed by default. Also, remember the swap column may be empty if no process uses swap directly (swap is managed globally by the kernel, not per-process).
### High swap usage and low performance
If `vmstat` shows constant non-zero `si` and `so`, and the system is sluggish:
1. Increase RAM if possible.
2. Optimize applications: find memory-intensive processes via `top` (sort by `%MEM`).
3. Adjust the `vm.swappiness` parameter (range 0 to 100), which controls swap usage aggressiveness. Check the current value: `cat /proc/sys/vm/swappiness`. Recommended values: 10-20 for servers, 60 for desktops. Change temporarily: `sudo sysctl vm.swappiness=10`, or permanently — add `vm.swappiness=10` to `/etc/sysctl.conf`.
4. Consider adding an additional swap file on a fast SSD if swap is necessary.
F.A.Q.
What is swap memory and why is it needed in Linux?
What level of swap usage is considered normal?
Can I disable swap if I have a lot of RAM?
How to increase swap space if it's insufficient?
Hints
Use the free command
Check details in /proc/swaps
Monitor real-time usage with top
Use vmstat for swap activity statistics