Skip to content

Conversation

@vidplace7
Copy link
Member

@vidplace7 vidplace7 commented Oct 28, 2025

Description

Adds new extension for userland tweaks for memory starved boards.

This work has been split off from PR #8797 as it will also apply to other memory starved boards outside of this family.

Optimizations

  • Disable zram swap in favor of zswap. Especially on the 64MB RV1103, zswap is required for memory-intensive tasks like apt-get and locale-gen.
  • Create swapfile on firstboot and enable before basic.target (available early)
  • Disable armbian ramlog by default to save memory
  • Set /run tmpfs size to 20M (configurable). systemd throws errors when less than 16MB is free in this partition during daemon-reload.

Documentation summary for feature / change

  • short description (copy / paste of PR title)
    • Extensions: LowMem
  • summary (description relevant for end users)
    • The LowMem Extension provides userspace configuration optimizations for boards with <256MB Memory (64MB, 128MB).
  • example of usage (how to see this in function)
    • Board Maintainers should enabled this extension per-board at their discretion (opt-in)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@vidplace7 vidplace7 requested review from a team and igorpecovnik as code owners October 28, 2025 16:05
@github-actions github-actions bot added 11 Milestone: Fourth quarter release size/medium PR with more then 50 and less then 250 lines Needs review Seeking for review Framework Framework components BSP Board Support Packages labels Oct 28, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

Adds a low-memory optimization extension and BSP assets. New extensions/lowmem.sh provides functions to copy a default /etc/default/armbian-lowmem, install a lowmem-mkswap script and systemd unit into the target image, enable the lowmem-mkswap unit inside the chroot, and adjust image defaults (set LOWMEM_TMPFS_RUN_MB=20, ensure a /run tmpfs fstab entry if absent, disable armbian-ramlog and armbian-zram-config by default). Adds packages/bsp/armbian-lowmem/lowmem-mkswap.service, lowmem-mkswap.sh, and the default config file.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Areas to focus review on:

  • Consistency between lowmem-mkswap.service ExecStart and installed script path/permissions.
  • Correctness of systemd unit fields (DefaultDependencies, Wants/After, WantedBy) and interaction with armbian-resize-filesystem.service.
  • Idempotency and safety of copy/install logic in extensions/lowmem.sh.
  • Robustness of enabling a systemd unit inside the mounted chroot (use of systemctl/chroot with MOUNT).
  • Safety of fstab edits and updates to /etc/default/*.
  • Swap script: free-space checks, use of fallocate, permission setting, mkswap/swapon error handling, and protection against overwriting existing swap.

Suggested labels

Hardware

Suggested reviewers

  • igorpecovnik
  • leggewie
  • paolosabatino
  • pyavitz
  • EvilOlaf
  • Tonymac32
  • adeepn

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: a new LowMem extension for memory-constrained boards with less than 256MB RAM.
Description check ✅ Passed The description is directly related to the changeset, explaining the extension's purpose, optimizations, testing, and documentation completion.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f82f6a4 and aea06e7.

📒 Files selected for processing (4)
  • extensions/lowmem.sh (1 hunks)
  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
  • extensions/lowmem.sh
🧰 Additional context used
🧠 Learnings (16)
📓 Common learnings
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.
Learnt from: leggewie
Repo: armbian/build PR: 8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.
📚 Learning: 2025-09-18T03:36:17.862Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8537
File: config/boards/qcom-robotics-rb5.conf:1-1
Timestamp: 2025-09-18T03:36:17.862Z
Learning: In Armbian board configuration files (regardless of file extension), the standard pattern is to have only one line as a comment describing the board hardware specifications. This single-line description typically includes the SoC model, core count, RAM options, and key features like connectivity options, storage interfaces, and special features. The file extensions indicate board support status: .conf (standard support), .csc (community supported), .eos (end of support), .tvb (tvbox), .wip (work in progress).

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-07-17T04:12:33.125Z
Learnt from: pyavitz
Repo: armbian/build PR: 8388
File: config/boards/kickpik2b.conf:1-14
Timestamp: 2025-07-17T04:12:33.125Z
Learning: In the Armbian build system, board configuration files (*.conf) follow a project standard of not including shebang lines, even though they contain bash code and are sourced by the build system. This is an established Armbian convention that individual contributors are expected to follow, and changes to this standard would require broader project maintainer approval.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-08-30T04:13:16.457Z
Learnt from: tabrisnet
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-08-30T04:13:16.457Z
Learning: Armbian kernel configuration files like linux-filogic-current.config are autogenerated overlays on top of arch defconfig. Comments added manually will be lost during future updates by maintainers, and explicit "CONFIG_OPTION is not set" statements aren't needed for mutually exclusive options since these are overlay configs that only specify changes from the base configuration.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-09-14T06:19:06.828Z
Learnt from: amazingfate
Repo: armbian/build PR: 8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-11-02T20:49:56.719Z
Learnt from: igorpecovnik
Repo: armbian/build PR: 8849
File: config/boards/radxa-e54c.csc:14-28
Timestamp: 2025-11-02T20:49:56.719Z
Learning: In Armbian board configuration files (config/boards/*.conf, *.csc, etc.), do not use kernel_config_set, kernel_config_set_m, kernel_config_set_y, or custom_kernel_config__* functions to modify kernel configuration. Kernel configuration is associated with LINUXFAMILY/BOARDFAMILY, not individual BOARD. Board-specific kernel modifications cause inconsistency in kernel packages published to the apt repository because boards within a family share the same kernel packages. Kernel configuration changes must be made in the appropriate kernel config file (e.g., config/kernel/linux-*-*.config) or in family configuration files (config/sources/families/*.conf, *.inc) instead.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-09-18T03:36:17.862Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8537
File: config/boards/qcom-robotics-rb5.conf:1-1
Timestamp: 2025-09-18T03:36:17.862Z
Learning: In Armbian board configuration files, .wip and .conf extensions require BOARD_MAINTAINER to be present and contain at least one maintainer. If no maintainer is present, the board support rules state it does not qualify for standard support and must be moved to community support (.csc extension). This is documented at https://docs.armbian.com/User-Guide_Board-Support-Rules/

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-04-28T08:27:26.890Z
Learnt from: leggewie
Repo: armbian/build PR: 8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-10-24T04:46:22.901Z
Learnt from: tabrisnet
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-10-24T04:46:22.901Z
Learning: In lib/functions/rootfs/rootfs-create.sh, the FIXME comment about mmdebstrap usage with --aptopt is a future note related to PR #8785, which hasn't been merged yet.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-07-25T03:51:50.830Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub API (https://api.github.com/repos/armbian/build/pulls/{pr_number}/files) to get the complete picture of what files are being added or modified, especially for U-Boot patches that will be applied during the build process.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-07-25T03:51:50.830Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-09-25T18:37:00.330Z
Learnt from: tabrisnet
Repo: armbian/build PR: 8661
File: lib/functions/compilation/armbian-kernel.sh:194-199
Timestamp: 2025-09-25T18:37:00.330Z
Learning: In PR armbian/build#8661, line 235 of lib/functions/compilation/armbian-kernel.sh already contains the corrected comment "BPF link support for netfilter hooks" for NETFILTER_BPF_LINK, not the misleading "BPF_SYSCALL" comment that was flagged during review.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-07-21T04:12:02.439Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-07-21T04:12:02.439Z
Learning: In the Armbian build system, for recurring maintenance tasks like kernel version bumping, TODO comments should use generic version formats (e.g., "MAJOR.MINOR-rc1") rather than specific version numbers (e.g., "6.17-rc1") to avoid the need for frequent comment updates that would create unnecessary maintenance overhead.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-07-23T10:01:41.310Z
Learnt from: amazingfate
Repo: armbian/build PR: 8419
File: lib/functions/host/prepare-host.sh:272-275
Timestamp: 2025-07-23T10:01:41.310Z
Learning: In the Armbian build system, the design philosophy is to fail fast when host dependencies are not met rather than gracefully skipping unsupported architectures. This ensures build environment consistency and prevents silent failures. Host dependency checks should be explicit and non-negotiable.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
🔇 Additional comments (2)
packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist (1)

1-8: LGTM! Configuration defaults are appropriate.

The default configuration values are well-suited for low-memory boards:

  • 256MB swapfile provides adequate swap space for boards with 64-128MB RAM
  • /swapfile location follows standard conventions
  • Comments clearly explain the purpose and fields
packages/bsp/armbian-lowmem/lowmem-mkswap.service (1)

1-14: LGTM! Systemd unit is correctly configured.

The service unit is well-designed for early-boot swapfile creation:

  • Dependency chain ensures filesystem resize completes before swapfile creation
  • Before=basic.target guarantees swap availability early in the boot process
  • Wants= provides graceful handling if resize service is absent
  • RemainAfterExit=yes with Type=oneshot is appropriate for this setup task

Previous review issues have been addressed (ExecStart path corrected, Wants= dependency added). The default systemd timeout is sufficient based on empirical testing noted in PR discussions.


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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f2c9081 and 16578a9.

📒 Files selected for processing (3)
  • extensions/lowmem.sh (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
extensions/lowmem.sh (3)
.github/generate_CODEOWNERS.sh (1)
  • display_alert (6-6)
lib/functions/logging/runners.sh (1)
  • chroot_sdcard (133-136)
lib/functions/rootfs/trap-rootfs.sh (1)
  • prepare_rootfs_build_params_and_trap (12-51)
packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1)
lib/functions/bsp/armbian-bsp-cli-deb.sh (2)
  • board_side_bsp_cli_preinst (360-415)
  • board_side_bsp_cli_postinst_base (425-446)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Shell script analysis
🔇 Additional comments (9)
packages/bsp/armbian-lowmem/lowmem-mkswap.sh (3)

1-2: LGTM!

Strict error handling with set -euo pipefail is appropriate for a first-boot critical script.


4-13: LGTM!

The safety check prevents overwriting an existing swapfile, which complements the systemd ConditionPathExists in the service unit.


15-21: LGTM!

The free space check with 64MiB headroom provides reasonable safety margin before attempting swapfile creation.

packages/bsp/armbian-lowmem/lowmem-mkswap.service (2)

1-6: LGTM!

The unit dependencies and ordering are correct: runs after filesystem resize, before basic.target, and only when swapfile doesn't exist.


13-14: LGTM!

The install target basic.target is correct for this early-boot service.

extensions/lowmem.sh (4)

1-10: LGTM!

Clear documentation of the extension's purpose and scope.


11-21: Installation paths are correct; verify service file matches.

The extension correctly installs the script as /usr/bin/lowmem-mkswap.sh, but the service file content references /usr/bin/rv1106-firstboot-makeswap.sh. Ensure the service file is updated to match (see comment on lowmem-mkswap.service line 10).


23-30: LGTM!

The service enablement using chroot_sdcard is correct for the build process.


32-51: Sed patterns verified and function implementation is correct.

The regex patterns correctly handle the default Armbian configuration files:

  • Line 35: s/^ENABLED=.*/ENABLED=false/ correctly replaces ENABLED=true in armbian-ramlog config
  • Line 38: s/^#\?\s*SWAP=.*/SWAP=false/ correctly uncomments and sets # SWAP=false to SWAP=false in armbian-zram-config
  • Line 44: The fstab grep check appropriately prevents duplicate /run tmpfs entries

All memory optimization settings are applied correctly for low-memory devices.

@EvilOlaf
Copy link
Member

have you considered installing dropbear with this extension instead of openssh? should save a few megabytes of memory.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/bsp/armbian-lowmem/lowmem-mkswap.service (1)

10-10: Script name mismatch — service will fail to execute.

The ExecStart path references /usr/bin/lowmem-makeswap.sh, but the extension (extensions/lowmem.sh line 17) installs the script as /usr/bin/lowmem-mkswap.sh. The service will fail because the referenced script does not exist.

Apply this diff:

-ExecStart=/usr/bin/lowmem-makeswap.sh
+ExecStart=/usr/bin/lowmem-mkswap.sh
🧹 Nitpick comments (3)
extensions/lowmem.sh (3)

17-18: Quote variables and use consistent installation commands.

Variables like $SRC and $destination should be quoted to handle paths with spaces safely. Additionally, line 18 uses cp while line 17 uses install — prefer install throughout for explicit permission and ownership control.

Apply this diff:

-    install -m 755 $SRC/packages/bsp/armbian-lowmem/${service_name}.sh $destination/usr/bin/${service_name}.sh
-    cp $SRC/packages/bsp/armbian-lowmem/${service_name}.service $destination/lib/systemd/system/${service_name}.service
+    install -m 755 "${SRC}/packages/bsp/armbian-lowmem/${service_name}.sh" "${destination}/usr/bin/${service_name}.sh"
+    install -m 644 "${SRC}/packages/bsp/armbian-lowmem/${service_name}.service" "${destination}/lib/systemd/system/${service_name}.service"

35-35: Inconsistent path quoting.

The path uses both quoted and unquoted segments: "${MOUNT}"/etc/default/armbian-ramlog. While this works, it's clearer to quote the entire path consistently.

Apply this diff for consistency:

-    sed -i "s/^ENABLED=.*/ENABLED=false/" "${MOUNT}"/etc/default/armbian-ramlog
+    sed -i "s/^ENABLED=.*/ENABLED=false/" "${MOUNT}/etc/default/armbian-ramlog"

35-38: Consider adding defensive checks for configuration files.

The sed commands assume the target files exist and contain the expected patterns. While this follows existing project patterns (see lib/functions/bsp/armbian-bsp-cli-deb.sh lines 408, 434-436), adding file existence checks would make the script more robust.

Example approach:

if [[ -f "${MOUNT}/etc/default/armbian-ramlog" ]]; then
    sed -i "s/^ENABLED=.*/ENABLED=false/" "${MOUNT}/etc/default/armbian-ramlog"
fi

if [[ -f "${MOUNT}/etc/default/armbian-zram-config" ]]; then
    sed -i "s/^#\?\s*SWAP=.*/SWAP=false/" "${MOUNT}/etc/default/armbian-zram-config"
fi
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 16578a9 and 0721f22.

📒 Files selected for processing (3)
  • extensions/lowmem.sh (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
🧰 Additional context used
🧬 Code graph analysis (2)
extensions/lowmem.sh (3)
.github/generate_CODEOWNERS.sh (1)
  • display_alert (6-6)
lib/functions/logging/runners.sh (1)
  • chroot_sdcard (133-136)
lib/functions/rootfs/trap-rootfs.sh (1)
  • prepare_rootfs_build_params_and_trap (12-51)
packages/bsp/armbian-lowmem/lowmem-mkswap.service (1)
lib/functions/bsp/armbian-bsp-cli-deb.sh (4)
  • board_side_bsp_cli_preinst (360-415)
  • board_side_bsp_cli_postinst_finish (448-471)
  • board_side_bsp_cli_postinst_base (425-446)
  • board_side_bsp_cli_postrm (417-423)
🔇 Additional comments (1)
extensions/lowmem.sh (1)

23-30: LGTM!

The function properly uses chroot_sdcard to enable the service, and variables are correctly quoted.

@vidplace7
Copy link
Member Author

have you considered installing dropbear with this extension instead of openssh? should save a few megabytes of memory.

That's certainly interesting, given the memory limitations we're working with here.

Are you planning to PR your slimmer branch/extension soon?
Would be nice not to reinvent the wheel here if you're working on similar goals.

@vidplace7 vidplace7 requested a review from amazingfate October 28, 2025 22:06
@EvilOlaf
Copy link
Member

Are you planning to PR your slimmer branch/extension soon?

No, probably not. If you want to adopt that partially or in full, feel free to go ahead.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
extensions/lowmem.sh (1)

1-1: Consider removing the shebang per Armbian conventions.

Extension scripts in the extensions/ directory are sourced by the build framework rather than executed directly, so the shebang line is unnecessary. While harmless, removing it would align with Armbian project conventions for extension files.

Apply this diff:

-#!/usr/bin/env bash
-
 #
 # Armbian Optimizations for Low-Memory Boards

Based on learnings

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0721f22 and f76336a.

📒 Files selected for processing (4)
  • extensions/lowmem.sh (1 hunks)
  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
🧰 Additional context used
🧠 Learnings (16)
📓 Common learnings
Learnt from: EvilOlaf
PR: armbian/build#8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.
Learnt from: amazingfate
PR: armbian/build#8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.
Learnt from: amazingfate
PR: armbian/build#8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.
Learnt from: leggewie
PR: armbian/build#8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.
📚 Learning: 2025-09-14T06:19:06.828Z
Learnt from: amazingfate
PR: armbian/build#8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-10-24T04:46:22.901Z
Learnt from: tabrisnet
PR: armbian/build#0
File: :0-0
Timestamp: 2025-10-24T04:46:22.901Z
Learning: In lib/functions/rootfs/rootfs-create.sh, the FIXME comment about mmdebstrap usage with --aptopt is a future note related to PR #8785, which hasn't been merged yet.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
📚 Learning: 2025-09-18T03:36:17.862Z
Learnt from: EvilOlaf
PR: armbian/build#8537
File: config/boards/qcom-robotics-rb5.conf:1-1
Timestamp: 2025-09-18T03:36:17.862Z
Learning: In Armbian board configuration files (regardless of file extension), the standard pattern is to have only one line as a comment describing the board hardware specifications. This single-line description typically includes the SoC model, core count, RAM options, and key features like connectivity options, storage interfaces, and special features. The file extensions indicate board support status: .conf (standard support), .csc (community supported), .eos (end of support), .tvb (tvbox), .wip (work in progress).

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • extensions/lowmem.sh
📚 Learning: 2025-08-30T04:13:16.457Z
Learnt from: tabrisnet
PR: armbian/build#0
File: :0-0
Timestamp: 2025-08-30T04:13:16.457Z
Learning: Armbian kernel configuration files like linux-filogic-current.config are autogenerated overlays on top of arch defconfig. Comments added manually will be lost during future updates by maintainers, and explicit "CONFIG_OPTION is not set" statements aren't needed for mutually exclusive options since these are overlay configs that only specify changes from the base configuration.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-07-17T04:12:33.125Z
Learnt from: pyavitz
PR: armbian/build#8388
File: config/boards/kickpik2b.conf:1-14
Timestamp: 2025-07-17T04:12:33.125Z
Learning: In the Armbian build system, board configuration files (*.conf) follow a project standard of not including shebang lines, even though they contain bash code and are sourced by the build system. This is an established Armbian convention that individual contributors are expected to follow, and changes to this standard would require broader project maintainer approval.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • extensions/lowmem.sh
📚 Learning: 2025-09-27T21:50:15.915Z
Learnt from: tabrisnet
PR: armbian/build#8678
File: config/kernel/linux-sunxi64-current.config:94-94
Timestamp: 2025-09-27T21:50:15.915Z
Learning: When kernel config files are generated through Armbian's automated process (previous config → armbian-kernel.sh changes → make oldconfig → Armbian machinery processing), manual config file edits are not appropriate since they would be overwritten. Deprecated option handling should be implemented in the automated tooling instead.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • extensions/lowmem.sh
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • extensions/lowmem.sh
📚 Learning: 2025-09-18T03:36:17.862Z
Learnt from: EvilOlaf
PR: armbian/build#8537
File: config/boards/qcom-robotics-rb5.conf:1-1
Timestamp: 2025-09-18T03:36:17.862Z
Learning: In Armbian board configuration files, .wip and .conf extensions require BOARD_MAINTAINER to be present and contain at least one maintainer. If no maintainer is present, the board support rules state it does not qualify for standard support and must be moved to community support (.csc extension). This is documented at https://docs.armbian.com/User-Guide_Board-Support-Rules/

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-04-28T08:27:26.890Z
Learnt from: leggewie
PR: armbian/build#8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-07-27T15:53:30.629Z
Learnt from: pyavitz
PR: armbian/build#8421
File: config/kernel/linux-sunxi64-edge.config:805-825
Timestamp: 2025-07-27T15:53:30.629Z
Learning: In the Armbian build system, kernel configurations prioritize broad hardware compatibility over optimization concerns. Even when including numerous legacy/obsolete drivers causes technical issues like increased initramfs size and slower enumeration, the project philosophy is to "appease the masses" by ensuring maximum device compatibility rather than optimizing for specific use cases.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-08-03T15:21:20.148Z
Learnt from: pyavitz
PR: armbian/build#8455
File: config/sources/families/sun50iw1.conf:19-24
Timestamp: 2025-08-03T15:21:20.148Z
Learning: In the Armbian build system, when copying firmware files during family_tweaks_s(), use /lib/firmware/updates/ instead of /lib/firmware/ to avoid conflicts with the Armbian firmware package. The /lib/firmware/updates directory takes precedence in Linux firmware loading hierarchy and is the proper location for user-installed firmware files.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-24T09:54:07.968Z
Learnt from: amazingfate
PR: armbian/build#8668
File: extensions/ufs.sh:2-2
Timestamp: 2025-09-24T09:54:07.968Z
Learning: In Armbian's build system, DOCKER_ARMBIAN_BASE_IMAGE must be set globally at file load time in extensions, not inside extension_prepare_config functions, because docker operations happen early in the build process and would default to ubuntu:noble if not set before docker_cli_prepare() runs.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-07T17:39:32.272Z
Learnt from: EvilOlaf
PR: armbian/build#8586
File: config/boards/nanopi-r76s.conf:15-21
Timestamp: 2025-09-07T17:39:32.272Z
Learning: In the Armbian build system, the variables $BOARD and $SDCARD are always set by the build framework, so guard checks for these variables are unnecessary in board configuration files and hook functions.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-05-16T15:34:34.672Z
Learnt from: Grippy98
PR: armbian/build#8202
File: config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh:2-3
Timestamp: 2025-05-16T15:34:34.672Z
Learning: The shell scripts in the Armbian build system's desktop configuration files, such as config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh, rely on environment variables like $SRC and $destination that are expected to be set externally before the script is executed.

Applied to files:

  • extensions/lowmem.sh
🧬 Code graph analysis (2)
packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1)
lib/functions/bsp/armbian-bsp-cli-deb.sh (2)
  • board_side_bsp_cli_preinst (360-415)
  • board_side_bsp_cli_postinst_base (425-446)
extensions/lowmem.sh (3)
.github/generate_CODEOWNERS.sh (1)
  • display_alert (6-6)
lib/functions/logging/runners.sh (1)
  • chroot_sdcard (133-136)
lib/functions/bsp/armbian-bsp-cli-deb.sh (1)
  • board_side_bsp_cli_postinst_finish (448-471)
🔇 Additional comments (7)
packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist (1)

1-8: LGTM! Configuration defaults are appropriate.

The configuration file provides sensible defaults for low-memory boards (256 MiB swapfile at /swapfile) and addresses the configurability requirements raised in previous reviews. Users can edit this file to customize the swapfile size and location based on their specific hardware (e.g., choosing between microSD and eMMC).

packages/bsp/armbian-lowmem/lowmem-mkswap.sh (3)

1-7: LGTM! Configuration override mechanism works correctly.

The script provides sensible defaults while allowing users to override both swapfile location and size via /etc/default/armbian-lowmem. This addresses the configurability requirements for boards with different storage configurations (microSD vs eMMC).


9-24: LGTM! Safety checks are thorough and correct.

The script properly guards against overwriting existing swapfiles and ensures sufficient free space (swapfile size + 64 MiB headroom) before creating the swapfile. The use of dirname on line 18 to obtain the parent directory for the df check is correct.


26-39: LGTM! Swapfile creation and service cleanup are correct.

The script correctly creates the swapfile with secure permissions (600), initializes it with mkswap, adds an appropriate fstab entry (without the discard option, addressing previous review feedback), and enables the swap. The service properly disables and masks itself after successful execution to prevent repeated runs.

extensions/lowmem.sh (3)

11-21: LGTM! Configuration installation is idempotent.

The function correctly copies the default configuration file only when it doesn't already exist, ensuring idempotent behavior during repeated builds.


35-42: LGTM! Service enablement uses the correct framework function.

The function properly uses chroot_sdcard to enable the service within the target image's systemd environment.


44-64: LGTM! Memory optimizations are well-designed and configurable.

The function appropriately:

  • Disables ramlog to reduce memory overhead
  • Disables zram swap (aligning with the PR's objective to favor zswap for low-memory boards)
  • Sets a fixed /run tmpfs size (default 20M, configurable via LOWMEM_TMPFS_RUN_MB environment variable) to prevent systemd daemon-reload errors on systems where the default 10% of RAM would be insufficient
  • Implements idempotent fstab modifications

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/bsp/armbian-lowmem/lowmem-mkswap.service (2)

4-4: Consider adding explicit dependency on armbian-resize-filesystem.service.

Currently, After= ensures ordering but doesn't create a dependency. If armbian-resize-filesystem.service fails or is disabled, this service will still run, potentially creating the swapfile before the filesystem is properly resized.

Consider applying this diff:

 DefaultDependencies=no
+Wants=armbian-resize-filesystem.service
 After=armbian-resize-filesystem.service

This ensures the resize service is pulled in when this service is enabled, improving robustness while maintaining the correct boot order.


7-10: Consider adding a timeout for boot reliability.

The service creates a 256MB swapfile, which may take time on slow storage. Without an explicit timeout, the default (typically 90s) applies. If swapfile creation hangs or exceeds the timeout, the boot will be delayed or fail.

Consider applying this diff to add a reasonable timeout:

 [Service]
 Type=oneshot
 ExecStart=/usr/bin/lowmem-mkswap.sh
+TimeoutStartSec=180
 RemainAfterExit=yes

A 3-minute timeout provides sufficient time for slow embedded storage while preventing indefinite boot hangs. Adjust the value based on testing with target hardware.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f76336a and 327d1fb.

📒 Files selected for processing (4)
  • extensions/lowmem.sh (1 hunks)
  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • extensions/lowmem.sh
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: EvilOlaf
PR: armbian/build#8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.
Learnt from: amazingfate
PR: armbian/build#8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.
Learnt from: amazingfate
PR: armbian/build#8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.
Learnt from: EvilOlaf
PR: armbian/build#8537
File: config/boards/qcom-robotics-rb5.conf:1-1
Timestamp: 2025-09-18T03:36:17.862Z
Learning: In Armbian board configuration files (regardless of file extension), the standard pattern is to have only one line as a comment describing the board hardware specifications. This single-line description typically includes the SoC model, core count, RAM options, and key features like connectivity options, storage interfaces, and special features. The file extensions indicate board support status: .conf (standard support), .csc (community supported), .eos (end of support), .tvb (tvbox), .wip (work in progress).
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.
Learnt from: leggewie
PR: armbian/build#8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.
📚 Learning: 2025-09-14T06:19:06.828Z
Learnt from: amazingfate
PR: armbian/build#8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-04-28T08:27:26.890Z
Learnt from: leggewie
PR: armbian/build#8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
🧬 Code graph analysis (1)
packages/bsp/armbian-lowmem/lowmem-mkswap.service (2)
lib/functions/bsp/armbian-bsp-cli-deb.sh (2)
  • board_side_bsp_cli_postinst_finish (448-471)
  • board_side_bsp_cli_postrm (417-423)
extensions/armbian-live-patch.sh (1)
  • post_family_tweaks_bsp__armbian-live-patch (1-97)
🔇 Additional comments (1)
packages/bsp/armbian-lowmem/lowmem-mkswap.service (1)

1-13: Service structure looks correct for first-boot swap setup.

The systemd unit follows appropriate patterns:

  • Type=oneshot with RemainAfterExit=yes for one-time setup
  • Before=basic.target ensures swap is available early (aligns with PR objectives)
  • After=armbian-resize-filesystem.service ensures proper filesystem state
  • WantedBy=basic.target for correct installation point

The fixed ExecStart path matches the installation location from the extension. The self-masking behavior (mentioned in past review comments) handles the first-boot-only requirement.

The suggested improvements above (timeout and explicit dependency) would enhance robustness but are not blockers.

@tabrisnet
Copy link
Collaborator

Actionable comments posted: 0
🧹 Nitpick comments (2)

7-10: Consider adding a timeout for boot reliability.
The service creates a 256MB swapfile, which may take time on slow storage. Without an explicit timeout, the default (typically 90s) applies. If swapfile creation hangs or exceeds the timeout, the boot will be delayed or fail.
Consider applying this diff to add a reasonable timeout:

 [Service]
 Type=oneshot
 ExecStart=/usr/bin/lowmem-mkswap.sh
+TimeoutStartSec=180
 RemainAfterExit=yes

@coderabbitai
I am curious what [recent] storage you're thinking of where the storage write speed is less than 2MB/sec.
2MB/sec would be ~2minutes, which is atrocious. Assuming this is authoritative, the slowest speed rating is C2. I don't even know where to buy something slower than U1/C10, which is 10MB/sec.

Further, I think the criticality of this on a low-RAM machine makes failure preferable.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

Tip

For best results, initiate chat on the files or code changes.

@tabrisnet You make excellent points. You're absolutely right that:

  1. Modern storage, even budget SD cards, are typically C10 (10MB/sec) or faster, which would complete the 256MB swapfile creation in well under 30 seconds—far below the default 90s timeout.

  2. C2 cards (2MB/sec) are extremely rare and obsolete in practice, and even those would only take ~128 seconds, barely exceeding the default timeout.

  3. Most importantly, on a low-RAM machine where swap is critical for basic functionality, failing fast is preferable to masking issues with an extended timeout. If the service can't complete in a reasonable time, that's a signal of a serious problem (bad storage, insufficient space, etc.) that should halt boot rather than allow the system to proceed in a degraded state.

Your reasoning is sound—the timeout suggestion isn't necessary here, and the default behavior is appropriate for this use case. Thank you for the thoughtful pushback!


🧠 Learnings used
Learnt from: tabrisnet
PR: armbian/build#0
File: :0-0
Timestamp: 2025-10-24T04:46:22.901Z
Learning: In lib/functions/rootfs/rootfs-create.sh, the FIXME comment about mmdebstrap usage with --aptopt is a future note related to PR #8785, which hasn't been merged yet.

Learnt from: EvilOlaf
PR: armbian/build#8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.

@vidplace7
Copy link
Member Author

vidplace7 commented Oct 30, 2025

Actionable comments posted: 0
🧹 Nitpick comments (2)

7-10: Consider adding a timeout for boot reliability.
The service creates a 256MB swapfile, which may take time on slow storage. Without an explicit timeout, the default (typically 90s) applies. If swapfile creation hangs or exceeds the timeout, the boot will be delayed or fail.
Consider applying this diff to add a reasonable timeout:

 [Service]
 Type=oneshot
 ExecStart=/usr/bin/lowmem-mkswap.sh
+TimeoutStartSec=180
 RemainAfterExit=yes

@coderabbitai I am curious what [recent] storage you're thinking of where the storage write speed is less than 2MB/sec. 2MB/sec would be ~2minutes, which is atrocious. Assuming this is authoritative, the slowest speed rating is C2. I don't even know where to buy something slower than U1/C10, which is 10MB/sec.

Further, I think the criticality of this on a low-RAM machine makes failure preferable.

For what it's worth. This oneshot script typically finishes in about 5 seconds 😅 on RV1103 (and my microSD card is nothing fancy) the default 90 should be plenty I agree.

I suppose this could fail if the user decided to increase SWAPFILE_SIZE_MB to a very large (multiple GBs) number... I'm fine with systemd punishing you for that 🤣

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

Tip

For best results, initiate chat on the files or code changes.

@vidplace7 Perfect! 5 seconds is excellent, and that real-world data confirms the default 90s timeout is more than sufficient. I agree with your assessment—and yes, if someone cranks that swapfile up to multiple GBs on slow storage, a timeout failure is indeed the appropriate consequence. 😄

The current configuration is sound as-is. Thank you for the empirical confirmation!


🧠 Learnings used
Learnt from: tabrisnet
PR: armbian/build#0
File: :0-0
Timestamp: 2025-10-24T04:46:22.901Z
Learning: In lib/functions/rootfs/rootfs-create.sh, the FIXME comment about mmdebstrap usage with --aptopt is a future note related to PR #8785, which hasn't been merged yet.

Learnt from: EvilOlaf
PR: armbian/build#8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

Tip

For best results, initiate chat on the files or code changes.

@vidplace7 Thanks for the real-world data point! 5 seconds on actual hardware confirms the default timeout is more than adequate. And I completely agree with your philosophy on the edge case—if someone cranks the swapfile to multiple GBs on a low-RAM board, a systemd timeout is the least of their worries. 😄

The original suggestion to add TimeoutStartSec=180 isn't needed given the practical performance and the fail-fast-is-better principle for this critical service.

🐰✨


🧠 Learnings used
Learnt from: tabrisnet
PR: armbian/build#0
File: :0-0
Timestamp: 2025-10-24T04:46:22.901Z
Learning: In lib/functions/rootfs/rootfs-create.sh, the FIXME comment about mmdebstrap usage with --aptopt is a future note related to PR #8785, which hasn't been merged yet.

Learnt from: EvilOlaf
PR: armbian/build#8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

Tip

For best results, initiate chat on the files or code changes.

@vidplace7 Perfect! That 5-second real-world measurement is exactly the kind of data that confirms the default timeout is more than adequate. Thanks for providing the empirical evidence—much appreciated!

And yes, I completely agree with your philosophy on the edge case. If someone configures a multi-GB swapfile on a low-RAM board, the systemd timeout is indeed the appropriate feedback mechanism. 😄


🧠 Learnings used
Learnt from: tabrisnet
PR: armbian/build#0
File: :0-0
Timestamp: 2025-10-24T04:46:22.901Z
Learning: In lib/functions/rootfs/rootfs-create.sh, the FIXME comment about mmdebstrap usage with --aptopt is a future note related to PR #8785, which hasn't been merged yet.

@coderabbitai coderabbitai bot requested a review from EvilOlaf October 30, 2025 15:52
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
extensions/lowmem.sh (1)

1-1: Remove unnecessary shebang for consistency.

Extension scripts in the Armbian build system are sourced, not executed directly, so the shebang is unnecessary. As per established convention, remove this line.

-#!/usr/bin/env bash
-
 #

Based on learnings from project conventions for extension scripts.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 327d1fb and a375b12.

📒 Files selected for processing (4)
  • extensions/lowmem.sh (1 hunks)
  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
🧰 Additional context used
🧠 Learnings (22)
📓 Common learnings
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.
Learnt from: amazingfate
PR: armbian/build#8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.
Learnt from: amazingfate
PR: armbian/build#8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.
Learnt from: EvilOlaf
PR: armbian/build#8537
File: config/boards/qcom-robotics-rb5.conf:1-1
Timestamp: 2025-09-18T03:36:17.862Z
Learning: In Armbian board configuration files (regardless of file extension), the standard pattern is to have only one line as a comment describing the board hardware specifications. This single-line description typically includes the SoC model, core count, RAM options, and key features like connectivity options, storage interfaces, and special features. The file extensions indicate board support status: .conf (standard support), .csc (community supported), .eos (end of support), .tvb (tvbox), .wip (work in progress).
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.
Learnt from: leggewie
PR: armbian/build#8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-04-28T08:27:26.890Z
Learnt from: leggewie
PR: armbian/build#8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-22T21:59:36.334Z
Learnt from: tabrisnet
PR: armbian/build#8661
File: lib/functions/compilation/armbian-kernel.sh:200-200
Timestamp: 2025-09-22T21:59:36.334Z
Learning: Functions named with the pattern `armbian_kernel_config__*` in lib/functions/compilation/armbian-kernel.sh are automatically discovered and invoked by Armbian's extension system via metaprogramming using `compgen -A function`, without requiring explicit registration or calls.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-05-16T15:34:34.672Z
Learnt from: Grippy98
PR: armbian/build#8202
File: config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh:2-3
Timestamp: 2025-05-16T15:34:34.672Z
Learning: The shell scripts in the Armbian build system's desktop configuration files, such as config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh, rely on environment variables like $SRC and $destination that are expected to be set externally before the script is executed.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-05-29T01:52:21.381Z
Learnt from: djurny
PR: armbian/build#8235
File: packages/bsp/mvebu/helios4/helios4-wol.service:0-0
Timestamp: 2025-05-29T01:52:21.381Z
Learning: In systemd service ExecStart commands, shell variables like ${INTF} can cause issues because systemd may resolve them before the shell processes them, leading to "no device matches name" errors. Using xargs with -I{} is a more reliable approach for iterating over dynamic lists in systemd services, as it avoids variable substitution problems entirely.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-08-14T17:19:39.693Z
Learnt from: leggewie
PR: armbian/build#8502
File: config/desktop/trixie/environments/i3-wm/config_base/packages:44-44
Timestamp: 2025-08-14T17:19:39.693Z
Learning: When a PR author provides clear context about package transitions in the commit message and the changes are scoped to specific release pockets, focus the review on validating those specific changes rather than suggesting broader investigations across other releases or additional dependency verifications.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-07-25T03:51:50.830Z
Learnt from: EvilOlaf
PR: armbian/build#8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub API (https://api.github.com/repos/armbian/build/pulls/{pr_number}/files) to get the complete picture of what files are being added or modified, especially for U-Boot patches that will be applied during the build process.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-13T19:51:14.713Z
Learnt from: pyavitz
PR: armbian/build#8631
File: config/boards/khadas-vim4.conf:42-42
Timestamp: 2025-09-13T19:51:14.713Z
Learning: In the Armbian build system, run_host_command_logged properly handles shell redirection operators like ">>" when passed as string arguments. This pattern is used consistently throughout the codebase, such as in lib/functions/rootfs/distro-agnostic.sh where it's used to append to armbianEnv.txt files. The function has been tested and confirmed to work correctly with this syntax.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-25T18:37:00.330Z
Learnt from: tabrisnet
PR: armbian/build#8661
File: lib/functions/compilation/armbian-kernel.sh:194-199
Timestamp: 2025-09-25T18:37:00.330Z
Learning: In PR armbian/build#8661, line 235 of lib/functions/compilation/armbian-kernel.sh already contains the corrected comment "BPF link support for netfilter hooks" for NETFILTER_BPF_LINK, not the misleading "BPF_SYSCALL" comment that was flagged during review.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-07-25T03:51:50.830Z
Learnt from: EvilOlaf
PR: armbian/build#8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-08-29T18:44:47.732Z
Learnt from: leggewie
PR: armbian/build#0
File: :0-0
Timestamp: 2025-08-29T18:44:47.732Z
Learning: When creating GitHub issues for code improvements in the Armbian build project, include the relevant patches/diffs in the issue description or open a PR directly instead of just describing the changes. This makes it more efficient for the assignee to handle the improvements.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-11T04:34:05.589Z
Learnt from: tabrisnet
PR: armbian/build#0
File: :0-0
Timestamp: 2025-09-11T04:34:05.589Z
Learning: When users identify architectural issues during code review, they may prefer to split them into separate issues rather than expanding the scope of the current PR. This allows for focused fixes while ensuring broader problems get proper tracking and discussion.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-10-24T04:46:22.901Z
Learnt from: tabrisnet
PR: armbian/build#0
File: :0-0
Timestamp: 2025-10-24T04:46:22.901Z
Learning: In lib/functions/rootfs/rootfs-create.sh, the FIXME comment about mmdebstrap usage with --aptopt is a future note related to PR #8785, which hasn't been merged yet.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-05-07T20:49:40.969Z
Learnt from: djurny
PR: armbian/build#8166
File: config/bootscripts/boot-mvebu.cmd:38-50
Timestamp: 2025-05-07T20:49:40.969Z
Learning: The 4KB (0x1000) boundary used for device tree size calculations in U-Boot scripts is specific to how the `fdt resize` command works internally and should remain hardcoded rather than being tied to adjustable alignment variables.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-07-27T15:53:30.629Z
Learnt from: pyavitz
PR: armbian/build#8421
File: config/kernel/linux-sunxi64-edge.config:805-825
Timestamp: 2025-07-27T15:53:30.629Z
Learning: In the Armbian build system, kernel configurations prioritize broad hardware compatibility over optimization concerns. Even when including numerous legacy/obsolete drivers causes technical issues like increased initramfs size and slower enumeration, the project philosophy is to "appease the masses" by ensuring maximum device compatibility rather than optimizing for specific use cases.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-18T03:36:17.862Z
Learnt from: EvilOlaf
PR: armbian/build#8537
File: config/boards/qcom-robotics-rb5.conf:1-1
Timestamp: 2025-09-18T03:36:17.862Z
Learning: In Armbian board configuration files (regardless of file extension), the standard pattern is to have only one line as a comment describing the board hardware specifications. This single-line description typically includes the SoC model, core count, RAM options, and key features like connectivity options, storage interfaces, and special features. The file extensions indicate board support status: .conf (standard support), .csc (community supported), .eos (end of support), .tvb (tvbox), .wip (work in progress).

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-24T09:54:07.968Z
Learnt from: amazingfate
PR: armbian/build#8668
File: extensions/ufs.sh:2-2
Timestamp: 2025-09-24T09:54:07.968Z
Learning: In Armbian's build system, DOCKER_ARMBIAN_BASE_IMAGE must be set globally at file load time in extensions, not inside extension_prepare_config functions, because docker operations happen early in the build process and would default to ubuntu:noble if not set before docker_cli_prepare() runs.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-08-03T15:21:20.148Z
Learnt from: pyavitz
PR: armbian/build#8455
File: config/sources/families/sun50iw1.conf:19-24
Timestamp: 2025-08-03T15:21:20.148Z
Learning: In the Armbian build system, when copying firmware files during family_tweaks_s(), use /lib/firmware/updates/ instead of /lib/firmware/ to avoid conflicts with the Armbian firmware package. The /lib/firmware/updates directory takes precedence in Linux firmware loading hierarchy and is the proper location for user-installed firmware files.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-07-17T04:12:33.125Z
Learnt from: pyavitz
PR: armbian/build#8388
File: config/boards/kickpik2b.conf:1-14
Timestamp: 2025-07-17T04:12:33.125Z
Learning: In the Armbian build system, board configuration files (*.conf) follow a project standard of not including shebang lines, even though they contain bash code and are sourced by the build system. This is an established Armbian convention that individual contributors are expected to follow, and changes to this standard would require broader project maintainer approval.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-07T17:39:32.272Z
Learnt from: EvilOlaf
PR: armbian/build#8586
File: config/boards/nanopi-r76s.conf:15-21
Timestamp: 2025-09-07T17:39:32.272Z
Learning: In the Armbian build system, the variables $BOARD and $SDCARD are always set by the build framework, so guard checks for these variables are unnecessary in board configuration files and hook functions.

Applied to files:

  • extensions/lowmem.sh
🧬 Code graph analysis (1)
extensions/lowmem.sh (4)
.github/generate_CODEOWNERS.sh (1)
  • display_alert (6-6)
lib/functions/logging/runners.sh (1)
  • chroot_sdcard (133-136)
lib/functions/bsp/armbian-bsp-cli-deb.sh (2)
  • board_side_bsp_cli_postinst_base (425-446)
  • board_side_bsp_cli_postinst_finish (448-471)
lib/functions/rootfs/post-tweaks.sh (1)
  • post_debootstrap_tweaks (10-34)
🔇 Additional comments (2)
extensions/lowmem.sh (2)

11-21: Verify file permissions for user-customizable config file.

The config file is installed with mode 664 (rw-rw-r--), which grants group write access. Most /etc/default files in Armbian use 644 (rw-r--r--) to prevent accidental group modifications. Confirm whether group write access is intentional for armbian-lowmem.

If group write is not needed:

-	install -m 664 "$SRC/packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist" "$destination/etc/default/armbian-lowmem"
+	install -m 644 "$SRC/packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist" "$destination/etc/default/armbian-lowmem"

44-64: Solid structure and idempotent design.

The memory optimization function correctly:

  • Sets a configurable default for /run tmpfs size (line 45)
  • Handles sed replacements safely (lines 48, 51)
  • Checks for existing /run entry before appending to fstab, preventing duplicates (line 57)
  • Uses a robust POSIX-compliant regex with [[:space:]]+ to handle multiple spaces/tabs in fstab

The overall extension properly integrates with the Armbian framework (hook naming, chroot_sdcard, framework variables). 🎉

@vidplace7 vidplace7 force-pushed the lowmem-extension branch 2 times, most recently from 255c770 to 2099fbc Compare November 2, 2025 22:04
@coderabbitai coderabbitai bot requested a review from igorpecovnik November 2, 2025 22:05
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 255c770 and 2099fbc.

📒 Files selected for processing (4)
  • extensions/lowmem.sh (1 hunks)
  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
🧰 Additional context used
🧠 Learnings (25)
📓 Common learnings
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.
Learnt from: amazingfate
Repo: armbian/build PR: 8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.
Learnt from: amazingfate
Repo: armbian/build PR: 8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8537
File: config/boards/qcom-robotics-rb5.conf:1-1
Timestamp: 2025-09-18T03:36:17.862Z
Learning: In Armbian board configuration files (regardless of file extension), the standard pattern is to have only one line as a comment describing the board hardware specifications. This single-line description typically includes the SoC model, core count, RAM options, and key features like connectivity options, storage interfaces, and special features. The file extensions indicate board support status: .conf (standard support), .csc (community supported), .eos (end of support), .tvb (tvbox), .wip (work in progress).
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.
Learnt from: leggewie
Repo: armbian/build PR: 8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.
📚 Learning: 2025-09-18T03:36:17.862Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8537
File: config/boards/qcom-robotics-rb5.conf:1-1
Timestamp: 2025-09-18T03:36:17.862Z
Learning: In Armbian board configuration files (regardless of file extension), the standard pattern is to have only one line as a comment describing the board hardware specifications. This single-line description typically includes the SoC model, core count, RAM options, and key features like connectivity options, storage interfaces, and special features. The file extensions indicate board support status: .conf (standard support), .csc (community supported), .eos (end of support), .tvb (tvbox), .wip (work in progress).

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • extensions/lowmem.sh
📚 Learning: 2025-08-30T04:13:16.457Z
Learnt from: tabrisnet
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-08-30T04:13:16.457Z
Learning: Armbian kernel configuration files like linux-filogic-current.config are autogenerated overlays on top of arch defconfig. Comments added manually will be lost during future updates by maintainers, and explicit "CONFIG_OPTION is not set" statements aren't needed for mutually exclusive options since these are overlay configs that only specify changes from the base configuration.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
📚 Learning: 2025-07-17T04:12:33.125Z
Learnt from: pyavitz
Repo: armbian/build PR: 8388
File: config/boards/kickpik2b.conf:1-14
Timestamp: 2025-07-17T04:12:33.125Z
Learning: In the Armbian build system, board configuration files (*.conf) follow a project standard of not including shebang lines, even though they contain bash code and are sourced by the build system. This is an established Armbian convention that individual contributors are expected to follow, and changes to this standard would require broader project maintainer approval.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • extensions/lowmem.sh
📚 Learning: 2025-09-14T06:19:06.828Z
Learnt from: amazingfate
Repo: armbian/build PR: 8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
📚 Learning: 2025-11-02T20:49:56.697Z
Learnt from: igorpecovnik
Repo: armbian/build PR: 8849
File: config/boards/radxa-e54c.csc:14-28
Timestamp: 2025-11-02T20:49:56.697Z
Learning: In Armbian board configuration files (config/boards/*.conf, *.csc, etc.), do not use kernel_config_set, kernel_config_set_m, kernel_config_set_y, or custom_kernel_config__* functions to modify kernel configuration. Kernel configuration is associated with LINUXFAMILY/BOARDFAMILY, not individual BOARD. Board-specific kernel modifications cause inconsistency in kernel packages published to the apt repository because boards within a family share the same kernel packages. Kernel configuration changes must be made in the appropriate kernel config file (e.g., config/kernel/linux-*-*.config) or in family configuration files (config/sources/families/*.conf, *.inc) instead.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • extensions/lowmem.sh
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • extensions/lowmem.sh
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.

Applied to files:

  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
  • extensions/lowmem.sh
📚 Learning: 2025-04-28T08:27:26.890Z
Learnt from: leggewie
Repo: armbian/build PR: 8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-22T21:59:36.334Z
Learnt from: tabrisnet
Repo: armbian/build PR: 8661
File: lib/functions/compilation/armbian-kernel.sh:200-200
Timestamp: 2025-09-22T21:59:36.334Z
Learning: Functions named with the pattern `armbian_kernel_config__*` in lib/functions/compilation/armbian-kernel.sh are automatically discovered and invoked by Armbian's extension system via metaprogramming using `compgen -A function`, without requiring explicit registration or calls.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-05-16T15:34:34.672Z
Learnt from: Grippy98
Repo: armbian/build PR: 8202
File: config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh:2-3
Timestamp: 2025-05-16T15:34:34.672Z
Learning: The shell scripts in the Armbian build system's desktop configuration files, such as config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh, rely on environment variables like $SRC and $destination that are expected to be set externally before the script is executed.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-05-29T01:52:21.381Z
Learnt from: djurny
Repo: armbian/build PR: 8235
File: packages/bsp/mvebu/helios4/helios4-wol.service:0-0
Timestamp: 2025-05-29T01:52:21.381Z
Learning: In systemd service ExecStart commands, shell variables like ${INTF} can cause issues because systemd may resolve them before the shell processes them, leading to "no device matches name" errors. Using xargs with -I{} is a more reliable approach for iterating over dynamic lists in systemd services, as it avoids variable substitution problems entirely.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-08-14T17:19:39.693Z
Learnt from: leggewie
Repo: armbian/build PR: 8502
File: config/desktop/trixie/environments/i3-wm/config_base/packages:44-44
Timestamp: 2025-08-14T17:19:39.693Z
Learning: When a PR author provides clear context about package transitions in the commit message and the changes are scoped to specific release pockets, focus the review on validating those specific changes rather than suggesting broader investigations across other releases or additional dependency verifications.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-07-25T03:51:50.830Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub API (https://api.github.com/repos/armbian/build/pulls/{pr_number}/files) to get the complete picture of what files are being added or modified, especially for U-Boot patches that will be applied during the build process.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-13T19:51:14.713Z
Learnt from: pyavitz
Repo: armbian/build PR: 8631
File: config/boards/khadas-vim4.conf:42-42
Timestamp: 2025-09-13T19:51:14.713Z
Learning: In the Armbian build system, run_host_command_logged properly handles shell redirection operators like ">>" when passed as string arguments. This pattern is used consistently throughout the codebase, such as in lib/functions/rootfs/distro-agnostic.sh where it's used to append to armbianEnv.txt files. The function has been tested and confirmed to work correctly with this syntax.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-25T18:37:00.330Z
Learnt from: tabrisnet
Repo: armbian/build PR: 8661
File: lib/functions/compilation/armbian-kernel.sh:194-199
Timestamp: 2025-09-25T18:37:00.330Z
Learning: In PR armbian/build#8661, line 235 of lib/functions/compilation/armbian-kernel.sh already contains the corrected comment "BPF link support for netfilter hooks" for NETFILTER_BPF_LINK, not the misleading "BPF_SYSCALL" comment that was flagged during review.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-07-25T03:51:50.830Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-08-29T18:44:47.732Z
Learnt from: leggewie
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-08-29T18:44:47.732Z
Learning: When creating GitHub issues for code improvements in the Armbian build project, include the relevant patches/diffs in the issue description or open a PR directly instead of just describing the changes. This makes it more efficient for the assignee to handle the improvements.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-11T04:34:05.589Z
Learnt from: tabrisnet
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-09-11T04:34:05.589Z
Learning: When users identify architectural issues during code review, they may prefer to split them into separate issues rather than expanding the scope of the current PR. This allows for focused fixes while ensuring broader problems get proper tracking and discussion.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-10-24T04:46:22.901Z
Learnt from: tabrisnet
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-10-24T04:46:22.901Z
Learning: In lib/functions/rootfs/rootfs-create.sh, the FIXME comment about mmdebstrap usage with --aptopt is a future note related to PR #8785, which hasn't been merged yet.

Applied to files:

  • extensions/lowmem.sh
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
📚 Learning: 2025-05-07T20:49:40.969Z
Learnt from: djurny
Repo: armbian/build PR: 8166
File: config/bootscripts/boot-mvebu.cmd:38-50
Timestamp: 2025-05-07T20:49:40.969Z
Learning: The 4KB (0x1000) boundary used for device tree size calculations in U-Boot scripts is specific to how the `fdt resize` command works internally and should remain hardcoded rather than being tied to adjustable alignment variables.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-07-27T15:53:30.629Z
Learnt from: pyavitz
Repo: armbian/build PR: 8421
File: config/kernel/linux-sunxi64-edge.config:805-825
Timestamp: 2025-07-27T15:53:30.629Z
Learning: In the Armbian build system, kernel configurations prioritize broad hardware compatibility over optimization concerns. Even when including numerous legacy/obsolete drivers causes technical issues like increased initramfs size and slower enumeration, the project philosophy is to "appease the masses" by ensuring maximum device compatibility rather than optimizing for specific use cases.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-24T09:54:07.968Z
Learnt from: amazingfate
Repo: armbian/build PR: 8668
File: extensions/ufs.sh:2-2
Timestamp: 2025-09-24T09:54:07.968Z
Learning: In Armbian's build system, DOCKER_ARMBIAN_BASE_IMAGE must be set globally at file load time in extensions, not inside extension_prepare_config functions, because docker operations happen early in the build process and would default to ubuntu:noble if not set before docker_cli_prepare() runs.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-08-03T15:21:20.148Z
Learnt from: pyavitz
Repo: armbian/build PR: 8455
File: config/sources/families/sun50iw1.conf:19-24
Timestamp: 2025-08-03T15:21:20.148Z
Learning: In the Armbian build system, when copying firmware files during family_tweaks_s(), use /lib/firmware/updates/ instead of /lib/firmware/ to avoid conflicts with the Armbian firmware package. The /lib/firmware/updates directory takes precedence in Linux firmware loading hierarchy and is the proper location for user-installed firmware files.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-07T17:39:32.272Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8586
File: config/boards/nanopi-r76s.conf:15-21
Timestamp: 2025-09-07T17:39:32.272Z
Learning: In the Armbian build system, the variables $BOARD and $SDCARD are always set by the build framework, so guard checks for these variables are unnecessary in board configuration files and hook functions.

Applied to files:

  • extensions/lowmem.sh
🧬 Code graph analysis (3)
packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist (1)
lib/functions/bsp/armbian-bsp-cli-deb.sh (2)
  • board_side_bsp_cli_preinst (360-415)
  • board_side_bsp_cli_postinst_finish (448-471)
extensions/lowmem.sh (2)
lib/functions/logging/runners.sh (1)
  • chroot_sdcard (133-136)
lib/functions/bsp/armbian-bsp-cli-deb.sh (1)
  • board_side_bsp_cli_postinst_finish (448-471)
packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1)
lib/functions/bsp/armbian-bsp-cli-deb.sh (2)
  • board_side_bsp_cli_preinst (360-415)
  • board_side_bsp_cli_postinst_base (425-446)
🔇 Additional comments (3)
packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist (1)

1-8: LGTM!

Configuration values are appropriate for low-memory boards, comments are clear, and the format follows established Armbian conventions for default config files.

packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1)

1-35: Well-structured script with proper safety checks.

The script demonstrates good practices:

  • Idempotent behavior (exits cleanly if swapfile exists)
  • Safety checks for free space with 64MiB headroom
  • Correct permissions (600) for swapfile
  • Proper use of fallocate for fast allocation
  • Past review feedback addressed (discard=once, configurable values via /etc/default/armbian-lowmem, correct use of dirname)
extensions/lowmem.sh (1)

1-63: Well-designed extension following Armbian conventions.

The extension properly implements four hook functions with clear separation of concerns:

  • Config installation with idempotent checks
  • Script and service installation
  • Service enablement
  • Image-level memory optimizations

The implementation follows established patterns:

  • Hook function naming enables automatic discovery by the framework
  • Proper use of display_alert for debugging visibility
  • Idempotent operations (checks before copying/appending)
  • Correct fstab regex pattern on line 56 (matches tmpfs /run tmpfs entries)
  • Past feedback addressed (quoting, file permissions)

Note: The shebang on line 1 is optional for extensions (they're sourced, not executed) but harmless. Based on learnings.

@coderabbitai coderabbitai bot requested a review from leggewie November 4, 2025 15:24
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1)

31-31: CRITICAL: Fix the broken fstab regex pattern.

The grep pattern on line 31 will never match existing swapfile entries in fstab, causing duplicate entries to be added on subsequent runs. The [^#]* prefix is greedy and consumes the entire line including the swapfile path, leaving nothing for the literal ${SWAPFILE_PATH} to match against.

For example, with the fstab line /swapfile swap swap defaults,nofail,discard=once,pri=0 0 0:

  • [^#]* matches the entire line
  • There's nothing left for ${SWAPFILE_PATH} to match
  • The grep fails even though the entry exists

Apply this diff to fix the pattern (consistent with standard fstab matching):

-if ! grep -qE "^[^#]*[[:space:]]+${SWAPFILE_PATH}[[:space:]]+swap[[:space:]]" /etc/fstab; then
+if ! grep -qE "^[[:space:]]*${SWAPFILE_PATH}[[:space:]]+swap[[:space:]]+swap" /etc/fstab; then

This pattern correctly matches:

  • Optional leading whitespace
  • The swapfile path
  • Whitespace(s)
  • "swap" (mount point field)
  • Whitespace(s)
  • "swap" (filesystem type field)
🧹 Nitpick comments (1)
extensions/lowmem.sh (1)

56-60: Consider making the fstab grep pattern more robust.

The current pattern works for typical fstab entries starting at column 0, but could be more robust by handling optional leading whitespace for consistency with defensive coding practices.

Apply this diff for improved robustness:

-	if ! grep -qE "tmpfs[[:space:]]+/run[[:space:]]+tmpfs" "${MOUNT}/etc/fstab"; then
+	if ! grep -qE "^[[:space:]]*tmpfs[[:space:]]+/run[[:space:]]+tmpfs" "${MOUNT}/etc/fstab"; then

This anchors the pattern to the start of the line and handles any leading whitespace, though in practice fstab entries rarely have leading spaces.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2099fbc and f82f6a4.

📒 Files selected for processing (4)
  • extensions/lowmem.sh (1 hunks)
  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service (1 hunks)
  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bsp/armbian-lowmem/etc/default/armbian-lowmem.dpkg-dist
🧰 Additional context used
🧠 Learnings (25)
📓 Common learnings
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub API (https://api.github.com/repos/armbian/build/pulls/{pr_number}/files) to get the complete picture of what files are being added or modified, especially for U-Boot patches that will be applied during the build process.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.
Learnt from: leggewie
Repo: armbian/build PR: 8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.
Learnt from: amazingfate
Repo: armbian/build PR: 8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.
Learnt from: amazingfate
Repo: armbian/build PR: 8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.
📚 Learning: 2025-09-14T06:19:06.828Z
Learnt from: amazingfate
Repo: armbian/build PR: 8619
File: config/kernel/linux-rockchip-vendor.config:0-0
Timestamp: 2025-09-14T06:19:06.828Z
Learning: CONFIG_ZSWAP has an implicit kernel-level dependency on CONFIG_SWAP, so when CONFIG_ZSWAP=y is set in Armbian overlay configs, CONFIG_SWAP gets automatically enabled during kernel build configuration processing, even if not explicitly specified in the overlay file.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-10-24T04:46:22.901Z
Learnt from: tabrisnet
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-10-24T04:46:22.901Z
Learning: In lib/functions/rootfs/rootfs-create.sh, the FIXME comment about mmdebstrap usage with --aptopt is a future note related to PR #8785, which hasn't been merged yet.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
  • extensions/lowmem.sh
📚 Learning: 2025-08-30T06:48:09.091Z
Learnt from: tabrisnet
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-08-30T06:48:09.091Z
Learning: In lib/functions/compilation/armbian-kernel.sh, the user prefers flexible grep patterns over anchored ones for BTRFS configuration checks, but agrees to use quiet grep (-q) to avoid polluting build logs.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.sh
📚 Learning: 2025-04-28T08:27:26.890Z
Learnt from: leggewie
Repo: armbian/build PR: 8133
File: extensions/apa.sh:1-2
Timestamp: 2025-04-28T08:27:26.890Z
Learning: In the Armbian build system, extension scripts in the `extensions/` directory contain hook functions and are meant to be sourced, not executed directly. These scripts don't require a shebang or `set -euo pipefail`.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
  • extensions/lowmem.sh
📚 Learning: 2025-07-25T03:51:50.830Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub API (https://api.github.com/repos/armbian/build/pulls/{pr_number}/files) to get the complete picture of what files are being added or modified, especially for U-Boot patches that will be applied during the build process.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
  • extensions/lowmem.sh
📚 Learning: 2025-07-25T03:51:50.830Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
  • extensions/lowmem.sh
📚 Learning: 2025-09-25T18:37:00.330Z
Learnt from: tabrisnet
Repo: armbian/build PR: 8661
File: lib/functions/compilation/armbian-kernel.sh:194-199
Timestamp: 2025-09-25T18:37:00.330Z
Learning: In PR armbian/build#8661, line 235 of lib/functions/compilation/armbian-kernel.sh already contains the corrected comment "BPF link support for netfilter hooks" for NETFILTER_BPF_LINK, not the misleading "BPF_SYSCALL" comment that was flagged during review.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
  • extensions/lowmem.sh
📚 Learning: 2025-07-21T04:12:02.439Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-07-21T04:12:02.439Z
Learning: In the Armbian build system, for recurring maintenance tasks like kernel version bumping, TODO comments should use generic version formats (e.g., "MAJOR.MINOR-rc1") rather than specific version numbers (e.g., "6.17-rc1") to avoid the need for frequent comment updates that would create unnecessary maintenance overhead.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-07-23T10:01:41.310Z
Learnt from: amazingfate
Repo: armbian/build PR: 8419
File: lib/functions/host/prepare-host.sh:272-275
Timestamp: 2025-07-23T10:01:41.310Z
Learning: In the Armbian build system, the design philosophy is to fail fast when host dependencies are not met rather than gracefully skipping unsupported architectures. This ensures build environment consistency and prevents silent failures. Host dependency checks should be explicit and non-negotiable.

Applied to files:

  • packages/bsp/armbian-lowmem/lowmem-mkswap.service
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: In Armbian build framework, extensions are loaded and executed via lib/functions/general/extensions.sh using call_extension_method. The framework sets set -o errexit and set -o errtrace globally, and individual commands run with pipefail protection through the command execution functions.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-05-16T15:34:34.672Z
Learnt from: Grippy98
Repo: armbian/build PR: 8202
File: config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh:2-3
Timestamp: 2025-05-16T15:34:34.672Z
Learning: The shell scripts in the Armbian build system's desktop configuration files, such as config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh, rely on environment variables like $SRC and $destination that are expected to be set externally before the script is executed.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-05-29T01:52:21.381Z
Learnt from: djurny
Repo: armbian/build PR: 8235
File: packages/bsp/mvebu/helios4/helios4-wol.service:0-0
Timestamp: 2025-05-29T01:52:21.381Z
Learning: In systemd service ExecStart commands, shell variables like ${INTF} can cause issues because systemd may resolve them before the shell processes them, leading to "no device matches name" errors. Using xargs with -I{} is a more reliable approach for iterating over dynamic lists in systemd services, as it avoids variable substitution problems entirely.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-08-14T17:19:39.693Z
Learnt from: leggewie
Repo: armbian/build PR: 8502
File: config/desktop/trixie/environments/i3-wm/config_base/packages:44-44
Timestamp: 2025-08-14T17:19:39.693Z
Learning: When a PR author provides clear context about package transitions in the commit message and the changes are scoped to specific release pockets, focus the review on validating those specific changes rather than suggesting broader investigations across other releases or additional dependency verifications.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-13T19:51:14.713Z
Learnt from: pyavitz
Repo: armbian/build PR: 8631
File: config/boards/khadas-vim4.conf:42-42
Timestamp: 2025-09-13T19:51:14.713Z
Learning: In the Armbian build system, run_host_command_logged properly handles shell redirection operators like ">>" when passed as string arguments. This pattern is used consistently throughout the codebase, such as in lib/functions/rootfs/distro-agnostic.sh where it's used to append to armbianEnv.txt files. The function has been tested and confirmed to work correctly with this syntax.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-08-29T18:44:47.732Z
Learnt from: leggewie
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-08-29T18:44:47.732Z
Learning: When creating GitHub issues for code improvements in the Armbian build project, include the relevant patches/diffs in the issue description or open a PR directly instead of just describing the changes. This makes it more efficient for the assignee to handle the improvements.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-05-07T20:49:40.969Z
Learnt from: djurny
Repo: armbian/build PR: 8166
File: config/bootscripts/boot-mvebu.cmd:38-50
Timestamp: 2025-05-07T20:49:40.969Z
Learning: The 4KB (0x1000) boundary used for device tree size calculations in U-Boot scripts is specific to how the `fdt resize` command works internally and should remain hardcoded rather than being tied to adjustable alignment variables.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-11-02T20:49:56.719Z
Learnt from: igorpecovnik
Repo: armbian/build PR: 8849
File: config/boards/radxa-e54c.csc:14-28
Timestamp: 2025-11-02T20:49:56.719Z
Learning: In Armbian board configuration files (config/boards/*.conf, *.csc, etc.), do not use kernel_config_set, kernel_config_set_m, kernel_config_set_y, or custom_kernel_config__* functions to modify kernel configuration. Kernel configuration is associated with LINUXFAMILY/BOARDFAMILY, not individual BOARD. Board-specific kernel modifications cause inconsistency in kernel packages published to the apt repository because boards within a family share the same kernel packages. Kernel configuration changes must be made in the appropriate kernel config file (e.g., config/kernel/linux-*-*.config) or in family configuration files (config/sources/families/*.conf, *.inc) instead.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-07-27T15:53:30.629Z
Learnt from: pyavitz
Repo: armbian/build PR: 8421
File: config/kernel/linux-sunxi64-edge.config:805-825
Timestamp: 2025-07-27T15:53:30.629Z
Learning: In the Armbian build system, kernel configurations prioritize broad hardware compatibility over optimization concerns. Even when including numerous legacy/obsolete drivers causes technical issues like increased initramfs size and slower enumeration, the project philosophy is to "appease the masses" by ensuring maximum device compatibility rather than optimizing for specific use cases.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-24T09:54:07.968Z
Learnt from: amazingfate
Repo: armbian/build PR: 8668
File: extensions/ufs.sh:2-2
Timestamp: 2025-09-24T09:54:07.968Z
Learning: In Armbian's build system, DOCKER_ARMBIAN_BASE_IMAGE must be set globally at file load time in extensions, not inside extension_prepare_config functions, because docker operations happen early in the build process and would default to ubuntu:noble if not set before docker_cli_prepare() runs.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-18T03:36:17.862Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8537
File: config/boards/qcom-robotics-rb5.conf:1-1
Timestamp: 2025-09-18T03:36:17.862Z
Learning: In Armbian board configuration files (regardless of file extension), the standard pattern is to have only one line as a comment describing the board hardware specifications. This single-line description typically includes the SoC model, core count, RAM options, and key features like connectivity options, storage interfaces, and special features. The file extensions indicate board support status: .conf (standard support), .csc (community supported), .eos (end of support), .tvb (tvbox), .wip (work in progress).

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-08-03T15:21:20.148Z
Learnt from: pyavitz
Repo: armbian/build PR: 8455
File: config/sources/families/sun50iw1.conf:19-24
Timestamp: 2025-08-03T15:21:20.148Z
Learning: In the Armbian build system, when copying firmware files during family_tweaks_s(), use /lib/firmware/updates/ instead of /lib/firmware/ to avoid conflicts with the Armbian firmware package. The /lib/firmware/updates directory takes precedence in Linux firmware loading hierarchy and is the proper location for user-installed firmware files.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-07-17T04:12:33.125Z
Learnt from: pyavitz
Repo: armbian/build PR: 8388
File: config/boards/kickpik2b.conf:1-14
Timestamp: 2025-07-17T04:12:33.125Z
Learning: In the Armbian build system, board configuration files (*.conf) follow a project standard of not including shebang lines, even though they contain bash code and are sourced by the build system. This is an established Armbian convention that individual contributors are expected to follow, and changes to this standard would require broader project maintainer approval.

Applied to files:

  • extensions/lowmem.sh
📚 Learning: 2025-09-07T17:39:32.272Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8586
File: config/boards/nanopi-r76s.conf:15-21
Timestamp: 2025-09-07T17:39:32.272Z
Learning: In the Armbian build system, the variables $BOARD and $SDCARD are always set by the build framework, so guard checks for these variables are unnecessary in board configuration files and hook functions.

Applied to files:

  • extensions/lowmem.sh
🧬 Code graph analysis (3)
packages/bsp/armbian-lowmem/lowmem-mkswap.sh (1)
lib/functions/bsp/armbian-bsp-cli-deb.sh (2)
  • board_side_bsp_cli_preinst (360-415)
  • board_side_bsp_cli_postinst_base (425-446)
packages/bsp/armbian-lowmem/lowmem-mkswap.service (1)
lib/functions/bsp/armbian-bsp-cli-deb.sh (3)
  • board_side_bsp_cli_preinst (360-415)
  • board_side_bsp_cli_postinst_finish (448-471)
  • board_side_bsp_cli_postrm (417-423)
extensions/lowmem.sh (3)
lib/functions/logging/runners.sh (1)
  • chroot_sdcard (133-136)
lib/functions/bsp/armbian-bsp-cli-deb.sh (1)
  • board_side_bsp_cli_postinst_finish (448-471)
lib/functions/rootfs/post-tweaks.sh (1)
  • post_debootstrap_tweaks (10-34)
🔇 Additional comments (9)
packages/bsp/armbian-lowmem/lowmem-mkswap.sh (4)

1-3: LGTM! Appropriate error handling for first-boot script.

The shebang and strict error handling (set -euo pipefail) are appropriate for this critical first-boot swapfile creation script.


4-8: LGTM! Sensible defaults with user override capability.

The default swapfile configuration (256MB at /swapfile) is appropriate for low-memory boards, and the config file sourcing pattern allows users to customize these values as discussed in the PR.


11-15: LGTM! Graceful handling of existing swapfile.

The exit-on-existing-swapfile logic is correct per the design discussion. Returning 0 allows the script to run on every boot without systemd marking it as failed when the swapfile is already present.


17-24: LGTM! Appropriate free-space validation with headroom.

The free-space check with 64MB headroom is a good safety measure that prevents out-of-space errors during swapfile creation. The fail-fast behavior (exit 1) is appropriate for low-memory devices.

packages/bsp/armbian-lowmem/lowmem-mkswap.service (1)

1-14: LGTM! Well-structured systemd unit with appropriate dependencies.

The systemd unit configuration is correct:

  • DefaultDependencies=no with Before=basic.target ensures swap is available early in the boot process
  • Wants=armbian-resize-filesystem.service establishes a soft dependency that won't cause failure if the resize service is absent
  • After=armbian-resize-filesystem.service ensures proper ordering when both services are present
  • Type=oneshot with RemainAfterExit=yes is the standard pattern for one-time initialization

Previous issues (script path mismatch) have been addressed per earlier reviews.

extensions/lowmem.sh (4)

11-21: LGTM! Idiomatic config installation with overwrite protection.

The function correctly installs the default lowmem configuration with appropriate permissions (664) while guarding against overwriting existing customizations. The pattern aligns with Armbian BSP conventions visible in lib/functions/bsp/armbian-bsp-cli-deb.sh.


23-33: LGTM! Proper installation of script and service with correct permissions.

The function uses the install command with appropriate modes (755 for executable script, 644 for service file) and properly quoted paths. Previous quoting issues have been addressed.


35-41: LGTM! Correct service enablement in chroot context.

The function properly uses chroot_sdcard to enable the lowmem-mkswap service within the target image. This aligns with the Armbian extension framework patterns. Based on learnings.


44-51: LGTM! Appropriate memory optimization defaults.

The memory optimization settings are well-chosen for low-RAM boards:

  • 20MB fixed size for /run tmpfs prevents systemd daemon-reload issues when free memory drops below ~16MB
  • Disabling ramlog reduces memory consumption
  • Disabling zram swap in favor of file-based swap + zswap is appropriate per the PR objectives

The sed patterns correctly handle both commented and uncommented configuration lines.

@vidplace7
Copy link
Member Author

Tested this PR again after making all requested changes.

  • lowmem-mkswap.service now starts on every boot
  • Confirmed that multiple-reboots do not result in multiple swapfiles (skipping quickly if already exists is working).
  • Confirmed /etc/fstab conditional behavior is working 👍 (no duplicate creation)
  • Confirmed /etc/default/armbian-lowmem changes work properly (both size and location)

This should be good to merge 🙏

@github-actions github-actions bot removed the Needs review Seeking for review label Nov 4, 2025
@igorpecovnik igorpecovnik merged commit 896afe2 into armbian:main Nov 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

11 Milestone: Fourth quarter release BSP Board Support Packages Framework Framework components size/medium PR with more then 50 and less then 250 lines

Development

Successfully merging this pull request may close these issues.

4 participants