It looks like you're new here. If you want to get involved, click one of these buttons!Sign In Register
It looks like you're new here. If you want to get involved, click one of these buttons!
free -hyour results will be printed in two lines: "Mem", "Swap", which will indicates what is the exact amount of RAM and SWAP memory on server. The "Swap" line should only contain zeros.
fallocate -l 6G /swapfileYou can check if your SWAP memory was assigned with this command:
ls -lh /swapfileAt first, your SWAP may not be allocated due to permission issue and you might be seeing this message:
-rw-r--r-- 1 root root 6.0G Dec 5 14:32 /swapfile
chmod 600 /swapfileAfter the change you can check the file permissions again:
ls -lh /swapfileThe results should change as well, comparing to the previous above:
-rw------- 1 root root 6.0G Dec 5 14:36 /swapfile
free -hYour results will print two lines again, just this time, you will see a line "Swap" having a variable of 6 GB.
cp /etc/fstab /etc/fstab.oldOnce the backup is done, we have make the changes to the actual file:
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstabThere are few extra option for SWAP memory, which we would like to address as well
cat /proc/sys/vm/swappinessoption - vfs_cache_pressure, this option sets how often the information about file system is updated. By default it should be 100, but we would recommend using low, for example, value 50.
cat /proc/sys/vm/vfs_cache_pressureBoth of the additional options can be edited at the file /etc/sysctl.conf