Skip to content

cloud-init: stop persisting zram swap into /etc/fstab (slow cloud boot) - #10324

Open
igorpecovnik wants to merge 1 commit into
mainfrom
cloudinit-no-zram-swap-fstab
Open

cloud-init: stop persisting zram swap into /etc/fstab (slow cloud boot)#10324
igorpecovnik wants to merge 1 commit into
mainfrom
cloudinit-no-zram-swap-fstab

Conversation

@igorpecovnik

@igorpecovnik igorpecovnik commented Aug 3, 2026

Copy link
Copy Markdown
Member

On the arm64 cloud images, boot takes ~90 s longer than it should. Root cause:

  • armbian-zram-config.service sets up zram swap at boot.
  • cloud-init's mounts module sees that active swap and persists it to /etc/fstab: /dev/zram0 none swap sw,comment=cloudconfig 0 0.
  • On the next boot systemd turns that line into a dev-zram0.swap unit that blocks ~90 s on the device timeout waiting for /dev/zram0 (which only appears once armbian-zram-config runs), failing swap.target until it recovers.

Confirmed on two production cloud hosts (armbian-aarch64-1/2), both with the identical fstab line and a 90 s dev-zram0.device timeout in dmesg.

Fix

A cloud.cfg.d drop-in (99-armbian-no-zram-swap.cfg) that sets cloud-init's swap mount to null:

mounts:
  - [ swap, null ]

This removes cloud-init's default swap mount so it leaves zram/swap management to Armbian, while keeping the rest of the mounts module. Verified against cc_mounts.py (26.1): handle() runs sanitize_mounts_configuration before add_default_mounts_to_cfg, so the sanitized swap/dev/zram0 entry suppresses the auto-added default swap entry, and the null mountpoint keeps it out of fstab.

Deployed cloud hosts were already fixed by removing the stale fstab line (armbian-zram-config still provides the swap); this stops new images from shipping the bug.

Summary by CodeRabbit

  • Bug Fixes
    • Prevented cloud-init from persisting dynamically configured Armbian zram swap in /etc/fstab.
    • Preserved processing for other mount configurations.

cloud-init's `mounts` module sees the running zram swap that
armbian-zram-config sets up and writes a "/dev/zram0 ... swap ... cloudconfig"
line into /etc/fstab. On the next boot systemd turns that into a dev-zram0.swap
unit that blocks ~90s waiting for /dev/zram0 (created later by
armbian-zram-config) before swap.target recovers — a very slow boot every time,
seen on the arm64 cloud images.

Ship a cloud.cfg.d drop-in that sets the `swap` mount to null, removing
cloud-init's default swap mount so it leaves zram/swap to Armbian. Verified
against cc_mounts (config is sanitized before de-dup, so the default swap entry
is suppressed too).

Signed-off-by: Igor Pecovnik <igor@armbian.com>
@github-actions github-actions Bot added the 08 Milestone: Third quarter release label Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds a cloud-init configuration that prevents Armbian zram swap from being persisted in /etc/fstab while leaving other mount processing enabled.

Changes

Cloud-init swap handling

Layer / File(s) Summary
Override swap mount persistence
extensions/cloud-init/config/99-armbian-no-zram-swap.cfg
Adds documentation and sets the cloud-init mounts swap entry to null.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

  • armbian/build#10065: Changes swapfile creation in armbian-install, while this PR changes cloud-init swap persistence.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing cloud-init from persisting zram swap entries to /etc/fstab.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cloudinit-no-zram-swap-fstab

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size/small PR with less then 50 lines Needs review Seeking for review Framework Framework components labels Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

08 Milestone: Third quarter release Framework Framework components Needs review Seeking for review size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

1 participant