@@ -229,6 +229,12 @@ pub(crate) struct InstallTargetFilesystemOpts {
229
229
/// In the future, it may also be supported to set up an explicit "dual boot" system.
230
230
#[ clap( long) ]
231
231
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 ,
232
238
}
233
239
234
240
/// Perform an installation to a mounted filesystem.
@@ -763,8 +769,8 @@ pub(crate) struct RootSetup {
763
769
rootfs : Utf8PathBuf ,
764
770
rootfs_fd : Dir ,
765
771
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 ,
768
774
boot : Option < MountSpec > ,
769
775
kargs : Vec < String > ,
770
776
}
@@ -1175,7 +1181,7 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
1175
1181
tracing:: debug!( "Installed bootloader" ) ;
1176
1182
1177
1183
// Finalize mounted filesystems
1178
- if !rootfs. is_alongside {
1184
+ if !rootfs. skip_finalize {
1179
1185
let bootfs = rootfs. rootfs . join ( "boot" ) ;
1180
1186
for fs in [ bootfs. as_path ( ) , rootfs. rootfs . as_path ( ) ] {
1181
1187
finalize_filesystem ( fs) ?;
@@ -1513,6 +1519,8 @@ pub(crate) async fn install_to_filesystem(
1513
1519
. chain ( bootarg)
1514
1520
. collect :: < Vec < _ > > ( ) ;
1515
1521
1522
+ let skip_finalize =
1523
+ matches ! ( fsopts. replace, Some ( ReplaceMode :: Alongside ) ) || fsopts. skip_finalize ;
1516
1524
let mut rootfs = RootSetup {
1517
1525
luks_device : None ,
1518
1526
device : backing_device. into ( ) ,
@@ -1521,7 +1529,7 @@ pub(crate) async fn install_to_filesystem(
1521
1529
rootfs_uuid : inspect. uuid . clone ( ) ,
1522
1530
boot,
1523
1531
kargs,
1524
- is_alongside : matches ! ( fsopts . replace , Some ( ReplaceMode :: Alongside ) ) ,
1532
+ skip_finalize ,
1525
1533
} ;
1526
1534
1527
1535
install_to_filesystem_impl ( & state, & mut rootfs) . await ?;
@@ -1541,6 +1549,7 @@ pub(crate) async fn install_to_existing_root(opts: InstallToExistingRootOpts) ->
1541
1549
root_mount_spec : None ,
1542
1550
boot_mount_spec : None ,
1543
1551
replace : opts. replace ,
1552
+ skip_finalize : true ,
1544
1553
} ,
1545
1554
source_opts : opts. source_opts ,
1546
1555
target_opts : opts. target_opts ,
0 commit comments