@@ -779,6 +779,17 @@ async fn initialize_ostree_root(state: &State, root_setup: &RootSetup) -> Result
779779 // Another implementation: https://github.com/coreos/coreos-assembler/blob/3cd3307904593b3a131b81567b13a4d0b6fe7c90/src/create_disk.sh#L295
780780 crate :: lsm:: ensure_dir_labeled ( rootfs_dir, "" , Some ( "/" . into ( ) ) , 0o755 . into ( ) , sepolicy) ?;
781781
782+ // If we're installing alongside existing ostree and there's a separate boot partition,
783+ // we need to mount it to the sysroot's /boot so ostree can write bootloader entries there
784+ if has_ostree && root_setup. boot . is_some ( ) {
785+ if let Some ( boot) = & root_setup. boot {
786+ let source_boot = & boot. source ;
787+ let target_boot = root_setup. physical_root_path . join ( BOOT ) ;
788+ tracing:: debug!( "Mount {source_boot} to {target_boot} on ostree" ) ;
789+ bootc_mount:: mount ( source_boot, & target_boot) ?;
790+ }
791+ }
792+
782793 // And also label /boot AKA xbootldr, if it exists
783794 if rootfs_dir. try_exists ( "boot" ) ? {
784795 crate :: lsm:: ensure_dir_labeled ( rootfs_dir, "boot" , None , 0o755 . into ( ) , sepolicy) ?;
@@ -1944,7 +1955,9 @@ fn remove_all_except_loader_dirs(bootdir: &Dir, is_ostree: bool) -> Result<()> {
19441955 anyhow:: bail!( "Invalid non-UTF8 filename: {file_name:?} in /boot" ) ;
19451956 } ;
19461957
1947- // Only preserve loader on ostree
1958+ // TODO: Preserve basically everything (including the bootloader entries
1959+ // on non-ostree) by default until the very end of the install. And ideally
1960+ // make the "commit" phase an optional step after.
19481961 if is_ostree && file_name. starts_with ( "loader" ) {
19491962 continue ;
19501963 }
@@ -1955,6 +1968,7 @@ fn remove_all_except_loader_dirs(bootdir: &Dir, is_ostree: bool) -> Result<()> {
19551968 if let Some ( subdir) = bootdir. open_dir_noxdev ( & file_name) ? {
19561969 remove_all_in_dir_no_xdev ( & subdir, false )
19571970 . with_context ( || format ! ( "Removing directory contents: {}" , file_name) ) ?;
1971+ bootdir. remove_dir ( & file_name) ?;
19581972 }
19591973 } else {
19601974 bootdir
0 commit comments