[PATCH 3/5] Add swapSameAsRam and use it for autopartitioning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The algorithm in swapSuggestion has changed to using less swap space than RAM
size which is not enough for hibernation. So we need to use a different
algorithm for autopartitioning and the swap with the same size as RAM should be
a good default.

(ported 0ff17d6012e6cfa2458d3fa282dfd5094a4f5787 from rhel6-branch)
---
 pyanaconda/installclass.py            |    2 +-
 pyanaconda/storage/devicelibs/swap.py |   24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/pyanaconda/installclass.py b/pyanaconda/installclass.py
index 0855319..9f9a5d3 100644
--- a/pyanaconda/installclass.py
+++ b/pyanaconda/installclass.py
@@ -185,7 +185,7 @@ class BaseInstallClass(object):
         if bootreq:
             autorequests.extend(bootreq)
 
-        (minswap, maxswap) = swap.swapSuggestion()
+        (minswap, maxswap) = swap.swapSameAsRam()
         autorequests.append(PartSpec(fstype="swap", size=minswap, maxSize=maxswap,
                                      grow=True, lv=True, encrypted=True))
 
diff --git a/pyanaconda/storage/devicelibs/swap.py b/pyanaconda/storage/devicelibs/swap.py
index c4a46b1..52209ff 100644
--- a/pyanaconda/storage/devicelibs/swap.py
+++ b/pyanaconda/storage/devicelibs/swap.py
@@ -31,6 +31,8 @@ from . import dm
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
 
+#see rhbz#744129 for details
+SWAP_SIZE_LIMIT = 128 * 1024
 
 def mkswap(device, label='', progress=None):
     # We use -f to force since mkswap tends to refuse creation on lvs with
@@ -166,3 +168,25 @@ def swapSuggestion(quiet=0):
 
     return (minswap, maxswap)
 
+def swapSameAsRam(quiet=0):
+    """
+    Checks if we can create a swap with the same size as RAM (see rhbz#587152)
+    and returns max(RAMsize, SWAP_SIZE_LIMIT).
+
+    @param quiet: whether the size information should be logged
+
+    """
+
+    mem = iutil.memInstalled() / 1024
+    mem = ((mem / 16) + 1) * 16
+    if not quiet:
+        log.info("Detected %sM of memory", mem)
+
+    #see #rhbz587152
+    if mem <= SWAP_SIZE_LIMIT:
+        log.info("Swap attempt of %sM to %sM", mem, mem)
+        return (mem / 2, mem)
+    else:
+        log.warning("Cannot create swap of size %sM, using upper bound %sM",
+                    mem, SWAP_SIZE_LIMIT)
+        return (SWAP_SIZE_LIMIT, SWAP_SIZE_LIMIT)
-- 
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux