Solved

How to automate the swap size as per RAM

Posted on 2014-07-31
4
486 Views
Last Modified: 2014-08-18
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?
0
Comment
Question by:apunkabollywood
  • 2
4 Comments
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 40231369
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 ...
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40231404
The twice rule is old rule , and the new  rule is suggested at this site
http://www.cyberciti.biz/tips/linux-swap-space.html

You can try this example code for  create and remove swap script at this stie
http://programmaticponderings.wordpress.com/2013/12/19/scripting-linux-swap-space/

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


Duncan
0
 
LVL 62

Expert Comment

by:gheist
ID: 40231481
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.
0
 
LVL 25

Accepted Solution

by:
Zephyr ICT earned 500 total points
ID: 40231508
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:

%pre
 #!/bin/sh
 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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question