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

install: Support non EFI partition format #623

Merged
merged 1 commit into from
Jun 21, 2024
Merged
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
30 changes: 17 additions & 13 deletions lib/src/install/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ use super::RW_KARG;
use crate::mount;
use crate::task::Task;

pub(crate) const BOOTPN: u32 = 3;
// This ensures we end up under 512 to be small-sized.
pub(crate) const BOOTPN_SIZE_MB: u32 = 510;
pub(crate) const EFIPN: u32 = 2;
pub(crate) const EFIPN_SIZE_MB: u32 = 512;

#[derive(clap::ValueEnum, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand Down Expand Up @@ -240,6 +238,8 @@ pub(crate) fn install_create_rootfs(
let bootfs = mntdir.join("boot");
std::fs::create_dir_all(bootfs)?;

let mut partno = 0;

// Run sgdisk to create partitions.
let mut sgdisk = Task::new("Initializing partitions", "sgdisk");
// sgdisk is too verbose
Expand All @@ -250,18 +250,20 @@ pub(crate) fn install_create_rootfs(
#[allow(unused_assignments)]
if cfg!(target_arch = "x86_64") {
// BIOS-BOOT
partno += 1;
sgdisk_partition(
&mut sgdisk.cmd,
1,
partno,
"0:+1M",
"BIOS-BOOT",
Some("21686148-6449-6E6F-744E-656564454649"),
);
} else if cfg!(target_arch = "aarch64") {
// reserved
partno += 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Tangential but at this point we can kill the reserved partition on aarch64, we don't have the same use case/problems that motivated it on CoreOS with having symmetry with x86_64 - makes sense in a followup)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ #624

sgdisk_partition(
&mut sgdisk.cmd,
1,
partno,
"0:+1M",
"reserved",
Some("8DA63339-0007-60C0-C436-083AC8230908"),
Expand All @@ -271,24 +273,23 @@ pub(crate) fn install_create_rootfs(
}

let esp_partno = if super::ARCH_USES_EFI {
partno += 1;
sgdisk_partition(
&mut sgdisk.cmd,
EFIPN,
partno,
format!("0:+{EFIPN_SIZE_MB}M"),
"EFI-SYSTEM",
Some("C12A7328-F81F-11D2-BA4B-00A0C93EC93B"),
);
Some(EFIPN)
Some(partno)
} else {
None
};

// Initialize the /boot filesystem. Note that in the future, we may match
// what systemd/uapi-group encourages and make /boot be FAT32 as well, as
// it would aid systemd-boot.
let use_xbootldr = block_setup.requires_bootpart();
let mut partno = EFIPN;
if use_xbootldr {
let boot_partno = if block_setup.requires_bootpart() {
partno += 1;
sgdisk_partition(
&mut sgdisk.cmd,
Expand All @@ -297,8 +298,11 @@ pub(crate) fn install_create_rootfs(
"boot",
None,
);
}
let rootpn = if use_xbootldr { BOOTPN + 1 } else { EFIPN + 1 };
Some(partno)
} else {
None
};
let rootpn = partno + 1;
let root_size = root_size
.map(|v| Cow::Owned(format!("0:{v}M")))
.unwrap_or_else(|| Cow::Borrowed("0:0"));
Expand Down Expand Up @@ -379,8 +383,8 @@ pub(crate) fn install_create_rootfs(
};

// Initialize the /boot filesystem
let bootdev = if use_xbootldr {
Some(findpart(BOOTPN)?)
let bootdev = if let Some(bootpn) = boot_partno {
Some(findpart(bootpn)?)
} else {
None
};
Expand Down