Skip to content

Conversation

@ckyrouac
Copy link
Collaborator

@ckyrouac ckyrouac commented Nov 4, 2025

Allow mount points (separate filesystems) to exist during to-filesystem installations by detecting and skipping them in the empty rootdir check.

When cleaning directories during install, recursively clean the contents of mount point directories while preserving the mount point itself. This is necessary for cases where subdirectories like /var/log or /var/home are separate logical volumes.

Assisted-by: Claude Code

Fixes #1728


I need to test this more and add automated tests. Looking for feedback on possible side effects I'm not aware of.

@github-actions github-actions bot added area/install Issues related to `bootc install` area/ostree Issues related to ostree labels Nov 4, 2025
@bootc-bot bootc-bot bot requested a review from gursewak1997 November 4, 2025 19:51
// Check if this entry is a directory
let etype = e.file_type()?;
if etype == FileType::dir() {
// Check if this directory is a mount point (separate filesystem)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Offhand this seems sane to me

Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

I think we could still land this with a test case or so?

Which I guess partially blocks on cleaning up the install test cases.

}
// Also ignore bind mounts, if we have a new enough kernel with statx()
// that will tell us.
// For mount points (e.g., separate LVM volumes under /var), we need to clean
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the record I think this code is "almost" dead, it should only be reachable from the ostree container commit CLI verb which we have backed away from.

While it is related, I think this would be better as a separate PR with its own rationale, because it's really not related at all to the install flow.

@cgwalters
Copy link
Collaborator

I'm not quite sure this is going to actively fix #1728 though. This case is more like "system-reinstall-bootc on a system where e.g. /foo is a mount point. Except to-existing-root already defaults to --wipe=alongside which should skip this logic anyways?

When performing a to-filesystem installation, the target directory may
contain pre-existing mount points for directories like /var, /var/lib/containers,
etc. These are legitimate in hybrid/existing filesystem scenarios where certain
directories are on separate partitions.

This change enhances the empty rootdir check to:
- Recursively detect directories that contain only mount points
- Skip directories that are themselves mount points
- Allow installation to proceed when mount hierarchies exist (e.g., /var
  containing /var/lib which contains mounted /var/lib/containers)

Also adds integration test coverage for separate /var mount scenarios using LVM.

Assisted-by: Claude Code (Sonnet 4.5)
Signed-off-by: ckyrouac <ckyrouac@redhat.com>
@ckyrouac ckyrouac marked this pull request as ready for review November 20, 2025 15:20
@bootc-bot bootc-bot bot requested a review from jmarrero November 20, 2025 15:20
/// This handles cases like /var containing /var/lib (not a mount) which contains
/// /var/lib/containers (a mount point).
#[context("Checking if directory contains only mount points")]
fn dir_contains_only_mounts(parent_fd: &Dir, dir_name: &str) -> Result<bool> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could have a unit test for this for the trivial cases at least (no inner mounts). Actually testing the mount case needs an integration test.

}

// There must be a boot directory (that is empty)
if name == BOOT {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we might be able to consolidate this logic with the above?

}

// Found a non-mount, non-directory-of-mounts entry
tracing::debug!("Found non-mount entry in {dir_name}: {entry_name}");
Copy link
Collaborator

Choose a reason for hiding this comment

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

The logs here feel a bit noisy potentially, how about making this

fn require_dir_contains_only_mounts(...) -> Result<()> and the error message is the first non-mount entry?

Then I think we probably don't need the logs at all, the error will include the info.

if dir_contains_only_mounts(rootfs_fd, &name)? {
tracing::debug!("Skipping directory containing only mount points: {name}");
continue;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feels a bit weird to me to fall through here on error instead of just erroring out, see above

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

Labels

area/install Issues related to `bootc install` area/ostree Issues related to ostree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Separate /var part required for ISO based installation but forbidden for 'bootc install to-filesystem'

2 participants