How to free up Swap memory in Ubunt

Everyone likes to download things online, that’s something we fully specialize in in the 21st century. But most never take into account how much space the computer has left until it is too late, so today you will learn to increase and free up Swap memory on Ubuntu Linux.

And it is that Linux not only offers advantages for its free software , but also gives the opportunity to manage memory (real and virtual), so that you can download whatever you want without overdoing it. Allowing all its users to perform functions such as cleaning the storage space whenever they want and even allowing you to format or format an SD card .

Increase and free up Swap memory in Ubuntu Linux

The first thing you will learn is to increase the swap memory space . For those who do not know what this memory is, they should know that it is basically the virtual memory space, this uses the space included in the storage unit unlike the real one.

When the latter is finished or reaches its limit, the computer copies part of the content in virtual memory, so that it can continue to function normally (this process is carried out by all operating systems, since you can configure and increase virtual memory in Windows if you wish too).

In order to increase and free up the Swap memory in Ubuntu Linux there are many methods, but the easiest (when it comes to increasing it) is adding a swap file, to achieve this you have to do the following:

First determine the size of the new swap file to be created. Choose the one you want and then multiply it by 1024, for example if the size of the block is 64MB it would be 65536 .

In a Shell command prompt such as root, place the command dd if = / dev / zero of = / swapfile bs = 1024 count = 65536 where count will be the size of the swap block.

Then configure the swap file with the following command mkswap / swapfile, once done you must use another command that would be swapon / swapfile, the latter is used to activate the file at that time but not automatically when starting the computer.

If instead what you want is to activate it when it starts, edit / etc / fstab so that it can include / swapfile swap swap defaults 0 0. This will make the new swap file that you have placed (this is the most recommended).

Free up space

With the above, it is already clear the first part of how to increase and free the Swap memory in Ubuntu Linux , the second part of logic is to learn to free space.

This can also be done with commands from a terminal, it will even allow you to see how much memory is being used before cleaning it.

To do the latter you must go to the terminal and place the following command: cat / proc / swaps, which will return a message with the memory size and the space that is in use, in addition to indicating where the partition is located.

Once you have read everything, execute the command: swapoff -a && swapon –a, this will make the space that is in use go down to 0, that is, the swap memory will have been cleaned.

With this you already know what is necessary to increase and free the Swap memory in Ubuntu Linux. It is recommended that you ask for help if you are not an expert in this type of topic, since any error can be expensive for your team (in addition to that there are many more methods which are more complicated).

 

In conclusion, it should be noted how good it is to use an operating system like Linux, which gives you the freedom to edit the parts you want on your PC through commands. For example, you can update the Ubuntu system to the latest version from the terminal, and even repair broken or incorrectly installed packages , so learning about this should be your next step.

 

Leave a Comment