83.1 Swap File


If you are running out of swap memory you can add more by creating a swap file on your storage device (hdd or ssd). Swapping to a file is a little less efficient than swapping to a dedicated swap partition as the kernel needs to access the new swap file through the file system. But since this swap file is only called upon when you’ve run out of RAM and then swap memory on a dedicated partition, the additional performance hit is not much compared to that of swapping itself.

Have a look at what memory you have available using free:

$ free
               total        used        free      shared  buff/cache   available
Mem:        16028508     3987252     3494292     1043004     8546964    10656712
Swap:        1003516      467112      536404

Here we have 16GB memory and 1GB of swap of which something like 467MB is being used.

The swapon command can also show the swap memory utilisation:

$ swapon --show
/dev/dm-2 partition 980M 456.2M   -2

Here we have almost 1GB of swap of which 456MB is being used.

Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0