• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

How to automate the swap size as per RAM

Hi All,

My motive is to automate the process of creating swap twice of Physical RAM during OS installation .
If its not possible during oS installation then a post installation script or commands can be usefule - please help?
  • 2
1 Solution
Zephyr ICTCloud ArchitectCommented:
Did you try using the "recommended" option?

as in:
 logvol swap --recommended --fstype swap --name=LogVol00 --vgname=VolGroup00

Open in new window

According to the docs: The minimum size of the automatically-generated swap partition is no smaller than the amount of RAM in the system and no larger than twice the amount of RAM in the system.

If you want more control you'll need to create something I think ...
The twice rule is old rule , and the new  rule is suggested at this site

You can try this example code for  create and remove swap script at this stie

Hope understand your question completely.If not, pls pt it out

You need some swap like gigabyte to have indication when you run out of memory
And you can resize swap logical volume with LVM if your system really goes into crashing.
Zephyr ICTCloud ArchitectCommented:
If you want to control the swap creation during kickstart you could also opt for a "scripted" way.

Define a %pre section in the kickstart file containing following:

 mem=$((`grep MemTotal: /proc/meminfo | sed ‘s/^MemTotal: *//’|sed ‘s/ .*//’` / 1024))
 echo “logvol swap –fstype swap –name=LogVol01 –vgname=VolGroup00 –size=$mem” > /tmp/setswap

Open in new window

Then set the %include around the part where you create the partitions:

%include /tmp/setswap

Open in new window

Fyi, I've tested the code on a Centos.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now