Skip to content

Conversation

@iav
Copy link
Contributor

@iav iav commented Apr 11, 2025

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.

This PR:

  1. places root filesystem to "@" btrfs subvolume instead of a root of btrfs itself
  2. adds 2 hook calls in fs creation process to make possible to create additional btrfs subvolumes
  3. adds inactive example of usage — how to place /var, /var/log, /home directories on separate btrfs subvolumes
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

It makes possible to work with snapshots of a root filesystem
@iav iav requested a review from a team as a code owner April 11, 2025 01:01
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 11, 2025

Walkthrough

The changes update the prepare_partitions function within the partitioning.sh script to add support for the Btrfs filesystem. When the ROOTFS_TYPE is set to btrfs, the function now creates a set of Btrfs subvolumes including those for @home, @var, @var_log, @var_cache, and @srv. A default subvolume @ is also created for the root filesystem and is set as the default subvolume for mounting. Additionally, the script appends the necessary entries to the fstab file with appropriate mount options specific to Btrfs, ensuring the subvolumes are correctly mounted during boot. No changes were made to the declarations of exported or public entities.

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.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.

✨ Finishing Touches
  • 📝 Generate Docstrings

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 plan to trigger planning for file edits and PR creation.
  • @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 size/medium PR with more then 50 and less then 250 lines Needs review Seeking for review Framework Framework components labels Apr 11, 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)
lib/functions/image/partitioning.sh (2)

317-342: Btrfs Subvolume Creation and Root Remounting

This new block introduces btrfs‐specific logic by:
• Setting the mount option for btrfs to "commit=120" (note that this now omits the leading comma compared to its earlier default, so please ensure consistency across mount option concatenations).
• Creating the root subvolume “@” with btrfs subvolume create $MOUNT/@.
• Retrieving the subvolume ID using a pipeline that includes grep 'path @' and cut before setting it as the default with btrfs subvolume set-default.

Please verify that the filtering with grep 'path @' is robust across different btrfs versions and that only the intended subvolume is matched. In addition, consider whether additional error handling or logging should be added in case the subvolume creation or default setting fails.


345-363: Btrfs fstab Entries for Additional Subvolumes

This section creates and mounts additional btrfs subvolumes (namely for /home, /var, /var/log, /var/cache, and /srv) and appends corresponding entries to fstab. The use of the call_extension_method hook to encapsulate these operations is a good approach for modularity. Ensure that:
• Directory creation is idempotent so that repeated runs do not result in errors.
• The fstab entries are unique and nonconflicting if the image is rebuilt or reconfigured.
• Appropriate logging or error checking is in place for these mount operations.

A brief review in various environments may help verify that these extra mounts integrate well with the overall mounting scheme.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2b48f5c and 7a65724.

📒 Files selected for processing (1)
  • lib/functions/image/partitioning.sh (2 hunks)
🔇 Additional comments (1)
lib/functions/image/partitioning.sh (1)

247-247: Minor Formatting/Whitespace Change

A new line appears to be added right after the partitioning command output. This seems intended to improve readability or visually separate stages in the script. Verify that this extra newline was intentional and does not affect downstream processing.

@The-going
Copy link
Contributor

Using snapshots of a rootfs on btrfs needs to place root on a btrfs subvolume

Good health!

Maybe it's better to implement this feature in armbian-install?

Copy link
Member

@igorpecovnik igorpecovnik left a comment

Choose a reason for hiding this comment

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

LGTM.

I also agree that it would be nice to add this also to armbian-install.

But there is ongoing RFC of it. I did some front-end changed armbian/configng#384 and @adeepn was also looking into integrating (fresh modular design) armbian-install into armbian-config.

@igorpecovnik igorpecovnik added Ready to merge Reviewed, tested and ready for merge 05 Milestone: Second quarter release labels Apr 16, 2025
@igorpecovnik igorpecovnik merged commit ab6587a into armbian:main Apr 16, 2025
1 check passed
@iav
Copy link
Contributor Author

iav commented Apr 17, 2025

I'll try to add this to armbian-install.

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

Development

Successfully merging this pull request may close these issues.

3 participants