Skip to content

Commit fdae493

Browse files
committed
reinstall: Add problematic mounted filesystem warning
This uses findmnt to locate filesystem mounts that are on the same source as the root mount. If any are found, the user is warned these filesystems will persist unmounted in the bootc system. The user must hit <enter> to proceed. Signed-off-by: ckyrouac <[email protected]>
1 parent 36fceed commit fdae493

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

system-reinstall-bootc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ platforms = ["*-unknown-linux-gnu"]
1616

1717
[dependencies]
1818
anyhow = { workspace = true }
19+
bootc-mount = { path = "../mount" }
1920
bootc-utils = { path = "../utils" }
2021
clap = { workspace = true, features = ["derive"] }
2122
crossterm = "0.29.0"

system-reinstall-bootc/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ fn run() -> Result<()> {
4040

4141
prompt::get_ssh_keys(ssh_key_file_path)?;
4242

43+
prompt::mount_warning()?;
44+
4345
let mut reinstall_podman_command =
4446
podman::reinstall_command(&config.bootc_image, ssh_key_file_path);
4547

system-reinstall-bootc/src/prompt.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::{prompt, users::get_all_users_keys};
22
use anyhow::{ensure, Context, Result};
33

4+
use bootc_mount::Filesystem;
45
use crossterm::event::{self, Event};
56
use std::time::Duration;
67

@@ -92,6 +93,42 @@ pub(crate) fn ask_yes_no(prompt: &str, default: bool) -> Result<bool> {
9293
.context("prompting")
9394
}
9495

96+
pub(crate) fn mount_warning() -> Result<()> {
97+
let mounts = bootc_mount::run_findmnt(&[], None)?;
98+
99+
let problematic_filesystems: Vec<&Filesystem> = mounts
100+
.filesystems
101+
.iter()
102+
.find(|mount| mount.target == "/")
103+
.map(|root| {
104+
root.children
105+
.iter()
106+
.flatten()
107+
.filter(|child| child.source == root.source)
108+
.collect()
109+
})
110+
.unwrap_or_default();
111+
112+
if !problematic_filesystems.is_empty() {
113+
println!();
114+
println!("Notice: the following filesystems are currently mounted on the root disk. After rebooting into the bootc system, these filesystems will not be mounted. They will be preserved so you will need to manually mount or remove them.");
115+
println!();
116+
for fs in problematic_filesystems {
117+
println!("{:?}", fs); //TODO: format this
118+
}
119+
println!();
120+
println!("Press <enter> to continue.");
121+
122+
loop {
123+
if let Event::Key(_) = event::read().unwrap() {
124+
break;
125+
}
126+
}
127+
}
128+
129+
Ok(())
130+
}
131+
95132
/// Gather authorized keys for all user's of the host system
96133
/// prompt the user to select which users's keys will be imported
97134
/// into the target system's root user's authorized_keys file

0 commit comments

Comments
 (0)