Bug 490402

Summary: Contradictory documentation about recommended size for swap partitions
Product: Red Hat Enterprise Linux 5 Reporter: Ruediger Landmann <rlandman+disabled>
Component: doc-Installation_GuideAssignee: Ruediger Landmann <rlandman+disabled>
Status: CLOSED NEXTRELEASE QA Contact: Content Services Development <ecs-dev-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.2CC: david.c.mores, mhideo, pasteur, ralph, rjohnson, rvykydal
Target Milestone: rcKeywords: Documentation
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 463885 Environment:
Last Closed: 2009-03-31 11:33:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ruediger Landmann 2009-03-16 05:02:28 UTC
+++ This bug was initially created as a clone of Bug #463885 +++

Description of problem:
I am using kickstart to image a machine with the partition option.
"swap --recommended"
When I do a kickstart of a machine with 8GB ram it only creates a swap partition of 2 GB. The documentation at 
https://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.2/html/Installation_Guide/s1-kickstart2-options.html
says
"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."

Version-Release number of selected component (if applicable):
5.2

How reproducible:
everytime

Steps to Reproduce:
1. Create kiskstart file with "swap --recommended" partition option
2. build from kickstart file
3. use fdisk to see size.
  
Actual results:
kickstart creates 2GB partion for swap

Expected results:
swap partition at least the size of memory


Additional info:

--- Additional comment from rvykydal on 2008-09-25 04:34:25 EDT ---

Could you attach the ks file and /var/log/anaconda.log?

--- Additional comment from dlehman on 2008-09-25 12:05:26 EDT ---

FWIW we mostly fixed this for 4.7 in bug 339001.

--- Additional comment from grants.au on 2008-09-25 17:57:51 EDT ---

Created an attachment (id=317740)
Simplified kickstart file that should reproduce the problem

This is the anaconda-ks.cfg file of an installed system that has the required partition information in it. The original kickstart uses a lot of dynamic stuff in pre scripts and includes etc.

--- Additional comment from grants.au on 2008-09-25 17:59:43 EDT ---

Created an attachment (id=317741)
anaconda.log from a kickstart install

this log file is for a more complex kickstart that I use.

--- Additional comment from grants.au on 2008-09-25 18:02:50 EDT ---

I noticed that after I install with a kickstart file with recommended swap, the generated kickstart file that gets written to /root/anaconda-ks.cfg, contains the following line
#part swap --size=1000 --grow --maxsize=2000 --ondisk=sda

--- Additional comment from clumens on 2008-10-02 12:06:26 EDT ---

The problem here is that there are two different sets of swap size
documentation within the installation guide.  The kickstart options section
(28.4) describes the size recommendation as listed above in this bug.  The
recommended partitioning scheme section (4.18.4) describes something completely
different.  For 5.3 and F10 (therefore RHEL6) our swap size recommendation
follows the recommended partitioning scheme section.

We need the kickstart options section updated to match the recommended
partitioning scheme section.  I've already updated the Fedora wiki to match.

--- Additional comment from ddomingo on 2008-10-05 20:36:08 EDT ---

hi Chris, 
please add the link to the Fedora documentation that needs to be reflected in the RHEL IG. thanks!

--- Additional comment from mhideo on 2008-11-06 22:30:14 EDT ---

Setting to NEEDINFO

Chris can you give me alink to the Fedora wiki?

Cheers,
Mike

--- Additional comment from grants.au on 2008-11-06 23:56:27 EDT ---

Fixing the documentation is one thing ... when will anaconda do recommended swap partioning correctly? As you can see version 5.2 does not match any documentation source.

--- Additional comment from clumens on 2008-11-07 09:57:12 EDT ---

Michael, the link is:

http://fedoraproject.org/wiki/Anaconda/Kickstart

Then search for "recommended" a couple times and you'll see it under the part command.  Or, you could use the text from section 4.18.4 in the existing installation guide.

--- Additional comment from david.c.mores on 2008-11-19 14:03:43 EDT ---

(In reply to comment #9)
> Fixing the documentation is one thing ... when will anaconda do recommended
> swap partioning correctly? As you can see version 5.2 does not match any
> documentation source.

I agree completely with this.  The --recommend option working to set the swap size would be more valuable than the other options combined.  Instead, users are suckered into a time wasting exercise for an attractive option only to find that it does not work.  Please make it work as reasonably expected.

--- Additional comment from rjohnson on 2009-02-04 23:37:12 EDT ---

This problem just can't seem to be fixed and stay fixed... In *ANY* of the RedHat-like distributions. The fault is in "iutil.py" found in /usr/lib/anaconda.

From the lastest 5.x documentation:

<snip>
 Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
So, if:
M = Amount of RAM in GB, and S = Amount of swap in GB, then

If M < 2
	S = M *2
Else
	S = M + 2

Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM). 
</snip>

http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/ch04s18s04s02.html

So, if we are to take the documentation's "recommendation" (I've noticed that there are others on the RedHat site), then the following "/usr/lib/anaconda/iutil.py needs to be fixed to match:

From RH 5.3 i386 (same in x86_64)
<snip>
# try to keep 2.4 kernel swapper happy!
def swapSuggestion(quiet=0):
    mem = memInstalled()/1024
    mem = ((mem/16)+1)*16
    if not quiet:
        log.info("Detected %sM of memory", mem)

    if mem < 128:
        minswap = 96
        maxswap = 192
    else:
        if mem > 1000:
            minswap = 1000
            maxswap = 2000
        else:
            minswap = mem
            maxswap = 2*mem

    if not quiet:
        log.info("Swap attempt of %sM to %sM", minswap, maxswap)

    return (minswap, maxswap)
</snip>
-------------------------------------------------------------------------

It is fixed, after a fashion, in 5.3:

<snip>
# try to keep 2.4 kernel swapper happy!
def swapSuggestion(quiet=0):
    mem = memInstalled()/1024
    mem = ((mem/16)+1)*16
    if not quiet:
        log.info("Detected %sM of memory", mem)

    if mem < 128:
        minswap = 96
        maxswap = 192
    else:
        if mem > 2000:
            minswap = 1000
            maxswap = 2000 + mem
        else:
            minswap = mem
            maxswap = 2*mem

    if not quiet:
        log.info("Swap attempt of %sM to %sM", minswap, maxswap)

    return (minswap, maxswap)

</snip>

--------------------------------------------------------------------------

I don't understand why whoever made this fix in 5.3 doesn't understand the difference between binary and standard units, but at least the end result isn't a 2000KB swap partition if your memsize > 1000KB.  A better and cleaner fix (no need for the "< 128" test) would be (for the key bit of logic):


    if mem <= 2048:
        minswap = mem
        maxswap = 2*mem
    else:
        minswap = mem
        maxswap = mem+2048


Hey!  That even matches the recommendation!  I know..., it doesn't handle the "> 32GB" case, but I'll leave that for some other genius to fix...  Sorry for the sarcasm... <grin>  It's just that this fix is so simple and has lived on FAR too long.  It was reported against 3.x versions and perhaps even earlier.

This fix really is simple.  I've made it on my own kickstart servers by modifying/rebuilding the stage2.img and minstg2.img files (or others depending on version of the distro).  

It's been reported for multiple versions/releases of RedHat, Fedora and CentOS.  Could whoever has responsibility for this one please replicate this fix (or something else if it's better) to all active RedHat/Fedora branches?  Please?

--- Additional comment from rjohnson on 2009-02-04 23:38:47 EDT ---

Oops... The first snippet is actually from the *5.2* version of the code.

Comment 1 Ruediger Landmann 2009-03-31 11:33:30 UTC
Documentation made consistent in RHEL5 and F11 Installation Guides.