Enable the swap partition during installation. (and Exclude calamares installer from oom killer.)
https://github.com/calamares/calamares/pull/2097
During installation, if a swap partition exists, enable swap.
If there is no swap at all when the partition of the installation destination device is mounted, if a Swap partition exists, enable swap. target_env_call cannot be used because it is before the files are copied to the installation destination. host_env_process_output cannot be used because the return value cannot be obtained. To avoid reinventing the wheel as much as possible, use subprocess.check_output.
diff --git a/src/modules/mount/main.py b/src/modules/mount/main.py
index 32da36dd0..6207a6cfe 100644
--- a/src/modules/mount/main.py
+++ b/src/modules/mount/main.py
@@ -307,6 +307,12 @@ def mount_partition(root_mount_point, partition, partitions, mount_options, moun
mount_option) != 0:
libcalamares.utils.warning("Cannot mount {}".format(device))
+def enable_swap_partitions(swap_partitions):
+ try:
+ for swap_device in swap_partitions:
+ libcalamares.utils.host_env_process_output(["swapon", swap_device])
+ except subprocess.CalledProcessError:
+ libcalamares.utils.warning("Failed to swapon " + swap_device)
def run():
"""
@@ -321,6 +327,10 @@ def run():
return (_("Configuration Error"),
_("No partitions are defined for <pre>{!s}</pre> to use.").format("mount"))
+ # swap
+ swap_partitions = [p['device'] for p in partitions if p['fs'] == 'linuxswap']
+ enable_swap_partitions(swap_partitions)
+
root_mount_point = tempfile.mkdtemp(prefix="calamares-root-")
# Get the mountOptions, if this is None, that is OK and will be handled later
diff --git a/data/calamares_polkit b/data/calamares_polkit
index 363dcf7..cb8d2f6 100644
--- a/data/calamares_polkit
+++ b/data/calamares_polkit
@@ -1,4 +1,11 @@
#!/bin/bash
+
+#swap
+[[ $(swapon --show) == "" ]] && SWAP=$(lsblk -l -f -n -p | awk '{if ($2=="swap") print $1}') && ( sudo swapon $SWAP || (sudo mkswap $SWAP && sudo swapon $SWAP) )
+
+NO_OOM_KILLER="`pidof -xw Xwayland udisksd` $$"
+echo $NO_OOM_KILLER | xargs -n1 sudo choom -n -1000 -p
+
if [ $(which pkexec) ]; then
pkexec --disable-internal-agent "/usr/bin/calamares" "-D6" "$@"
else