From 70d95922195efa6cab4eadcf3258b8b7ad6dedec Mon Sep 17 00:00:00 2001 From: Kyle Krenzer Date: Fri, 4 Sep 2026 11:51:06 -0700 Subject: [PATCH] zram: retry the device reset instead of dying silently at boot The zram init script runs with "set -e". Right after "modprobe zram" udev opens the new block device to probe it, and while it is open the write to /sys/block/zram0/reset fails with EBUSY, which ends the script before mkswap and swapon ever run. Nothing reports the failure: the kernel log shows "zram: Added device" and then silence, and the machine runs with no swap at all. It is a race, so it does not happen on every boot. Wait for udev to settle when udevadm is available, then retry the reset for up to five seconds, and say so on the console if it still fails. Co-Authored-By: Claude Fable 5.1 --- meta-opencentauri/recipes-core/zram/files/init | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/meta-opencentauri/recipes-core/zram/files/init b/meta-opencentauri/recipes-core/zram/files/init index e9bdbf8e..a6cf4395 100644 --- a/meta-opencentauri/recipes-core/zram/files/init +++ b/meta-opencentauri/recipes-core/zram/files/init @@ -25,7 +25,23 @@ start() { modprobe zram num_devices=1 echo "zram devices probed successfully" - echo 1 > /sys/block/zram0/reset + # udev opens the new block device to probe it, and a reset while it is + # open fails with EBUSY. With "set -e" that used to end this script + # silently, before swap was ever enabled. Let udev finish, then retry. + if command -v udevadm >/dev/null 2>&1; then + udevadm settle --timeout=5 || true + fi + tries=0 + while ! echo 1 > /sys/block/zram0/reset 2>/dev/null; do + tries=$((tries + 1)) + if [ "$tries" -ge 20 ]; then + echo "zram: /sys/block/zram0/reset still busy after $tries tries, giving up" + return 1 + fi + sleep 0.25 + done + [ "$tries" -gt 0 ] && echo "zram: reset succeeded after $tries retries" + echo lz4 > /sys/block/zram0/comp_algorithm echo $disksize > /sys/block/zram0/disksize