If you have been installing Linux for years, you will probably do the procedure mechanically. Some things you keep doing may not be right.
For example, the size you think the swap partition should have
Table of Contents
What does Linux use the swap or swap partition for?
The data and the programs that are being executed are stored in the so-called Random Access Memory or Ram. What is stored in RAM memory is lost when you turn off the computer.
In the old days RAM was expensive. This limited the number of programs that could be run simultaneously and their power. The solution was to use a disk space to free up data that was not necessary at the moment.
We call a swap partition a area of the hard drive that the operating system uses for temporary storage. Used when there is not enough space in RAM to save the data of the active application.
Access to information written to the swap partition will be significantly slower than access to information stored in RAM. Thus, the Linux distribution that we are using will prefer use swap partition for older data.
Criteria to know if we need to create a swap partition.
On modern computers, a Linux distribution with normal use can work without problems by not setting a swap partition. But there are times when having it is essential and is always recommended.
It is absolutely necessary to create a swap partition andIn these cases:
- If our team has 2GB or less of RAM. Although there are hardly any desktops or notebooks left with this amount of RAM, it is common in computers originally designed to work with the cloud.
- When we use memory-intensive applications RAM like video editors.
- If we want to enable hibernation mode on our computer.
When you have enough RAM memory (More than 8 or 16 GB depending on the type of applications you use) it is convenient to assign a percentage of the disk to the swap partition. This will help prevent a malfunctioning program from consuming more memory than necessary and locking up the system.
This is not as weird as it sounds.
Two years ago GNOME 3.26 users reported that memory consumption increased exponentially when switching between windows or accessing the menu. Although the subject is corrected, it does not hurt to be forewarned.
Of course the size of the hard drive you have will be a factor to consider. If you installed your Linux distribution on a 16GB pendrive, you won't have many options.
Ways to determine the proper size of the swap partition.
As you could see if you installed different Linux distributions using the automatic installation mode, there is no uniform criterion when determining how much disk space to allocate to the swap partition.
- If the RAM memory is equal to or less than 2GB e is assignedl double the disk space.
- In case the RAM memory is greater than 2 GB and less than 5 GB slet's get 2 gb to RAM.
- When the RAM that we have is greater than 5 GB we allocate 20% of the disk space.
- In order to use hibernate mode without problems, the size of the swap partition must be equal to the size of the RAM plus the square root of the size of the RAM.
Of course, there is no combination of hardware and software that is the same as another. It is best to try different sizes of disk space to find the one that works best with our RAM and applications.
It is possible that due to lack of space or some other reason, a physical space on the hard disk cannot be allocated as a swap area.
In that case you can create a file and configure it as swap. Once this is done, it will fulfill exactly the same function of storing unnecessary data that does not have a place in RAM.