Automatic (dynamic) Virtual Swap Space Creator for Ubuntu Linux – Swapspace!

In extremely simple terms, “Swap space” is an allocated space in your HDD that’s being used as a temporary location for storing application data, prior to sending them to your RAM (also used to store the same data when removing from RAM as well).

It’s a place where most of your frequently used data is stored (temporarily) and it lets the operating system to access them faster thus minimizes delays while re-opening programs. Because programs and their can be scattered all over your HDD (though never operating systems try to minimize it) and searching for them can really slow down the process.

Now GNU/Linux recommends creating a separate partition for the “Swap space”, for both security and performance enhancements. But I don’t like this approach at all because it complicates things too much. For instance if you later wanted to expand the Swap space then resizing a partition is not that easy plus according to my experience, by using a separate partition doesn’t really increase the performance either.

“Swapspace” manual …

So the best solution is to create a virtual swap file because you can easily resize it later with ease and you won’t have any performance penalties for doing that. Or, there is another extremely handy utility called “Swapspace” and what it does is simple, it creates a ‘dynamic swap file’ which according to the requirements of the operating system changes its size!.

So now you can even forget about creating a virtual swap file and just install “SwapSpace” and it’ll automatically create one for you and will even resize it when necessary.

In the screenshot: It created a new Swap file (which was 0MB before) of 66.5MB …

You can also use ‘Swapspace’ side by side with a manually created swap file and when the manually one gets filled ‘Swapspace’ will automatically create another one for the OS so the OS will always have a swap space and it enhances the stability.

Another useful thing about “SwapSpace” is that, whenever it can, it’ll reduce the size of the SwapSpace and “release” those bytes into user file system and according to the developers this reduction helps to increase the swap file’s performance as well (plus your “precious” HDD space is not wasted too).

It’s pretty much automatic and “smart’  too. In their own words …

” it is less dependent on limits that the kernel may impose on the total number of swapfiles, while reducing the need for manual configuration. If the daemon finds that more and more swap files are needed, it will start creating larger ones to anticipate demand …”

If you want to give it a try, then you can install SwapSpace in Ubuntu 12.04 Precise Pangolin, 11.10 Oneiric Ocelot, 11.04 Natty Narwhal, 10.10 and 10.04 by typing the below command in your Terminal window.

sudo apt-get install swapspace

Few of its main features …

*. Supports up to 25 individual swap file creations.

*. Singe Swap File can be as big as 5.6GB.

*. Supports 44GB of maximum Swap Space (although they say going even further is possible but can lead into an unstable system).

*. The core program needs very little of your RAM (about 44KB! in my PC).

The little Devil 😉 …

*. It comes pre-optimized.

*. But of course you can adjust its settings (minimum swap file sizes, when to reduce the size etc). For that please refer to its manual by using the below command in your Terminal window.

man swapspace

However because of its nature, it’s not recommended to be used in systems where large on-the-fly (live) Swap file creation is highly demanded. This is because creating a large file takes time and slows down the OS. In that case you should either use a dedicated Swap Partition or stick with a non-dynamic virtual Swap file.

That being said, they say that it’s extremely reliable and in their own words …

“Robustness and user-friendliness are the first priorities in developing this program. For example, all alternatives we looked at perversely needed to allocate multiple chunks of memory in dealing with low-memory situations; allocation failure would typically crash these programs. It turned out that none of these allocations were really necessary, and Swapspace manages to avoid them categorically. This kills two birds with one stone when it comes to reliability: …”

If you encounter any issues and it made your OS unstable (worked quite fine for me) then you can safely remove it by using the below command in Ubuntu.

sudo apt-get purge swapspace

If interested you can get more information about it from this Official SwapSpace home page.

An RHCE, 'Linux' user with 14+ years of experience. Extreme lover of Linux and FOSS. He is passionate to test every Linux distribution & compare with the previous release to write in-depth articles to help the FOSS community.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.