Bug 464036

Summary: incorrect swap size on >2G systems
Product: Red Hat Enterprise Linux 5 Reporter: Chad Harvey <chad>
Component: anacondaAssignee: Anaconda Maintenance Team <anaconda-maint-list>
Status: CLOSED DUPLICATE QA Contact: Release Test Team <release-test-team-automation>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.2   
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2008-0653 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-09-26 20:33:38 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 Chad Harvey 2008-09-26 00:17:46 UTC
+++ This bug was initially created as a clone of Bug #339001 +++

Description of problem:

According to the documentation for RHEL4, "Swap should equal 2x physical RAM for
up to 2 GB of physical RAM, and then 1x physical RAM for any amount above 2 GB"
(http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/x8664-multi-install-guide/s1-diskpartitioning.html#S2-DISKPARTRECOMMEND)

However, on systems with >2G of RAM, only 2G is allocated when the "recommended"
option is used in kickstart configurations.



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

Tested on, but not limited to RHEL 4.5, anaconda-10.1.1.63-4
I looked at RHEL5 and it has the same problem, but I didn't test it.


How reproducible:

Very consistently, unfortunately.


Steps to Reproduce:

Assuming you have PXE/kickstart environment set up already:
1. Create a kickstart file with the line:
           part swap --recommended --asprimary
   as the partitioning line for swap

2. PXE boot and kickstart a system with more than 2G of memory and sufficient
disk space such that the maximum amount of swap could be allocated (147G of
disk, for instance).
  
Actual results:

2G of swap.

Expected results:

More than 2G of swap (10G in the case of an 8G systems)

Additional info:

We use PXE boots with kickstart; non-interactive; partitioning line as mentioned
above; all systems with >2G of memory (usually 8G); all systems have >100G of
disk space.

The logic for determining swap size maximizes the swap at 2G (probably due to a
legacy filesystem size limit). 

By applying the following patch to the stage2.img in the file
/usr/lib/anaconda/iutil.py, the correct amount of swap is created:

*** iutil.py-   1969-12-31 17:00:00.000000000 -0700
--- iutil.py    1969-12-31 17:00:00.000000000 -0700
***************
*** 256,259 ****
--- 256,264 ----
          maxswap = 192
      else:
+         if mem > 2000:
+             memextra = mem - 2000
+             minswap = 2000
+             maxswap = 4000 + memextra
+         else:
              if mem > 1000:
                  minswap = 1000

Only tested on system with >2G of memory (4G and 8G). And isn't a megabyte 1024,
not 1000? :)

--- Additional comment from atodorov on 2008-04-24 09:40:16 EDT ---

Observations from latest 4.7 tree available:
environment: Xen/PV guest, i386, start up memory = maximum memory

mem: 8GB, install: manual, choose auto partition (e.g. lvm) - 10GB (as expected)
mem: 8GB, install: ks.cfg w/ swap --recommended - 8GB swap partition is created

mem: 5GB, install: manual, choose auto partition (e.g. lvm) - 7GB (as expected)
mem: 5GB, install: ks.cfg w/ swap --recommended - 7GB (as expected)

Only for the 8GB case the --recommended is not creating partition with the
expected size. Still investigating this with Martin to figure out what is wrong.

--- Additional comment from atodorov on 2008-04-30 10:13:39 EDT ---

after more investigation I will move this to VERIFIED.
The swap calculation is fixed but there is a limit of 8GB hard coded in anaconda
hence the results in comment #4.

This limit is not documented and bug #437089 is used to track that.

--- Additional comment from atodorov on 2008-05-05 07:25:10 EDT ---

wrt to comment #6:

the limit mentioned is the value of self.maxSizeMB in class swapFileSystem in
fsset.py which is actually 8TB not GB. Anyway something is preventing the
creation of swap partition larger than 8GB when using '--recommended'.

Using bug #437089 to document that. The problem reported with this bug was fixed
(i.e. the formula calculating the swap size was fixed to calculate the correct
size).

--- Additional comment from errata-xmlrpc on 2008-07-24 15:05:59 EDT ---

An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2008-0653.html

Comment 1 Chris Lumens 2008-09-26 20:33:38 UTC

*** This bug has been marked as a duplicate of bug 447372 ***

Comment 2 Chris Lumens 2008-09-26 20:34:56 UTC
Sorry for duping this to a private bug.  447372 is tracking this exact issue for 5.3 and is currently in the ON_QA state, meaning a fix has been committed and is being checked by QA.  So this should be fixed in the next minor release of RHEL5.  Thanks for the bug report.