Swap memory is like RAM, in Linux is used when the amount of RAM is full. If the system needs more memory resources and the RAM is full then, other inactive pages in RAM are moved to the swap memory. While swap space can help machines with a small amount of RAM. Swap memory creates by some part of Hard drive.
You need to install htop monitoring features for check memory uses.
Following commands will create 4 GB of swap memory:
- sudo swapon –show
- sudo fallocate -l 4G /swapfile
- sudo chmod 600 /swapfile
- sudo mkswap /swapfile
- sudo swapon /swapfile
- sudo nano /etc/fstab (add this line /swapfile swap swap defaults 0 0)
- sudo swapon –show
- htop