diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 0603639add..c93f361aa3 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1020,27 +1020,19 @@ def setup_btrfs_snapshot( self._configure_grub_btrfsd(snapshot_type) self.enable_service('grub-btrfsd.service') - def setup_swap(self, kind: str = 'zram', algo: ZramAlgorithm = ZramAlgorithm.ZSTD) -> 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, with minimum of 4096 MB - size_mb = max(ram_kb // 2048, 4096) - info(f'Zram size: {size_mb} from RAM: {ram_kb}') - info(f'Zram compression algorithm: {algo.value}') - - 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') - zram_conf.write(f'compression-algorithm = {algo.value}\n') - - self.enable_service('systemd-zram-setup@zram0.service') - - self._zram_enabled = True - else: - raise ValueError('Archinstall currently only supports setting up swap on zram') + def setup_swap(self, algo: ZramAlgorithm = ZramAlgorithm.ZSTD) -> None: + info('Setting up swap on zram') + self.pacman.strap('zram-generator') + + info(f'Zram compression algorithm: {algo.value}') + + with open(f'{self.target}/etc/systemd/zram-generator.conf', 'w') as zram_conf: + zram_conf.write('[zram0]\n') + zram_conf.write(f'compression-algorithm = {algo.value}\n') + + self.enable_service('systemd-zram-setup@zram0.service') + + self._zram_enabled = True def _get_efi_partition(self) -> PartitionModification | None: for layout in self._disk_config.device_modifications: diff --git a/archinstall/scripts/guided.py b/archinstall/scripts/guided.py index 64dbbff913..4655a48d65 100644 --- a/archinstall/scripts/guided.py +++ b/archinstall/scripts/guided.py @@ -105,7 +105,7 @@ def perform_installation( installation.set_mirrors(mirror_list_handler, mirror_config, on_target=True) if config.swap and config.swap.enabled: - installation.setup_swap('zram', algo=config.swap.algorithm) + installation.setup_swap(algo=config.swap.algorithm) if config.bootloader_config and config.bootloader_config.bootloader != Bootloader.NO_BOOTLOADER: if config.bootloader_config.bootloader == Bootloader.Grub and SysInfo.has_uefi():