From 4bc91a8600309c4dff3a447c5e2ad933f86fa03e Mon Sep 17 00:00:00 2001 From: H8D13 Date: Wed, 24 Dec 2025 11:02:33 +0100 Subject: [PATCH 1/4] Use the total available RAM / 2 for swap size dynamically. --- archinstall/lib/installer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 36a15df686..44f66285f1 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -979,12 +979,16 @@ def setup_swap(self, kind: str = 'zram') -> None: if kind == 'zram': info('Setting up swap on zram') self.pacman.strap('zram-generator') - + # Get RAM size in MB from hardware info + ram_kb = SysInfo.mem_total() + # Convert KB to MB and divide by 2 + size_mb = ram_kb // 2048 # We could use the default example below, but maybe not the best idea: https://github.com/archlinux/archinstall/pull/678#issuecomment-962124813 # 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") with open(f'{self.target}/etc/systemd/zram-generator.conf', 'w') as zram_conf: zram_conf.write('[zram0]\n') + zram_conf.write(f'zram-size = {size_mb}\n') self.enable_service('systemd-zram-setup@zram0.service') From 1d7c92ec783dbd7bccb91a918417b6965b954176 Mon Sep 17 00:00:00 2001 From: H8D13 Date: Wed, 24 Dec 2025 11:13:25 +0100 Subject: [PATCH 2/4] ws --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 44f66285f1..3e0570e747 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -982,7 +982,7 @@ def setup_swap(self, kind: str = 'zram') -> None: # Get RAM size in MB from hardware info ram_kb = SysInfo.mem_total() # Convert KB to MB and divide by 2 - size_mb = ram_kb // 2048 + size_mb = ram_kb // 2048 # We could use the default example below, but maybe not the best idea: https://github.com/archlinux/archinstall/pull/678#issuecomment-962124813 # 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") From af55e5069fba7f6aef6509b7b7376a9bc749f157 Mon Sep 17 00:00:00 2001 From: H8D13 Date: Wed, 24 Dec 2025 11:15:26 +0100 Subject: [PATCH 3/4] - Systems with 8 GB RAM or less will get 4096 MB zram - Systems with more than 8 GB RAM will get half their RAM as zram --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 3e0570e747..7dff013ceb 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -981,8 +981,8 @@ def setup_swap(self, kind: str = 'zram') -> None: self.pacman.strap('zram-generator') # Get RAM size in MB from hardware info ram_kb = SysInfo.mem_total() - # Convert KB to MB and divide by 2 - size_mb = ram_kb // 2048 + # Convert KB to MB and divide by 2, with minimum of 4096 MB + size_mb = max(ram_kb // 2048, 4096) # We could use the default example below, but maybe not the best idea: https://github.com/archlinux/archinstall/pull/678#issuecomment-962124813 # 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") From d903b17e4233423c8b82951368572f071ddfe0c4 Mon Sep 17 00:00:00 2001 From: h8d13 Date: Wed, 24 Dec 2025 14:35:47 +0100 Subject: [PATCH 4/4] Add debug print --- archinstall/lib/installer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 7dff013ceb..a4fa4891e3 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -983,6 +983,7 @@ def setup_swap(self, kind: str = 'zram') -> None: ram_kb = SysInfo.mem_total() # Convert KB to MB and divide by 2, with minimum of 4096 MB size_mb = max(ram_kb // 2048, 4096) + info(f'Zram size: {size_mb} from RAM: {ram_kb}') # We could use the default example below, but maybe not the best idea: https://github.com/archlinux/archinstall/pull/678#issuecomment-962124813 # 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")