Skip to content

Conversation

@iav
Copy link
Contributor

@iav iav commented Apr 20, 2025

Realisation #8067 during installation from sdcard to nvme internal storage.
It makes possible to work with snapshots of a root filesystem on btrfs.

Using snapshots of a rootfs on btrfs needs to place root on a btrfs subvolume, not on root of btrfs volume itself.
Sometimes some of directories have to be placed on separate subvolumes.

After this change snapper can be installed, and do auto-snapshots on timer and apt operations.

@iav iav requested a review from a team as a code owner April 20, 2025 17:19
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 20, 2025

Walkthrough

This change updates the Armbian installation script to modify how Btrfs filesystems are handled during installation. The script now creates a dedicated Btrfs subvolume named @ within the root filesystem directory after mounting. It then synchronizes the filesystem, sets the newly created @ subvolume as the default, unmounts the root filesystem, and remounts it using the mount options compress-force=zlib,subvol=@. The previous noatime mount option is removed. These changes ensure that the root filesystem is mounted from the @ subvolume with compression enabled. No changes were made to the signatures or declarations of exported or public entities.

Possibly related PRs

Suggested labels

ready to merge

Suggested reviewers

  • igorpecovnik

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added 05 Milestone: Second quarter release size/small PR with less then 50 lines Needs review Seeking for review BSP Board Support Packages labels Apr 20, 2025
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label Apr 20, 2025
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/common/usr/bin/armbian-install (2)

131-131: Consider adding a comment about compression settings

The mount option compress-force=zlib is used when remounting, which could benefit from a brief comment explaining the choice of compression algorithm.

-    mount -o compress-force=zlib,subvol=@ "$2" "${TempDir}"/rootfs 2> /dev/null
+    # Mount with zlib compression for better compatibility and reasonable compression ratio
+    mount -o compress-force=zlib,subvol=@ "$2" "${TempDir}"/rootfs 2> /dev/null

124-132: Suggestion: Add error handling for Btrfs operations

The Btrfs subvolume creation and management operations don't include error handling. Consider adding checks to ensure each operation succeeds before proceeding.

 # make separate subvolume for rootfs on btrfs
 if [[ $eMMCFilesystemChoosen =~ ^(btrfs)$ ]]; then
-    btrfs subvolume create "${TempDir}"/rootfs/@
+    if ! btrfs subvolume create "${TempDir}"/rootfs/@ > /dev/null 2>&1; then
+        echo "Error: Failed to create Btrfs subvolume" >> $logfile
+        exit 15
+    fi
     sync
-    btrfs subvolume list ${TempDir}/rootfs/ | grep 'path @$' | cut -d' ' -f2 \
-        | xargs -I{} btrfs subvolume set-default {} ${TempDir}/rootfs/
+    SUBVOL_ID=$(btrfs subvolume list ${TempDir}/rootfs/ | grep 'path @$' | cut -d' ' -f2)
+    if [ -z "$SUBVOL_ID" ]; then
+        echo "Error: Failed to find created subvolume" >> $logfile
+        exit 15
+    fi
+    btrfs subvolume set-default $SUBVOL_ID ${TempDir}/rootfs/
     umount "${TempDir}"/rootfs
-    mount -o compress-force=zlib,subvol=@ "$2" "${TempDir}"/rootfs 2> /dev/null
+    if ! mount -o compress-force=zlib,subvol=@ "$2" "${TempDir}"/rootfs 2> /dev/null; then
+        echo "Error: Failed to mount Btrfs subvolume" >> $logfile
+        exit 15
+    fi
 fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 84447a0 and 76f7436.

📒 Files selected for processing (1)
  • packages/bsp/common/usr/bin/armbian-install (2 hunks)
🔇 Additional comments (3)
packages/bsp/common/usr/bin/armbian-install (3)

99-99: Updated Btrfs mount options to include subvolume support

The mount options for Btrfs have been modified to include subvol=@ and replaced noatime with better defaults. This change supports the new subvolume structure for the root filesystem.


124-132: Enhanced Btrfs support with dedicated root subvolume

The added code correctly implements the feature to place the root filesystem on a dedicated Btrfs subvolume named @. This is a good practice for Btrfs filesystems as it enables proper snapshot management and follows the standard layout used by tools like Snapper.

The implementation follows these steps:

  1. Creates a new subvolume named @ within the root filesystem
  2. Syncs the filesystem to ensure persistence
  3. Sets the newly created subvolume as the default
  4. Remounts the filesystem with the appropriate subvolume option

124-132:

✅ Verification successful

Verify Btrfs subvolume naming convention consistency

The implementation uses @ as the subvolume name, which is common in some distros (like Ubuntu), but ensure this is consistent with Armbian's conventions and documented appropriately.


🏁 Script executed:

#!/bin/bash
# Check for any existing Btrfs subvolume naming patterns in the codebase
grep -r "btrfs subvolume create" --include="*.sh" .
grep -r "subvol=" --include="*.sh" .

Length of output: 2610


Btrfs subvolume naming convention confirmed
Verified that Armbian’s existing scripts (e.g. lib/functions/image/partitioning.sh) already use @, @home, @var etc., so the use of @ here matches the established convention. No changes required.

@igorpecovnik
Copy link
Member

Perfect, thanks.

Perhaps adding few words on this here:
https://docs.armbian.com/User-Guide_Getting-Started/#installation

@igorpecovnik igorpecovnik merged commit 810ea3e into armbian:main Apr 21, 2025
1 check passed
@iav iav deleted the install_btrfs_subvol branch April 21, 2025 16:13
@iav
Copy link
Contributor Author

iav commented Apr 21, 2025

f2fs filesystem missed from this documentation page too.

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 Ready to merge Reviewed, tested and ready for merge size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

2 participants