Loading...
X

How to check Swap file usage in Linux

The swap file will be used when the physical memory runs out. In order to check the operation of the Swap file, you need to artificially use up all the RAM. You don’t need to run many applications and open dozens of tabs in your web browser to do this, instead you can use stress testing tools like stress-ng.

See also:

Install stress-ng

To install stress-ng on Debian, Kali Linux, Linux Mint, Ubuntu and their derivatives, run the command:

sudo apt install stress-ng

To install stress-ng on Arch Linux, Manjaro, BlackArch and their derivatives, install pikaur and then run the command:

pikaur -S stress-ng

How to fill 110% of the free memory

An example of a command that will consume 10% more RAM than system has free RAM:

stress-ng --vm-bytes $(awk '/MemAvailable/{printf "%d\n", $2 * 1.1;}' < /proc/meminfo)k --vm-keep -m 1

After that, watch the memory consumption – you will see how the Swap file starts to be used.

On the command line, Swap file usage can be checked with the command:

swapon --show

Leave Your Observation

Your email address will not be published.