How to add additional swap area in SuSe/openSUSE

How to add additional swap area in SuSe/openSUSE

swap space is a dedicated device or a file in one of the mounted file systems to which the system swaps pages of information from the physical memory onto these areas to allow more current application use the physical memory when the physical memory is running out of space.

Let us see here how we can add a file within the File System as a swap area either temporarily to troubleshoot a performance issue or permanently (atleast until you add additional physical memory) to your system in SuSE and openSUSE.

First to start with, lets see how much of total memory we have on the system. This is the sum of Physical memory and any swap space already added to the system using the “free” command:

Now, lets say the system is really stressed and is running out of memory (ofcourse not the case here on my system) and we decide to quickly add a big 1Gigabyte file as a temporary swap area. We need to first create thios big monstreous 1Gigabyte file.

While this provides the swap space required for the system almost instantly, if you happen to reboot your SuSE server or your openSUSE system then this swap space won’t be available for the system. To make it permanent, we need to add an entry to the /etc/fstab file as follows:

/swap_1 swap swap defaults 0 0

Where /swap_1 is our new swap file and it instructs the system to mount it at system startup as a swap area.