umount modules before switch_root
This commit is contained in:
@@ -144,6 +144,9 @@ pub async fn run() {
|
||||
warn!("failed to copy {INIT_LOG} to system: {e}");
|
||||
}
|
||||
|
||||
if let Err(e) = nix::mount::umount2("/modules", nix::mount::MntFlags::MNT_DETACH) {
|
||||
warn!("failed to umount /modules: {e}");
|
||||
}
|
||||
retry(async || switch_root("/system").await).await;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::{fs::walk_dir, utils};
|
||||
|
||||
pub async fn bootstrap(cfg: Config) {
|
||||
let verifier = retry(async || Verifier::from_config(&cfg)).await;
|
||||
let bs = cfg.bootstrap;
|
||||
let bs = &cfg.bootstrap;
|
||||
|
||||
mount(Some(&bs.dev), "/bootstrap", "ext4", None).await;
|
||||
|
||||
@@ -53,7 +53,7 @@ pub async fn bootstrap(cfg: Config) {
|
||||
})
|
||||
.await;
|
||||
|
||||
mount_system(&sys_cfg, base_dir, &verifier).await;
|
||||
mount_system(&sys_cfg, &cfg, base_dir, &verifier).await;
|
||||
|
||||
retry_or_ignore(async || {
|
||||
let path = "/etc/resolv.conf";
|
||||
@@ -187,7 +187,12 @@ fn default_root_tmpfs_opts() -> Option<String> {
|
||||
Some(format!("size={fs_size}m"))
|
||||
}
|
||||
|
||||
async fn mount_system(cfg: &dkl::Config, bs_dir: &str, verifier: &Verifier) {
|
||||
async fn mount_system(
|
||||
cfg: &dkl::Config,
|
||||
bs_cfg: &Config,
|
||||
bs_dir: &str,
|
||||
verifier: &Verifier,
|
||||
) {
|
||||
let opts = match utils::param("root-opts") {
|
||||
Some(s) => Some(s.to_string()),
|
||||
None => default_root_tmpfs_opts(),
|
||||
@@ -201,8 +206,7 @@ async fn mount_system(cfg: &dkl::Config, bs_dir: &str, verifier: &Verifier) {
|
||||
|
||||
for layer in &cfg.layers {
|
||||
let src = retry(async || {
|
||||
if layer == "modules" {
|
||||
let src = "/modules.sqfs";
|
||||
if layer == "modules" && let Some(src) = bs_cfg.modules.as_ref() {
|
||||
(fs::read(src).await).map_err(|e| format_err!("read {src} failed: {e}"))
|
||||
} else {
|
||||
verifier.verify_path(&format!("{bs_dir}/{layer}.fs")).await
|
||||
|
||||
Reference in New Issue
Block a user