The exchange area (swap) is the part of the hard disk space that is used as a complement to RAM memory with limited space. This gives the operating system the feeling of having more RAM than it actually does. It is a dedicated partition on the hard drive normally created during the installation of the operating system. It is good if you create a swap area twice the size of the RAM.
As we know, there are often many Windows users who migrate to Linux. There are users who have never had contact with any GNU Linux distribution, and in the installation process they do not know both how to partition in a way that the system has a correct performance, as well as what the unit is for swap. I remember that the first time I saw it, I didn't even know what it was for, and after they explained it to me I thought it was unnecessary to create it because I thought my PC with 4GB of RAM was enough, and I didn't know the advantages it provides.
Some users may not create it at the beginning of the installation process, so by following this tutorial they would have the opportunity to create a drive Swapat a specific time according to your needs, and even if it does not meet your needs later, you can modify it.
It is explained below how to create a unit swap from a file, which will be on the hard drive.
Memory capacity or existence is checked swap. In my case it is already assigned, because I created it using this method. The following command is executed as user root:
du -hsc swap
We already have the file ready. Now we proceed to create the unit swap, with the following command:
Where "swap" is the file created a moment ago. A "UUID" will be generated for which it will take it as a disk.
Drive is activated swap with the following command:
Then we check that the unit is already assigned swap:
At this point, you can check the results of the previous actions through the system monitor.
Now we go on to configure so that the unit can be used swap when the operating system restarts, through the following command:
echo “/swap /swap swap defaults 0 0” >> /etc/fstab
This step can be done either with the "UUID" or with the file name. I did it with the name of the file because, each identifier of the units, of course, is unique. In case the file swap does not meet the user's need, you can delete it and create a new one with greater capacity and the same name. Given the settings, only the unit would have to be activated swap created. And all the settings are kept, since the file name is used, and not the “UUID”. This recommendation is to make the job easier. We verify through the command:
where the following is displayed on the last line:
After the previous step is done, the system restarts. Once logged in, you can check the allocated swap memory in the system monitor or, through the command:
And that's all for this tutorial, I hope it will be helpful to you and if you have questions or comments, do not hesitate to expose them here. Until next time.