1

Memory Swap Ratio Company System

Today, a monitoring system indicated that one of the systems in the company has run out of memory. Executing htop on this system indicated that the Memory was nearly full (~8GB) even as the Swap Space (~0.5GB).

Stopping some of the services decreased the Memory use, but the Swap Space remained fully allocated.

According to this documentation it seems that the Swap Space of this Company's system does not match the recommended space:

S = M < 2 ? M * 2 : M + 2

Default Swap Space Test System

Executing htop on a test system results in:

enter image description here

which means a ratio of ~1:1 (1877/1799).

Subquestion: Why does the default Swap Memory Space Ratio not equal 2:1?


Clear and Increase Swap Space on a running system

Increase Swap Space

This documentation indicates that several commands should be executed in order to increase the Swap Space. Are all these commands really required?

Clear Swap Space

According to this documentation the Swap Space could be cleared by executing:

swapoff -a && swapon -a

Safely increase Swap Space

This documentation recommends to create a backup before increasing the Swap Space, but it does not indicate the possible impact. As this concerns a production system it is important to know if it is safe to increase the Swap Space on the system while it runs or e.g. should a new system be created and the date subsequently be moved?


Question:

What is the fastest and safest way to increase the Swap Space on Scientific Linux?

1 Answer 1

3

If you are using a LVM, you can allocate/create a new Logical Volume a format it as a swap space.

lvcreate -n swap2 -L 2G VG_NAME
mkswap /dev/VG_NAME/swap2
swapon -a

e.g the above will create a 2G LogicalVolume partition on VolumeGroup named VG_NAME, then format the LV as swap, and activated it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .