Skip to content

fix: armbian-resize-filesystem diskdevname fallback for /dev/sda* devices#9595

Open
mvanhorn wants to merge 1 commit intoarmbian:mainfrom
mvanhorn:fix/resize-filesystem-sda-diskdevname
Open

fix: armbian-resize-filesystem diskdevname fallback for /dev/sda* devices#9595
mvanhorn wants to merge 1 commit intoarmbian:mainfrom
mvanhorn:fix/resize-filesystem-sda-diskdevname

Conversation

@mvanhorn
Copy link
Copy Markdown

@mvanhorn mvanhorn commented Mar 26, 2026

Summary

Fixes the sed fallback regex in armbian-resize-filesystem that incorrectly handles /dev/sda* style device names.

Fixes #9593

Problem

The fallback path on line 28 uses sed "s/p.*//" to strip the partition suffix from device names. This works for devices using a "p" separator (mmcblk0p2 -> mmcblk0, nvme0n1p1 -> nvme0n1) but fails for SCSI/SATA/virtio devices (sda2 stays sda2 because there is no "p").

Fix

Replace with sed -E 's/p?[0-9]+$//' which strips an optional "p" followed by trailing digits:

Input Old result New result
mmcblk0p2 mmcblk0 mmcblk0
nvme0n1p1 nvme0n1 nvme0n1
sda2 sda2 (wrong) sda
vda3 vda3 (wrong) vda

This contribution was developed with AI assistance (Claude Code).

Summary by CodeRabbit

  • Bug Fixes
    • Improved filesystem resize fallback logic to more accurately detect block devices, increasing reliability when standard detection methods are unavailable.

…ices

The sed fallback for extracting disk device names used `sed "s/p.*//"`,
which only works for devices with a "p" partition separator (mmcblk0p2,
nvme0n1p1). For /dev/sda2, there is no "p" so the regex matches nothing,
leaving "sda2" instead of "sda".

Replace with `sed -E 's/p?[0-9]+$//'` which handles both conventions:
- mmcblk0p2 -> mmcblk0 (strips "p2")
- nvme0n1p1 -> nvme0n1 (strips "p1")
- sda2 -> sda (strips "2")
- vda3 -> vda (strips "3")

Fixes armbian#9593

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mvanhorn mvanhorn requested a review from a team as a code owner March 26, 2026 09:42
@mvanhorn mvanhorn requested review from ArkadiuszRaj and igorpecovnik and removed request for a team March 26, 2026 09:42
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 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: f34e7fb3-af2a-4621-a88d-a7d84df70fb1

📥 Commits

Reviewing files that changed from the base of the PR and between f990145 and 3947fa8.

📒 Files selected for processing (1)
  • packages/bsp/common/usr/lib/armbian/armbian-resize-filesystem

📝 Walkthrough

Walkthrough

A single-line refinement to the partition name extraction fallback logic in the resize-filesystem script. The sed pattern changes from stripping everything after p.* to using an extended regex p?[0-9]+$ that removes only the trailing partition suffix, preserving the device name structure.

Changes

Cohort / File(s) Summary
Partition fallback logic refinement
packages/bsp/common/usr/lib/armbian/armbian-resize-filesystem
Updated sed regex pattern in do_expand_partition() fallback to strip only trailing partition suffix p?[0-9]+$ instead of everything after p.*, improving compatibility with different block device naming schemes.

Possibly related issues

  • #9593 — Directly addresses the /dev/sda2 vs /dev/mmcblk0p2 device naming handling by refining the partition suffix extraction logic to work correctly across both naming conventions.

Poem

🐰 A partition path had lost its way,
Between sda and mmcblk's play,
With p?[0-9]+$ now precise,
The fallback works—oh how quite nice! ✨

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: fixing a regex fallback in armbian-resize-filesystem to properly handle /dev/sda* device names.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 the 05 Milestone: Second quarter release label Mar 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Hey @mvanhorn! 👋

Thanks for submitting your first pull request to the Armbian project — we're excited to have you contributing! 🧡
Your effort doesn’t just improve Armbian — it benefits the entire community of users and developers.

If you'd like to stay informed about project updates or collaborate more closely with the team,
you can optionally share some personal contact preferences at armbian.com/update-data.
This helps us keep in touch without relying solely on GitHub notifications.

Also, don’t forget to ⭐ star the repo if you haven’t already — and welcome aboard! 🚀

@github-actions github-actions bot added size/small PR with less then 50 lines Needs review Seeking for review BSP Board Support Packages labels Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release BSP Board Support Packages Needs review Seeking for review size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

[BUG]: armbian-resize-filesystem diskdevname fallback path is not handling /dev/sda* correctly.

1 participant