@@ -40,6 +40,7 @@ use ostree_ext::ostree;
40
40
use ostree_ext:: prelude:: Cast ;
41
41
use ostree_ext:: sysroot:: SysrootLock ;
42
42
use rustix:: fs:: { FileTypeExt , MetadataExt as _} ;
43
+ use rustix:: thread:: Pid ;
43
44
use serde:: { Deserialize , Serialize } ;
44
45
45
46
use self :: baseline:: InstallBlockDeviceOpts ;
@@ -56,6 +57,8 @@ use crate::utils::sigpolicy_from_opts;
56
57
const BOOT : & str = "boot" ;
57
58
/// Directory for transient runtime state
58
59
const RUN_BOOTC : & str = "/run/bootc" ;
60
+ /// The default path for the host rootfs
61
+ const ALONGSIDE_ROOT_MOUNT : & str = "/target" ;
59
62
/// This is an ext4 special directory we need to ignore.
60
63
const LOST_AND_FOUND : & str = "lost+found" ;
61
64
/// The filename of the composefs EROFS superblock; TODO move this into ostree
@@ -316,9 +319,10 @@ pub(crate) struct InstallToExistingRootOpts {
316
319
#[ clap( long) ]
317
320
pub ( crate ) acknowledge_destructive : bool ,
318
321
319
- /// Path to the mounted root; it's expected to invoke podman with
320
- /// `-v /:/target`, then supplying this argument is unnecessary.
321
- #[ clap( default_value = "/target" ) ]
322
+ /// Path to the mounted root; this is now not necessary to provide.
323
+ /// Historically it was necessary to ensure the host rootfs was mounted at here
324
+ /// via e.g. `-v /:/target`.
325
+ #[ clap( default_value = ALONGSIDE_ROOT_MOUNT ) ]
322
326
pub ( crate ) root_path : Utf8PathBuf ,
323
327
}
324
328
@@ -1631,6 +1635,22 @@ pub(crate) async fn install_to_filesystem(
1631
1635
// And the last bit of state here is the fsopts, which we also destructure now.
1632
1636
let mut fsopts = opts. filesystem_opts ;
1633
1637
1638
+ // If we're doing an alongside install, automatically set up the host rootfs
1639
+ // mount if it wasn't done already.
1640
+ if targeting_host_root
1641
+ && fsopts. root_path . as_str ( ) == ALONGSIDE_ROOT_MOUNT
1642
+ && !fsopts. root_path . try_exists ( ) ?
1643
+ {
1644
+ std:: fs:: create_dir ( ALONGSIDE_ROOT_MOUNT ) ?;
1645
+ crate :: mount:: bind_mount_from_pidns (
1646
+ Pid :: from_raw ( 1 ) . unwrap ( ) ,
1647
+ "/" . into ( ) ,
1648
+ ALONGSIDE_ROOT_MOUNT . into ( ) ,
1649
+ true ,
1650
+ )
1651
+ . context ( "Mounting host / to {ALONGSIDE_ROOT_MOUNT}" ) ?;
1652
+ }
1653
+
1634
1654
// Check that the target is a directory
1635
1655
{
1636
1656
let root_path = & fsopts. root_path ;
0 commit comments