Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rdcore: Juggle physical root versus deployment root #1203

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ nav_order: 8

## Upcoming coreos-installer 0.19.0 (unreleased)

Major changes:


Minor changes:


Internal changes:

- rootmap/bind-boot: Support root devices using composefs

Packaging changes:



## coreos-installer 0.18.0 (2023-08-24)

Expand Down
6 changes: 3 additions & 3 deletions src/bin/rdcore/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ mod rootmap;
mod stream_hash;
mod unique_fs;

use anyhow::Result;
use anyhow::{Context, Result};
use clap::Parser;

use crate::cmdline::*;

fn main() -> Result<()> {
match Cmd::parse() {
Cmd::Kargs(c) => kargs::kargs(c),
Cmd::Rootmap(c) => rootmap::rootmap(c),
Cmd::BindBoot(c) => rootmap::bind_boot(c),
Cmd::Rootmap(c) => rootmap::rootmap(c).context("Configuring rootmap"),
Cmd::BindBoot(c) => rootmap::bind_boot(c).context("Failed to bind boot"),
Cmd::StreamHash(c) => stream_hash::stream_hash(c),
Cmd::VerifyUniqueFsLabel(c) => unique_fs::verify_unique_fs(c),
#[cfg(target_arch = "s390x")]
Expand Down
24 changes: 18 additions & 6 deletions src/bin/rdcore/rootmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ use libcoreinst::runcmd_output;

use crate::cmdline::*;

/// In the ostree model this will be the physical root mount. When using
/// composefs, the mount of / and /sysroot will be distinct.
const PHYSICAL_ROOT_MOUNT: &str = "sysroot";

pub fn rootmap(config: RootmapConfig) -> Result<()> {
// get the backing device for the root mount
let mount = Mount::from_existing(&config.root_mount)?;
let device = PathBuf::from(mount.device());
// Get the mount point for the deployment root, which will have e.g. /etc which we might parse
let rootfs_mount = Mount::from_existing(&config.root_mount)?;
// get the backing device for the "physical" root
let physical_root_path = format!("{}/{PHYSICAL_ROOT_MOUNT}", config.root_mount);
let physical_mount = Mount::from_existing(&physical_root_path)?;
let device = PathBuf::from(physical_mount.device());

// and from that we can collect all the parent backing devices too
let mut backing_devices = get_blkdev_deps_recursing(&device)?;
Expand All @@ -38,15 +45,18 @@ pub fn rootmap(config: RootmapConfig) -> Result<()> {
// for each of those, convert them to kargs
let mut kargs = Vec::new();
for backing_device in backing_devices {
if let Some(dev_kargs) = device_to_kargs(&mount, backing_device)? {
if let Some(dev_kargs) = device_to_kargs(&rootfs_mount, backing_device)? {
kargs.extend(dev_kargs);
}
}

// we push the root kargs last, this has the nice property that the final order of kargs goes
// from lowest level to highest; see also
// https://github.com/coreos/fedora-coreos-tracker/issues/465
kargs.push(format!("root=UUID={}", mount.get_filesystem_uuid()?));
kargs.push(format!(
"root=UUID={}",
physical_mount.get_filesystem_uuid()?
));

// we need this because with root= it's systemd that takes care of mounting via
// systemd-fstab-generator, and it defaults to read-only otherwise
Expand Down Expand Up @@ -224,7 +234,9 @@ fn get_luks_uuid(device: &Path) -> Result<String> {

pub fn bind_boot(config: BindBootConfig) -> Result<()> {
let boot_mount = Mount::from_existing(&config.boot_mount)?;
let root_mount = Mount::from_existing(&config.root_mount)?;
// We always operate here on the physical root
let physical_root_path = format!("{}/{PHYSICAL_ROOT_MOUNT}", config.root_mount);
let root_mount = Mount::from_existing(&physical_root_path)?;
let boot_uuid = boot_mount.get_filesystem_uuid()?;
let root_uuid = root_mount.get_filesystem_uuid()?;

Expand Down