From bfeda9114e0e59ee0985f20ed98129a1572ac0e9 Mon Sep 17 00:00:00 2001 From: Andrei Smaliak Date: Thu, 3 Sep 2026 16:34:20 +0200 Subject: [PATCH] Keep swap disabled on kernels without zram support --- stage_env/stage_env_install_no_pulse.sh | 58 ------------------- .../iomatex-postinstall-selftest.sh | 12 +--- 2 files changed, 2 insertions(+), 68 deletions(-) diff --git a/stage_env/stage_env_install_no_pulse.sh b/stage_env/stage_env_install_no_pulse.sh index 0dfbc7e..1479911 100644 --- a/stage_env/stage_env_install_no_pulse.sh +++ b/stage_env/stage_env_install_no_pulse.sh @@ -369,62 +369,6 @@ EOF fi } -configure_zram_swap() { - write_if_changed /usr/local/sbin/iomatex-zram 0755 <<'EOF' -#!/usr/bin/env bash -set -euo pipefail - -device=/dev/zram0 - -case "${1:-start}" in - start) - if swapon --show=NAME --noheadings 2>/dev/null | awk '{$1=$1};1' | grep -qx "$device"; then - exit 0 - fi - modprobe zram num_devices=1 >/dev/null 2>&1 || exit 0 - [ -b "$device" ] || exit 0 - command -v zramctl >/dev/null 2>&1 || exit 0 - mem_kib="$(awk '/^MemTotal:/ {print $2}' /proc/meminfo)" - size_bytes=$((mem_kib * 1024 / 4)) - min_bytes=$((128 * 1024 * 1024)) - max_bytes=$((512 * 1024 * 1024)) - [ "$size_bytes" -lt "$min_bytes" ] && size_bytes="$min_bytes" - [ "$size_bytes" -gt "$max_bytes" ] && size_bytes="$max_bytes" - zramctl --reset "$device" >/dev/null 2>&1 || true - zramctl --size "$size_bytes" "$device" - mkswap "$device" >/dev/null - swapon --priority 100 "$device" - ;; - stop) - swapoff "$device" >/dev/null 2>&1 || true - zramctl --reset "$device" >/dev/null 2>&1 || true - ;; - *) - echo "usage: $0 {start|stop}" >&2 - exit 2 - ;; -esac -EOF - - write_if_changed /etc/systemd/system/iomatex-zram.service 0644 <<'EOF' -[Unit] -Description=IOMATEX compressed RAM swap -After=systemd-modules-load.service - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/usr/local/sbin/iomatex-zram start -ExecStop=/usr/local/sbin/iomatex-zram stop - -[Install] -WantedBy=multi-user.target -EOF - - systemctl daemon-reload - systemctl_enable_now_safe iomatex-zram.service -} - userdata_has_journal() { local device device="$(readlink -f /dev/disk/by-partlabel/userdata 2>/dev/null || true)" @@ -1325,7 +1269,6 @@ EOF # - NO fstab entries that can block boot # - /userdata is treated as optional for boot # - NO swap on /userdata; hard power cuts can make that partition block boot on fsck -# - compressed RAM swap is provided by iomatex-zram.service when supported # - generic app log directory is created only when /userdata is already mounted # ------------------------- step "Userdata SAFE: non-blocking mount + generic logs + log overflow protection" @@ -1343,7 +1286,6 @@ if [ "$STAGE_ENV_REINSTALL" -eq 0 ]; then else log "Existing Edge detected: leaving swap configuration untouched" fi -configure_zram_swap soft_run "systemd daemon-reload (storage contract)" 20 /bin/systemctl daemon-reload soft_run "Enable iomatex-userdata-prepare.service" 20 /bin/systemctl enable iomatex-userdata-prepare.service diff --git a/stage_validation/iomatex-postinstall-selftest.sh b/stage_validation/iomatex-postinstall-selftest.sh index 1302fd6..f7a2284 100755 --- a/stage_validation/iomatex-postinstall-selftest.sh +++ b/stage_validation/iomatex-postinstall-selftest.sh @@ -138,19 +138,11 @@ check_base_system() { local swap_total="" swap_total="$(free -h 2>/dev/null | awk '/^Swap:/ {print $2}')" if [[ -z "$swap_total" || "$swap_total" == "0B" || "$swap_total" == "0" ]]; then - if unit_exists "iomatex-zram.service"; then - warn "iomatex-zram.service is installed but swap is unavailable" - else - warn "swap is disabled" - fi + warn "swap is disabled" else pass "swap configured: ${swap_total}" - if swapon --show=NAME --noheadings 2>/dev/null | awk '{$1=$1};1' | grep -qx /dev/zram0; then - pass "zram swap active on /dev/zram0" - elif swapon --show=NAME --noheadings 2>/dev/null | grep -q '^/userdata/'; then + if swapon --show=NAME --noheadings 2>/dev/null | grep -q '^/userdata/'; then fail "swap must not depend on /userdata" - else - warn "swap is active but not provided by iomatex zram" fi fi