feat(zram): add compressed swap with optimized sysctl parameters
- commit
- c693e8f6a69926424ace998b1353bcd4598e78a0
- author
- bnema · · 2025-10-21 16:25 UTC
- committer
- bnema · · 2025-10-21 21:54 UTC
- parent
- 5592596
- signature
- unsigned
5 files · +37 -5
M install/base.packages +5 -1
| @@ -20,7 +20,8 @@ ttf-fira-sans | |||
| 20 | 20 | ttf-jetbrains-mono-nerd | |
| 21 | 21 | ||
| 22 | 22 | # Networking | |
| 23 | - | iwd | |
| 23 | + | networkmanager | |
| 24 | + | broadcom-wl | |
| 24 | 25 | openssh | |
| 25 | 26 | ||
| 26 | 27 | # Essential Tools | |
| @@ -30,5 +31,8 @@ man-db | |||
| 30 | 31 | git | |
| 31 | 32 | bash-completion | |
| 32 | 33 | ||
| 34 | + | # Memory Management | |
| 35 | + | zram-generator | |
| 36 | + | ||
| 33 | 37 | # Encryption (added if LUKS enabled) | |
| 34 | 38 | # cryptsetup | |
| @@ -20,7 +20,8 @@ ttf-fira-sans | |||||
| 20 | ttf-jetbrains-mono-nerd | 20 | ttf-jetbrains-mono-nerd | ||
| 21 | 21 | ||||
| 22 | # Networking | 22 | # Networking | ||
| 23 | - | iwd | 23 | + | networkmanager |
| 24 | + | broadcom-wl | |||
| 24 | openssh | 25 | openssh | ||
| 25 | 26 | ||||
| 26 | # Essential Tools | 27 | # Essential Tools | ||
| @@ -30,5 +31,8 @@ man-db | |||||
| 30 | git | 31 | git | ||
| 31 | bash-completion | 32 | bash-completion | ||
| 32 | 33 | ||||
| 34 | + | # Memory Management | |||
| 35 | + | zram-generator | |||
| 36 | + | ||||
| 33 | # Encryption (added if LUKS enabled) | 37 | # Encryption (added if LUKS enabled) | ||
| 34 | # cryptsetup | 38 | # cryptsetup | ||
M install/config/all.sh +1 -0
| @@ -7,3 +7,4 @@ source "$ARCHUP_INSTALL/config/user.sh" # Interactive (gum input) | |||
| 7 | 7 | start_log_output # Resume after prompts | |
| 8 | 8 | ||
| 9 | 9 | run_logged "$ARCHUP_INSTALL/config/network.sh" # Non-interactive | |
| 10 | + | run_logged "$ARCHUP_INSTALL/config/zram.sh" # Non-interactive | |
| @@ -7,3 +7,4 @@ source "$ARCHUP_INSTALL/config/user.sh" # Interactive (gum input) | |||||
| 7 | start_log_output # Resume after prompts | 7 | start_log_output # Resume after prompts | ||
| 8 | 8 | ||||
| 9 | run_logged "$ARCHUP_INSTALL/config/network.sh" # Non-interactive | 9 | run_logged "$ARCHUP_INSTALL/config/network.sh" # Non-interactive | ||
| 10 | + | run_logged "$ARCHUP_INSTALL/config/zram.sh" # Non-interactive | |||
A install/config/zram.sh +25 -0
| @@ -0,0 +1,25 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # Configure zram compressed swap | |
| 3 | + | ||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Configuring zram swap..." | |
| 5 | + | ||
| 6 | + | # Create zram-generator config | |
| 7 | + | cat > /mnt/etc/systemd/zram-generator.conf << 'EOF' | |
| 8 | + | [zram0] | |
| 9 | + | zram-size = min(ram / 2, 4096) | |
| 10 | + | compression-algorithm = zstd | |
| 11 | + | EOF | |
| 12 | + | ||
| 13 | + | echo "Created /etc/systemd/zram-generator.conf" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 14 | + | ||
| 15 | + | # Create sysctl config for zram optimization | |
| 16 | + | cat > /mnt/etc/sysctl.d/99-vm-zram-parameters.conf << 'EOF' | |
| 17 | + | vm.swappiness = 180 | |
| 18 | + | vm.watermark_boost_factor = 0 | |
| 19 | + | vm.watermark_scale_factor = 125 | |
| 20 | + | vm.page-cluster = 0 | |
| 21 | + | EOF | |
| 22 | + | ||
| 23 | + | echo "Created /etc/sysctl.d/99-vm-zram-parameters.conf with optimized settings" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 24 | + | ||
| 25 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] zram swap configured" | |
| @@ -0,0 +1,25 @@ | |||||
| 1 | + | #!/bin/bash | |||
| 2 | + | # Configure zram compressed swap | |||
| 3 | + | ||||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Configuring zram swap..." | |||
| 5 | + | ||||
| 6 | + | # Create zram-generator config | |||
| 7 | + | cat > /mnt/etc/systemd/zram-generator.conf << 'EOF' | |||
| 8 | + | [zram0] | |||
| 9 | + | zram-size = min(ram / 2, 4096) | |||
| 10 | + | compression-algorithm = zstd | |||
| 11 | + | EOF | |||
| 12 | + | ||||
| 13 | + | echo "Created /etc/systemd/zram-generator.conf" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 14 | + | ||||
| 15 | + | # Create sysctl config for zram optimization | |||
| 16 | + | cat > /mnt/etc/sysctl.d/99-vm-zram-parameters.conf << 'EOF' | |||
| 17 | + | vm.swappiness = 180 | |||
| 18 | + | vm.watermark_boost_factor = 0 | |||
| 19 | + | vm.watermark_scale_factor = 125 | |||
| 20 | + | vm.page-cluster = 0 | |||
| 21 | + | EOF | |||
| 22 | + | ||||
| 23 | + | echo "Created /etc/sysctl.d/99-vm-zram-parameters.conf with optimized settings" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 24 | + | ||||
| 25 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] zram swap configured" | |||
M install/helpers/download.sh +1 -1
| @@ -46,7 +46,7 @@ download_archup_files() { | |||
| 46 | 46 | ||
| 47 | 47 | # Configuration | |
| 48 | 48 | download_section "Downloading config scripts..." "config" \ | |
| 49 | - | all.sh system.sh user.sh network.sh | |
| 49 | + | all.sh system.sh user.sh network.sh zram.sh | |
| 50 | 50 | ||
| 51 | 51 | # Bootloader | |
| 52 | 52 | download_section "Downloading bootloader setup..." "boot" \ | |
| @@ -46,7 +46,7 @@ download_archup_files() { | |||||
| 46 | 46 | ||||
| 47 | # Configuration | 47 | # Configuration | ||
| 48 | download_section "Downloading config scripts..." "config" \ | 48 | download_section "Downloading config scripts..." "config" \ | ||
| 49 | - | all.sh system.sh user.sh network.sh | 49 | + | all.sh system.sh user.sh network.sh zram.sh |
| 50 | 50 | ||||
| 51 | # Bootloader | 51 | # Bootloader | ||
| 52 | download_section "Downloading bootloader setup..." "boot" \ | 52 | download_section "Downloading bootloader setup..." "boot" \ | ||
M install/post-install/verify.sh +5 -3
| @@ -89,11 +89,13 @@ verify_file "/etc/fstab" "Filesystem table" | |||
| 89 | 89 | verify_file "/etc/hostname" "Hostname" | |
| 90 | 90 | verify_file "/etc/locale.conf" "Locale configuration" | |
| 91 | 91 | verify_file "/etc/locale.gen" "Locale generation file" | |
| 92 | + | verify_file "/etc/systemd/zram-generator.conf" "zram configuration" | |
| 93 | + | verify_file "/etc/sysctl.d/99-vm-zram-parameters.conf" "zram sysctl parameters" | |
| 92 | 94 | ||
| 93 | - | if [ -f "/mnt/etc/systemd/network/20-wired.network" ] || [ -f "/mnt/etc/NetworkManager/NetworkManager.conf" ]; then | |
| 94 | - | echo "[OK] Network configuration present" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 95 | + | if arch-chroot /mnt systemctl is-enabled NetworkManager &>/dev/null; then | |
| 96 | + | echo "[OK] NetworkManager enabled" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 95 | 97 | else | |
| 96 | - | echo "[ERROR] Network configuration missing" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 98 | + | echo "[ERROR] NetworkManager not enabled" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 97 | 99 | VERIFICATION_FAILED=1 | |
| 98 | 100 | fi | |
| 99 | 101 | ||
| @@ -89,11 +89,13 @@ verify_file "/etc/fstab" "Filesystem table" | |||||
| 89 | verify_file "/etc/hostname" "Hostname" | 89 | verify_file "/etc/hostname" "Hostname" | ||
| 90 | verify_file "/etc/locale.conf" "Locale configuration" | 90 | verify_file "/etc/locale.conf" "Locale configuration" | ||
| 91 | verify_file "/etc/locale.gen" "Locale generation file" | 91 | verify_file "/etc/locale.gen" "Locale generation file" | ||
| 92 | + | verify_file "/etc/systemd/zram-generator.conf" "zram configuration" | |||
| 93 | + | verify_file "/etc/sysctl.d/99-vm-zram-parameters.conf" "zram sysctl parameters" | |||
| 92 | 94 | ||||
| 93 | - | if [ -f "/mnt/etc/systemd/network/20-wired.network" ] || [ -f "/mnt/etc/NetworkManager/NetworkManager.conf" ]; then | 95 | + | if arch-chroot /mnt systemctl is-enabled NetworkManager &>/dev/null; then |
| 94 | - | echo "[OK] Network configuration present" >> "$ARCHUP_INSTALL_LOG_FILE" | 96 | + | echo "[OK] NetworkManager enabled" >> "$ARCHUP_INSTALL_LOG_FILE" |
| 95 | else | 97 | else | ||
| 96 | - | echo "[ERROR] Network configuration missing" >> "$ARCHUP_INSTALL_LOG_FILE" | 98 | + | echo "[ERROR] NetworkManager not enabled" >> "$ARCHUP_INSTALL_LOG_FILE" |
| 97 | VERIFICATION_FAILED=1 | 99 | VERIFICATION_FAILED=1 | ||
| 98 | fi | 100 | fi | ||
| 99 | 101 | ||||