Skip to content

fix(extensions/lvm): Fix support for non-ext filesystems#9889

Open
ojafuenf wants to merge 3 commits into
armbian:mainfrom
ojafuenf:main
Open

fix(extensions/lvm): Fix support for non-ext filesystems#9889
ojafuenf wants to merge 3 commits into
armbian:mainfrom
ojafuenf:main

Conversation

@ojafuenf
Copy link
Copy Markdown

@ojafuenf ojafuenf commented May 24, 2026

Description

Compiling an image with ROOTFS_TYPE=btrfs and ENABLE_EXTENSIONS=lvm fails, because the lvm extensions tries to add a label to the filesystem using a ext4 specific command.
This PR differentiates between the different filesystems and uses the appropriate command for each to add the label.

nfs and f2fs are not labled, as they do not support labels, or labels cannot be added while the filesystem is mounted.
If the label cannot be successfully added, a message is printed, but ignored.

How Has This Been Tested?

  • Built all relevant ROOTFS_TYPEs with no more build errors
  • Flashed and tested btrfs on rock-5-itx

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

Summary by CodeRabbit

  • Bug Fixes
    • Root volume labeling now respects the filesystem type and supports ext4, btrfs, nilfs2 and xfs.
    • For supported filesystems, the installer emits per-filesystem success/failure alerts and records block ID info to the LVM log.
    • Labeling is skipped for unsupported filesystem types with an informational log entry to improve clarity and error handling.

Review Change Stack

@ojafuenf ojafuenf requested a review from igorpecovnik as a code owner May 24, 2026 20:26
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e6063d78-03d7-444c-90ef-69a86c519062

📥 Commits

Reviewing files that changed from the base of the PR and between 28965c7 and 8eb789a.

📒 Files selected for processing (1)
  • extensions/lvm.sh

📝 Walkthrough

Walkthrough

extensions/lvm.sh adds filesystem-aware labeling logic for LVM root volumes. A new label_partition() helper function performs type-specific labeling for ext4, btrfs, nilfs2, and xfs. The format_partitions__format_lvm() function is refactored to conditionally label based on ROOTFS_TYPE, skipping unsupported types with alerts, and logging filtered blkid output on successful labeling.

Changes

Filesystem-aware LVM partition labeling

Layer / File(s) Summary
Filesystem-specific label partition helper and conditional labeling
extensions/lvm.sh
New label_partition function dispatches filesystem-specific labeling for ext4, btrfs, nilfs2, and xfs. format_partitions__format_lvm is updated to early-return and emit a "labels skipped" alert for unsupported ROOTFS_TYPE, call label_partition for supported types, append blkid output filtered by LVM_VG_NAME to lvm.log on success, and emit a filesystem-specific failure alert (ignoring labeling) on failure.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 I hopped through scripts to fix a name,
From e2label to many a tiny claim,
ext4, btrfs, xfs, and nilfs2 in tune,
Logs sing blkid under the LVM moon,
A rabbit’s label dance — done soon!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing LVM support for non-ext filesystems by implementing filesystem-specific labeling logic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

❤️ Share

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

@github-actions github-actions Bot added 05 Milestone: Second quarter release size/small PR with less then 50 lines Needs review Seeking for review Framework Framework components labels May 24, 2026
Copy link
Copy Markdown
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@extensions/lvm.sh`:
- Around line 75-76: The script checks ROOTFS_TYPE against "nilfs" but upstream
uses "nilfs2", so update both occurrences to use "nilfs2" so ROOTFS_TYPE=nilfs2
is recognized; specifically change the conditional branch and the nilfs-tune
invocation that currently reference "nilfs" to "nilfs2" (the lines handling
ROOTFS_TYPE and the nilfs-tune call that targets
"/dev/mapper/${LVM_VG_NAME}-root") so the correct filesystem type is detected
and tuned.
- Around line 72-78: The label commands in extensions/lvm.sh currently hardcode
"armbi_root" for different filesystems; update each invocation (the e2label
call, the btrfs filesystem label call that uses mount+awk, the nilfs-tune -L
call, and the xfs_io -c "label -s" call) to use the configured ROOT_FS_LABEL
variable instead (e.g. "$ROOT_FS_LABEL"), ensuring proper quoting and that you
still reference the device or mountpoint via LVM_VG_NAME or the mount pipeline
as before.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7eaee1e2-dcdd-4c39-a2ee-000088069330

📥 Commits

Reviewing files that changed from the base of the PR and between 93e2cf6 and 28965c7.

📒 Files selected for processing (1)
  • extensions/lvm.sh

Comment thread extensions/lvm.sh Outdated
Comment thread extensions/lvm.sh Outdated
Comment thread extensions/lvm.sh
Comment on lines +70 to +79
function label_partition() {
if [ "$ROOTFS_TYPE" == "ext4" ]; then
e2label "/dev/mapper/${LVM_VG_NAME}-root" "${ROOT_FS_LABEL}"
elif [ "$ROOTFS_TYPE" == "btrfs" ]; then
btrfs filesystem label "$(mount | grep "/dev/mapper/${LVM_VG_NAME}-root" | awk '{print $3}')" "${ROOT_FS_LABEL}"
elif [ "$ROOTFS_TYPE" == "nilfs2" ]; then
nilfs-tune -L "${ROOT_FS_LABEL}" "/dev/mapper/${LVM_VG_NAME}-root"
elif [ "$ROOTFS_TYPE" == "xfs" ]; then
xfs_io -c "label -s \"${ROOT_FS_LABEL}\"" "$(mount | grep "/dev/mapper/${LVM_VG_NAME}-root" | awk '{print $3}')"
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

perhaps the design of the "case" for selection here would be clearer and more compact

Copy link
Copy Markdown
Contributor

@iav iav May 25, 2026

Choose a reason for hiding this comment

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

like that

  function format_partitions__format_lvm() {
        local rootdev="/dev/mapper/${LVM_VG_NAME}-root"
        local mountpoint
        case "${ROOTFS_TYPE}" in
                ext4|ext2)   e2label "${rootdev}" "${ROOT_FS_LABEL}" ;;
                btrfs)
                        mountpoint=$(findmnt -no TARGET "${rootdev}")
                        btrfs filesystem label "${mountpoint}" "${ROOT_FS_LABEL}
                nilfs2) nilfs-tune -L "${ROOT_FS_LABEL}" "${rootdev}" ;;
                xfs)
                        mountpoint=$(findmnt -no TARGET "${rootdev}")
                        xfs_io -c "label -s ${ROOT_FS_LABEL}" "${mountpoint}" ;;
                *) display_alert "LVM label skipped for ${ROOTFS_TYPE:-unset}" "
  "info"
                   return 0 ;;
        esac \
                && { blkid | grep -F "${LVM_VG_NAME}" >> "${DEST}/${LOG_SUBPATH}
                     display_alert "LVM labeled ${ROOTFS_TYPE} partition" "${EXT
  "info"; } \
                || display_alert "LVM failed to label ${ROOTFS_TYPE} partition.
  "${EXTENSION}" "info"
  }

Comment thread extensions/lvm.sh
elif [ "$ROOTFS_TYPE" == "nilfs2" ]; then
nilfs-tune -L "${ROOT_FS_LABEL}" "/dev/mapper/${LVM_VG_NAME}-root"
elif [ "$ROOTFS_TYPE" == "xfs" ]; then
xfs_io -c "label -s \"${ROOT_FS_LABEL}\"" "$(mount | grep "/dev/mapper/${LVM_VG_NAME}-root" | awk '{print $3}')"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

xfs_io -c "label -s ${ROOT_FS_LABEL}" "${mountpoint}"
simpler and safer

Comment thread extensions/lvm.sh
}

function label_partition() {
if [ "$ROOTFS_TYPE" == "ext4" ]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You miss ext2.

@iav
Copy link
Copy Markdown
Contributor

iav commented May 25, 2026

findmnt — structured, reliable, single-process method; mount | grep | awk — heuristic from 1990s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Development

Successfully merging this pull request may close these issues.

2 participants