Hello guys today in this article we are going to learn how to increase swap memory in linux after installation. As well we know swap memory is play very important roll in linux operating system Actually swap memory is use some space of heard disk space as a ram , but its a very important think that how space we create for swap memory. All Linux Administrator and engineers always recommend we need configure swap area just double to physical memory. For example we have 4 GB physical memory then we need to configure 8 GB swap area or partition during Linux installation. so let we now we are focus on our article heading. for example let’s assume we have 8 GB Linux Server or Desktop operating system we realized that our system need to increase physical memory so here we increase 8 GB Physical memory so here everything is normal our system is work perfectly and good but according to Linux expert rules we have to need just dual swap are to physical memory. so in this case we have two option 1st we will create extra swap partition or if we don’t have heard disk space we can also use file as a swap space its a very simple process so without wasting time we are learn how its possible.
(notice- in this tutorial all commands fire by root account you can also fire through other user you just use sudo )
1 we will create directory where we hold swap file (its not necessary you can hold anywhere in your system )
mkdir -v /var/cache/swap
2 then we will go in this directory through this commands
3 next here we will create any Empty file according to our Requirement using dd Command here my requirement is 8 GB swap area so look below Commands
dd if=/dev/zero of=swapfile bs=1K count=8M
4 then next we provide 600 permission
chmod 600 swapfile
5 next we will Convert newly created file into a swap space file.
6 then here we enable swap file and look this is work ?
sudo swapon swapfile
top -bn1 | grep -i swap
7 then we next we will stop swap file and entry in main swap file
8 then we add entry this file is /etc/fstab
echo "/var/cache/swap/swapfile none swap sw 0 0" | tee -a /etc/fstab
9 then we on swapfile using blow Commands
if you have any problem in this tutorial please comments here i will solve your problem
Writer- Vishnu Sharma (Linux and Network system Administrator)