How you can do Managing and monitoring swap space on Linux

How you can do Managing and monitoring swap space on Linux

This tutorial is about the How you can do Managing and monitoring swap space on Linux. We will try our best so that you understand this guide. I hope you like this blog How you can do Managing and monitoring swap space on Linux. If your answer is yes then please do share after reading this.


Check How you can do Managing and monitoring swap space on Linux

Swap space can play an important role in system performance. Learn how to determine how much swap space is available on your system and how much is being used.

Most of us don’t think often about swap space unless we run into a problem in our systems that suggests we don’t have enough of it. Still, viewing and measuring swap space suitability on a system isn’t too complicated, and knowing what’s normal for your system can help you detect when something is wrong. So, let’s take a look at some commands that can help you search your swap space. But first, let’s go over some fundamentals.

What is swap space and how is it used

Swap space is disk space that acts as an extension of memory. It is used when the physical memory (RAM) of the system is full and the system requires more memory resources. It is called “swap” because the system will move some inactive pages in memory to swap space so that it can accommodate more data in RAM. In other words, it provides a way to free up RAM on a busy system.

Programs and data use RAM because that is the only way the system can process it. In fact, when a system boots, it moves programs like the kernel and systemd to RAM to start.

Swap space can be configured as its own disk partition or configured as a file. These days, most Linux installations create a partition during installation, and this is optimal. However, you can set up a swap file and use it for your swap space.

With inadequate swap space, you may run into a problem called “thrashing” in which programs and data move between RAM and swap space so frequently that the system runs very slowly.

Together, RAM and swap are called “virtual memory.”

How much swap do you need?

The recommendation for swap space used to be double your RAM, but that was when systems didn’t have as much RAM as they generally do today. These recommendations for Ubuntu should probably work fine for other distributions as well:

The distinction between swap and hibernating swap is important. A hibernating system saves the system state immediately to the hard drive and shuts down. When you wake it up (for example, by lifting the “lid” on a laptop), all the programs you were running revert to the state they were in when the system went into hibernation. Therefore, more swap space is recommended. Not all systems hibernate.

To determine if your system can hibernate, run this command:

$ what hibernation pm

/ usr / sbin / pm-hibernate

If you get the answer shown above, your system is ready for hibernation. You can test it by running this command:

$ sudo pm-hibernate

How can you see the amount of swap space on your Linux system?

You can use the swapon –show command to see the swap space on your system.

$ swapon –show

NAME TYPE SIZE USED PRIO

/ dev / zram0 partition 5.8G 3.3M 100 Another useful command is the free command that shows both swap space and memory usage. With -m, the results are displayed in MB instead of KB.

The sar command can report swap space usage.

When you need it and you don’t need any more swap space

If your system has a lot of memory, you may never need to use swap space. But it is almost always a good idea to have it available. Disk space is relatively cheap compared to memory, and you never know when some process might increase the load. On the other hand, if your swap space is heavily used most of the time, perhaps you should consider adding more RAM to the system, as there is a performance cost associated with its use.

Final words: How you can do Managing and monitoring swap space on Linux

I hope you understand this article How you can do Managing and monitoring swap space on Linux, if your answer is no then you can ask anything via contact forum section related to this article. And if your answer is yes then please share this article with your family and friends.

Bollyinside - Get Daily Blogs From Experts
Logo