Most Linux installations recommend including a swap partition in it. This may seem strange to Windows users who are used to running the entire operating system in one partition.
What does the swap partition do, Do you even need it, and how big should it be? These are all important questions that, with the right answers, can seriously improve system performance.
What the Linux Swap partition does
The swap partition acts as an overload condition for your RAM. If the RAM is completely full, all other applications will run the swap partition instead of RAM.
This may sound like an easy way to increase the amount of memory available to your computer without getting more RAM yourself, but this is not the case. RAM is ideal hardware for memory because it is very fast, unlike hard drives, which are relatively little slower.
Hard disk drive performance may have reduced the problem at their greatly improved speeds
How do semiconductor stations work?
, but even they do not match the RAM. This is also true newer NVMe SSDs
What is an M.2 SSD? Pros, cons and how to install it
. In either case, you don’t want to cause extra wear and tear on your solid-state drive.
A close analogy to the exchange partition is Windows page file
Troubleshoot low RAM or memory leaks in Windows
, although there are many technical differences between the two.
The Linux swap partition is not limited to overflow storage space. It can help your computer in other ways.
A swap partition can also help move some items from memory to your hard drive so that others have more space for more important items. This means that items that are rarely touched would move to the swap section.
The amount of threshold considered rare depends on the configurable “interchangeability” (yes, it is a term actually used). Higher interchangeability means that data is more likely to be transferred to the exchange partition. Lower turnover means that data is less likely to be transferred to the exchange partition.
The swap partition is used to target the contents of memory whenever you tell the system to hibernate. This means that without a swap partition, hibernation in Linux is impossible.
Using the Hibernation feature has become quite rare, so this may not be important to you.
Need a swap partition?
Does this mean that an exchange partition is necessary? Not at all! A Linux system can work great without a swap partition. We have already discussed the benefits of the exchange section. Why might you not want to get one?
When Swap partitions don’t help
Swap partitions have their low sides. They take up space on your hard drive that does not resize dynamically when not in use. Heavy replacement can also increase main station wear. In some cases, swap partitions don’t even help improve performance. Here is an example that a removable partition can actually be worse than without it.
Let’s say you’ve installed Linux on an old netbook with only 2GB of RAM and a 5400rpm hard drive. With just 2GB of memory, you can imagine filling up pretty quickly with a few open browser tabs. The swap section lets you keep them all open when the memory becomes full
How much RAM do you really need?
But then a bottleneck occurs due to the hard drive speed of 5400 rpm. Because the hard drive is so slow and the system constantly wants to use the swap partition, the online book becomes very slow. The machine is slow enough to be idle unless you close anything to free up memory.
The set interchangeability does not guarantee that everyone in the swap partition will move back when space becomes free in RAM. Instead, a lot can be left in the swap partition, causing the netbook to remain slow. So you have to leave the computer to restart to start from a clean strip, which takes a while because the system has to remove everything from the replacement partition before shutting down.
What happens when you don’t have an exchange
If you decide to give up the exchange part, know the risks. When your computer needs more RAM than is available, the interface may lock. You may be forced to shut down your computer and lose all the data you are working on.
In such cases, you may want to have a swap partition around you, even if it is used only once. This depends on whether you are often running out of storage space. Do you find that you have 4GB less storage space available because you own that amount to change?
Here are some suggestions on when you want to get a replacement partition and how big it will be.
- If you want to be able to hibernate your computer, then you should have a swap partition. The size of this partition should be the size of the installed memory and an additional 10-25% to make room for all items that have already been moved to the swap partition.
- I just want small increase in performance (and you have at least a 7200 rpm hard drive)? Then you can add a swap partition if you want. This size can be anything, but I wouldn’t make it bigger than what you would do if you created a swap partition to hibernate.
- If you sometimes use heavy applications For those who require extra RAM, a swap partition can be a peace of mind. In this case, you do not need to change the partition to be the same size as your RAM.
- If you have a 5400 rpm hard drive, then you may not want to create a swap partition simply because a bottleneck can make your computer worse. But if you absolutely want to change the option, you can still create a partition with the same resizing instructions above. Just remember to change the interchangeability value to something much lower.
Like many aspects of the Linux desktop, the changeability of your computer is stored in a text file. To find this file, go to / Proc / sys / vm.
When you open the file, you will see a single number indicating your current change. You can edit this file with any text editor of your choice, as long as you have administrator rights.
To do this with Ubuntu and Fedora’s default GNOME text editor, try:
sudo gedit /proc/sys/vm/swappiness
There is also a command line option that works regardless of the text editor installed. Just type:
sudo sysctl vm.swappiness=20
You can enter any number between 0 and 100. The value indicates when you want Linux to begin actively moving processes from memory to the swap partition. So, for example, a value of 20 means that processes will shift when memory usage reaches 80%; the default switch value in Ubuntu 60 means that processes are moved when memory usage reaches 40%.
You can verify that the change was successful by reopening that text file. Not surprisingly, the terminal offers a faster way to check your turnover. Just type this command:
Does your computer feel faster?
Replacement partitions can make a big difference in system performance – sometimes for the better and sometimes for the worse. Now that you know what an exchange partition is, hopefully you will be better able to make the decision that is right for your situation.
But before reallocating a partition, know that memory management has more than the amount of RAM you have and the size of the Linux swap partition. Take a moment to learn how Linux manages RAM
Is Linux eating up your RAM? How to manage your memory