Skip to content

Commit 7efbb96

Browse files
cgwaltershenrywang
authored andcommitted
install: Add --skip-finalize
A generic use case for installing to an existing filesystem in the general case will be: - `bootc install to-filesystem` - Inject other configuration or data into `/etc` and/or `/var` (Until such time as we offer an explicit API to do the latter) Add a `--skip-finalize` which will avoid remounting the root. This also should work around qemu-user not implementing the FITRIM ioctl, which can be hit when doing cross-architecture installs. Signed-off-by: Colin Walters <[email protected]>
1 parent d22b50d commit 7efbb96

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lib/src/install.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ pub(crate) struct InstallTargetFilesystemOpts {
229229
/// In the future, it may also be supported to set up an explicit "dual boot" system.
230230
#[clap(long)]
231231
pub(crate) replace: Option<ReplaceMode>,
232+
233+
/// The default mode is to "finalize" the target filesystem by invoking `fstrim` and similar
234+
/// operations, and finally mounting it readonly. This option skips those operations. It
235+
/// is then the responsibility of the invoking code to perform those operations.
236+
#[clap(long)]
237+
pub(crate) skip_finalize: bool,
232238
}
233239

234240
/// Perform an installation to a mounted filesystem.
@@ -763,8 +769,8 @@ pub(crate) struct RootSetup {
763769
rootfs: Utf8PathBuf,
764770
rootfs_fd: Dir,
765771
rootfs_uuid: Option<String>,
766-
/// True if this is an "alongside" install where we didn't create the filesystem
767-
is_alongside: bool,
772+
/// True if we should skip finalizing
773+
skip_finalize: bool,
768774
boot: Option<MountSpec>,
769775
kargs: Vec<String>,
770776
}
@@ -1175,7 +1181,7 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
11751181
tracing::debug!("Installed bootloader");
11761182

11771183
// Finalize mounted filesystems
1178-
if !rootfs.is_alongside {
1184+
if !rootfs.skip_finalize {
11791185
let bootfs = rootfs.rootfs.join("boot");
11801186
for fs in [bootfs.as_path(), rootfs.rootfs.as_path()] {
11811187
finalize_filesystem(fs)?;
@@ -1513,6 +1519,8 @@ pub(crate) async fn install_to_filesystem(
15131519
.chain(bootarg)
15141520
.collect::<Vec<_>>();
15151521

1522+
let skip_finalize =
1523+
matches!(fsopts.replace, Some(ReplaceMode::Alongside)) || fsopts.skip_finalize;
15161524
let mut rootfs = RootSetup {
15171525
luks_device: None,
15181526
device: backing_device.into(),
@@ -1521,7 +1529,7 @@ pub(crate) async fn install_to_filesystem(
15211529
rootfs_uuid: inspect.uuid.clone(),
15221530
boot,
15231531
kargs,
1524-
is_alongside: matches!(fsopts.replace, Some(ReplaceMode::Alongside)),
1532+
skip_finalize,
15251533
};
15261534

15271535
install_to_filesystem_impl(&state, &mut rootfs).await?;
@@ -1541,6 +1549,7 @@ pub(crate) async fn install_to_existing_root(opts: InstallToExistingRootOpts) ->
15411549
root_mount_spec: None,
15421550
boot_mount_spec: None,
15431551
replace: opts.replace,
1552+
skip_finalize: true,
15441553
},
15451554
source_opts: opts.source_opts,
15461555
target_opts: opts.target_opts,

lib/src/install/baseline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,6 @@ pub(crate) fn install_create_rootfs(
408408
rootfs_uuid: Some(root_uuid.to_string()),
409409
boot: Some(boot),
410410
kargs,
411-
is_alongside: false,
411+
skip_finalize: false,
412412
})
413413
}

0 commit comments

Comments
 (0)