Skip to content

Commit 63d3e3e

Browse files
authored
Merge pull request #623 from yoheiueda/non-efi
install: Support non EFI partition format
2 parents 72bca1b + 41ea0b9 commit 63d3e3e

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

lib/src/install/baseline.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ use super::RW_KARG;
2929
use crate::mount;
3030
use crate::task::Task;
3131

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

3836
#[derive(clap::ValueEnum, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
@@ -239,6 +237,8 @@ pub(crate) fn install_create_rootfs(
239237
let bootfs = mntdir.join("boot");
240238
std::fs::create_dir_all(bootfs)?;
241239

240+
let mut partno = 0;
241+
242242
// Run sgdisk to create partitions.
243243
let mut sgdisk = Task::new("Initializing partitions", "sgdisk");
244244
// sgdisk is too verbose
@@ -249,18 +249,20 @@ pub(crate) fn install_create_rootfs(
249249
#[allow(unused_assignments)]
250250
if cfg!(target_arch = "x86_64") {
251251
// BIOS-BOOT
252+
partno += 1;
252253
sgdisk_partition(
253254
&mut sgdisk.cmd,
254-
1,
255+
partno,
255256
"0:+1M",
256257
"BIOS-BOOT",
257258
Some("21686148-6449-6E6F-744E-656564454649"),
258259
);
259260
} else if cfg!(target_arch = "aarch64") {
260261
// reserved
262+
partno += 1;
261263
sgdisk_partition(
262264
&mut sgdisk.cmd,
263-
1,
265+
partno,
264266
"0:+1M",
265267
"reserved",
266268
Some("8DA63339-0007-60C0-C436-083AC8230908"),
@@ -270,24 +272,23 @@ pub(crate) fn install_create_rootfs(
270272
}
271273

272274
let esp_partno = if super::ARCH_USES_EFI {
275+
partno += 1;
273276
sgdisk_partition(
274277
&mut sgdisk.cmd,
275-
EFIPN,
278+
partno,
276279
format!("0:+{EFIPN_SIZE_MB}M"),
277280
"EFI-SYSTEM",
278281
Some("C12A7328-F81F-11D2-BA4B-00A0C93EC93B"),
279282
);
280-
Some(EFIPN)
283+
Some(partno)
281284
} else {
282285
None
283286
};
284287

285288
// Initialize the /boot filesystem. Note that in the future, we may match
286289
// what systemd/uapi-group encourages and make /boot be FAT32 as well, as
287290
// it would aid systemd-boot.
288-
let use_xbootldr = block_setup.requires_bootpart();
289-
let mut partno = EFIPN;
290-
if use_xbootldr {
291+
let boot_partno = if block_setup.requires_bootpart() {
291292
partno += 1;
292293
sgdisk_partition(
293294
&mut sgdisk.cmd,
@@ -296,8 +297,11 @@ pub(crate) fn install_create_rootfs(
296297
"boot",
297298
None,
298299
);
299-
}
300-
let rootpn = if use_xbootldr { BOOTPN + 1 } else { EFIPN + 1 };
300+
Some(partno)
301+
} else {
302+
None
303+
};
304+
let rootpn = partno + 1;
301305
let root_size = root_size
302306
.map(|v| Cow::Owned(format!("0:{v}M")))
303307
.unwrap_or_else(|| Cow::Borrowed("0:0"));
@@ -379,8 +383,8 @@ pub(crate) fn install_create_rootfs(
379383
};
380384

381385
// Initialize the /boot filesystem
382-
let bootdev = if use_xbootldr {
383-
Some(findpart(BOOTPN)?)
386+
let bootdev = if let Some(bootpn) = boot_partno {
387+
Some(findpart(bootpn)?)
384388
} else {
385389
None
386390
};

0 commit comments

Comments
 (0)