Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archinstall/lib/installer.py12
-rw-r--r--archinstall/lib/user_interaction.py3
-rw-r--r--examples/guided.py5
3 files changed, 20 insertions, 0 deletions
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 11a0f24e..29b884d5 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -463,6 +463,18 @@ class Installer:
return True
+ def setup_swap(self, kind='zram'):
+ if kind == 'zram':
+ self.log(f"Setting up swap on zram")
+ self.pacstrap('zram-generator')
+ zram_example_location = '/usr/share/doc/zram-generator/zram-generator.conf.example'
+ shutil.copy2(f"{self.target}{zram_example_location}", f"{self.target}/usr/lib/systemd/zram-generator.conf")
+
+ if self.enable_service('systemd-zram-setup@zram0.service') and self.enable_service('systemd-zram-setup@zram1.service'):
+ return True
+ else:
+ raise ValueError(f"Archinstall currently only supports setting up swap on zram")
+
def add_bootloader(self, bootloader='systemd-bootctl'):
for plugin in plugins.values():
if hasattr(plugin, 'on_add_bootloader'):
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 6b142288..84eefdc0 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -325,6 +325,9 @@ class MiniCurses:
return response
+def ask_for_swap(prompt='Would you like to use swap on zram? (Y/n): ', forced=False):
+ return True if input(prompt).strip(' ').lower() not in ('n', 'no') else False
+
def ask_for_superuser_account(prompt='Username for required superuser with sudo privileges: ', forced=False):
while 1:
new_user = input(prompt).strip(' ')
diff --git a/examples/guided.py b/examples/guided.py
index 19fff406..4bbe94ca 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -126,6 +126,9 @@ def ask_user_questions():
if not archinstall.arguments.get("bootloader", None):
archinstall.arguments["bootloader"] = archinstall.ask_for_bootloader()
+ if not archinstall.arguments.get('swap', None):
+ archinstall.archinstall['swap'] = archinstall.ask_for_swap()
+
# Get the hostname for the machine
if not archinstall.arguments.get('hostname', None):
archinstall.arguments['hostname'] = input('Desired hostname for the installation: ').strip(' ')
@@ -268,6 +271,8 @@ def perform_installation(mountpoint):
if archinstall.arguments["bootloader"] == "grub-install" and archinstall.has_uefi():
installation.add_additional_packages("grub")
installation.add_bootloader(archinstall.arguments["bootloader"])
+ if archinstall.archinstall['swap']:
+ installation.setup_swap('zram')
# If user selected to copy the current ISO network configuration
# Perform a copy of the config