Set up Zram dynamically based on best practice (#4027)
* Use the total available RAM / 2 for swap size dynamically. * ws * - 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 * Add debug print
This commit is contained in:
parent
1faac77c0d
commit
9412f97771
|
|
@ -979,12 +979,17 @@ class Installer:
|
|||
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}')
|
||||
# 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')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue