You need to believe about storage critically if you belong to IT or doing work as a laptop or computer scientist. In that circumstance, bundles of software program packages are required to function on.
There could be several issues similar to storage potential in Linux techniques to operate applications you will need adequate RAM if not, the software will crash.
The Swap in the Linux system will help when RAM is about to exhaust. Although operating with multiple apps, if RAM fills up and there is no space to function, the system begins employing the secondary storage where by Swap is located.
The accessibility time of swap house is less than the procedure bodily memory. When operating applications stopped doing the job for the reason that of insufficient area in RAM, inactive pages are forced to move in the direction of swap space. If you’re working with the video editor tools or memory-consuming applications, it would be very good to use swap area.
Now, the dilemma may possibly crop up in your brain that how substantially swap house is required for a certain RAM. Do not stress about it a guideline table is stated in this article:
|Process RAM||Recommended Swap Space|
|Significantly less than 2 GB||2 x RAM|
|2 GB – 8 GB||1 x RAM|
|8 GB – 64 GB||.5 x RAM|
|More than 64 GB||Rely on workload|
For Centos and Redhat, the advice would be:
|Process RAM||Recommended Swap Place|
|Fewer than 2 GB||2 x RAM|
|2 GB – 8 GB||1 x RAM|
|8 GB – 64 GB||Min 4 GB|
|A lot more than 64 GB||Min 4 GB|
And for the Ubuntu method, the recommendation is by some means minimal improved:
|Method RAM||Recommended Swap House|
|Fewer than 1 GB||Swap >= RAM < 2xRAM|
|Greater than 1 GB||Swap>= sq. root of RAM (but) Swap < 2xRAM|
How to Increase Swap Space In Linux
To increase swap space in the Linux system, we first need to check if swap space is enabled.
To check it, type in the terminal:
If you didn’t get any output, it means your system doesn’t have swap space available at the moment.
There is another way to check the memory and swap space information i-e using the “free -h” command.
In my case, RAM is less than 2 GB, so the allocated swap space memory would be around 1 GB (as we have mentioned in the recommended cases above).
(Note that all of the below-mentioned commands required sudo privileges to make changes).
In the terminal, write down the command to increase swap space:
$ sudo dd if=/dev/zero of=/swap_file bs=1GB count=1
You can set the value of bs and count according to the requirement.
Keep in mind:
bs sets of blocksize
count number of blocks
Now, set the permission access for the users as 600 so users couldn’t be able to read important data from the swap_file:
$ sudo chmod 600 /swap_file
To enable the swap area on the file “swap_file,” use the “mkswap” command utility:
The next step is to enable the swap file “swap_file” using the command:
Run the “free -h” command to check if swap space has increased:
So, when we checked before, the swap space was 923 MB. And now it has been updated to 1.8 GB.
While using the system, every processor requires memory to run tons of packages and tools. There is always allocated memory in the system, i-e, RAM, but sometimes it is not enough for multiple applications to run simultaneously.
In a Linux system, swap space is located in the system as secondary memory. When RAM is exhausted, swap space helps to run applications in it.
We allocate swap size during the installation process of Linux distribution. But it can be changed later according to requirement.
The guide has shown how we can increase swap space in Linux Distributions.