Skip to content

Commit

Permalink
Merge pull request #462 from cgwalters/filesystem-no-trim
Browse files Browse the repository at this point in the history
install: Add `--skip-finalize`
  • Loading branch information
cgwalters committed Apr 8, 2024
2 parents d22b50d + 7efbb96 commit 593a932
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
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,
})
}

0 comments on commit 593a932

Please sign in to comment.