@@ -769,6 +769,16 @@ async fn initialize_ostree_root(state: &State, root_setup: &RootSetup) -> Result
769769 // Another implementation: https://github.com/coreos/coreos-assembler/blob/3cd3307904593b3a131b81567b13a4d0b6fe7c90/src/create_disk.sh#L295
770770 crate :: lsm:: ensure_dir_labeled ( rootfs_dir, "" , Some ( "/" . into ( ) ) , 0o755 . into ( ) , sepolicy) ?;
771771
772+ // If we're installing alongside existing ostree and there's a separate boot partition,
773+ // we need to mount it to the sysroot's /boot so ostree can write bootloader entries there
774+ if has_ostree && root_setup. boot . is_some ( ) {
775+ if let Some ( boot) = & root_setup. boot {
776+ let source_boot = & boot. source ;
777+ let target_boot = root_setup. physical_root_path . join ( BOOT ) ;
778+ tracing:: debug!( "Mount {source_boot} to {target_boot} on ostree" ) ;
779+ bootc_mount:: mount ( source_boot, & target_boot) ?;
780+ }
781+ }
772782 // And also label /boot AKA xbootldr, if it exists
773783 if rootfs_dir. try_exists ( "boot" ) ? {
774784 crate :: lsm:: ensure_dir_labeled ( rootfs_dir, "boot" , None , 0o755 . into ( ) , sepolicy) ?;
@@ -981,6 +991,23 @@ async fn install_container(
981991 }
982992 }
983993
994+ // For seperate /boot filesystem, the better workaround is
995+ // to inject kernel arguments during installation.
996+ // See discussion in https://github.com/bootc-dev/bootc/issues/1388
997+ if let Some ( boot) = root_setup. boot . as_ref ( ) {
998+ if !boot. source . is_empty ( ) {
999+ let mount_extra = format ! (
1000+ "systemd.mount-extra={}:{}:{}:{}" ,
1001+ boot. source,
1002+ boot. target,
1003+ boot. fstype,
1004+ boot. options. as_deref( ) . unwrap_or( "defaults" )
1005+ ) ;
1006+ kargs. extend ( & Cmdline :: from ( mount_extra. as_str ( ) ) ) ;
1007+ tracing:: debug!( "Add {mount_extra} to kargs if has seperate /boot" ) ;
1008+ }
1009+ }
1010+
9841011 // Finally map into &[&str] for ostree_container
9851012 let kargs_strs: Vec < & str > = kargs. iter_str ( ) . collect ( ) ;
9861013
@@ -1893,6 +1920,7 @@ fn remove_all_except_loader_dirs(bootdir: &Dir, is_ostree: bool) -> Result<()> {
18931920 if let Some ( subdir) = bootdir. open_dir_noxdev ( & file_name) ? {
18941921 remove_all_in_dir_no_xdev ( & subdir, false )
18951922 . with_context ( || format ! ( "Removing directory contents: {}" , file_name) ) ?;
1923+ bootdir. remove_dir ( & file_name) ?;
18961924 }
18971925 } else {
18981926 bootdir
@@ -2109,7 +2137,7 @@ pub(crate) async fn install_to_filesystem(
21092137 }
21102138 rootfs_fd
21112139 } else {
2112- target_rootfs_fd. clone ( )
2140+ target_rootfs_fd. try_clone ( ) ?
21132141 } ;
21142142
21152143 match fsopts. replace {
0 commit comments