Skip to content

Commit

Permalink
lib/bootloader: Write to PReP partition for ppc64le
Browse files Browse the repository at this point in the history
Bootloader code currently writes required data to base/parent
device (eg /dev/sda). This logic does not work for ppc64le
architecture as bootloader configuration has to be written
to PRePboot partition(typically first partition of disk).

This patch adds code to identify PowerPC-PReP-boot partition
(for ppc64le architecture) using lsblk command and writes
bootloader data to it.

Co-authored-by: Colin Walters <[email protected]>
Signed-off-by: Sachin Sant <[email protected]>
Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
sacsant and cgwalters committed Jul 16, 2024
1 parent 21447f2 commit 8e236b8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
27 changes: 25 additions & 2 deletions lib/src/bootloader.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
use anyhow::Result;
use camino::Utf8Path;
use camino::{Utf8Path, Utf8PathBuf};
use fn_error_context::context;

use crate::blockdev::PartitionTable;
use crate::task::Task;

/// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel)
pub(crate) const EFI_DIR: &str = "efi";
pub(crate) const PREPBOOT_GUID: &str = "9E1A2D38-C612-4316-AA26-8B49521E5A8B";
pub(crate) const PREPBOOT_LABEL: &str = "PowerPC-PReP-boot";

/// Find the device to pass to bootupd. Only on powerpc64 right now
/// we explicitly find one with a specific label.
///
/// This should get fixed once we execute on https://github.com/coreos/bootupd/issues/432
fn get_bootupd_device(device: &PartitionTable) -> Result<Utf8PathBuf> {
#[cfg(target_arch = "powerpc64")]
{
return device
.partitions
.iter()
.find(|p| p.uuid.as_deref() == Some(PREPBOOT_GUID))
.ok_or_else(|| {
anyhow::anyhow!("Failed to find PReP partition with GUID {PREPBOOT_GUID}")
})
.map(|dev| dev.node.as_str().into());
}
#[cfg(not(target_arch = "powerpc64"))]
return Ok(device.path().into());
}

#[context("Installing bootloader")]
pub(crate) fn install_via_bootupd(
Expand All @@ -17,7 +39,8 @@ pub(crate) fn install_via_bootupd(
let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv");
// bootc defaults to only targeting the platform boot method.
let bootupd_opts = (!configopts.generic_image).then_some(["--update-firmware", "--auto"]);
let devpath = device.path();

let devpath = get_bootupd_device(device)?;
let args = ["backend", "install", "--write-uuid"]
.into_iter()
.chain(verbose)
Expand Down
4 changes: 2 additions & 2 deletions lib/src/install/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ pub(crate) fn install_create_rootfs(
&mut sgdisk.cmd,
partno,
"0:+4M",
"PowerPC-PReP-boot",
Some("9E1A2D38-C612-4316-AA26-8B49521E5A8B"),
crate::bootloader::PREPBOOT_LABEL,
Some(crate::bootloader::PREPBOOT_GUID),
);
} else {
anyhow::bail!("Unsupported architecture: {}", std::env::consts::ARCH);
Expand Down

0 comments on commit 8e236b8

Please sign in to comment.