Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install: Add --skip-finalize #462

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ pub(crate) struct InstallTargetFilesystemOpts {
/// In the future, it may also be supported to set up an explicit "dual boot" system.
#[clap(long)]
pub(crate) replace: Option<ReplaceMode>,

/// The default mode is to "finalize" the target filesystem by invoking `fstrim` and similar
/// operations, and finally mounting it readonly. This option skips those operations. It
/// is then the responsibility of the invoking code to perform those operations.
#[clap(long)]
pub(crate) skip_finalize: bool,
}

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

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

let skip_finalize =
matches!(fsopts.replace, Some(ReplaceMode::Alongside)) || fsopts.skip_finalize;
let mut rootfs = RootSetup {
luks_device: None,
device: backing_device.into(),
Expand All @@ -1521,7 +1529,7 @@ pub(crate) async fn install_to_filesystem(
rootfs_uuid: inspect.uuid.clone(),
boot,
kargs,
is_alongside: matches!(fsopts.replace, Some(ReplaceMode::Alongside)),
skip_finalize,
};

install_to_filesystem_impl(&state, &mut rootfs).await?;
Expand All @@ -1541,6 +1549,7 @@ pub(crate) async fn install_to_existing_root(opts: InstallToExistingRootOpts) ->
root_mount_spec: None,
boot_mount_spec: None,
replace: opts.replace,
skip_finalize: true,
},
source_opts: opts.source_opts,
target_opts: opts.target_opts,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/install/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,6 @@ pub(crate) fn install_create_rootfs(
rootfs_uuid: Some(root_uuid.to_string()),
boot: Some(boot),
kargs,
is_alongside: false,
skip_finalize: false,
})
}