Skip to content
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
8 changes: 7 additions & 1 deletion crates/lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,12 @@ pub(crate) struct InstallToDiskOpts {
#[clap(flatten)]
#[serde(flatten)]
pub(crate) composefs_opts: InstallComposefsOpts,

/// Whether to use systemd-repart for partitioning.
/// This requires the image to have repart.d definitions
#[clap(long)]
#[serde(default)]
pub(crate) run_repart: bool,
}

#[derive(ValueEnum, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand Down Expand Up @@ -2340,7 +2346,7 @@ pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {

let state = state.clone();
let rootfs = tokio::task::spawn_blocking(move || {
baseline::install_create_rootfs(&state, block_opts)
baseline::install_create_rootfs(&state, block_opts, opts.run_repart)
})
.await??;
(rootfs, loopback_dev)
Expand Down
5 changes: 4 additions & 1 deletion crates/lib/src/install/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ fn use_discoverable_partitions(state: &State) -> bool {

// This ensures we end up under 512 to be small-sized.
pub(crate) const BOOTPN_SIZE_MB: u32 = 510;
// NOTE: If you change this or [`CFS_EFIPN_SIZE_MB`] below,
// make sure to update the test test-install-reaprt.nu
pub(crate) const EFIPN_SIZE_MB: u32 = 512;
/// EFI Partition size for composefs installations
/// We need more space than ostree as we have UKIs and UKI addons
Expand Down Expand Up @@ -625,6 +627,7 @@ fn sfdisk(
pub(crate) fn install_create_rootfs(
state: &State,
opts: InstallBlockDeviceOpts,
run_repart: bool,
) -> Result<RootSetup> {
let install_config = state.install_config.as_ref();
let luks_name = "root";
Expand Down Expand Up @@ -660,7 +663,7 @@ pub(crate) fn install_create_rootfs(
std::fs::remove_dir_all(&mntdir)?;
}

let use_systemd_repart = can_use_systemd_repart();
let use_systemd_repart = run_repart && can_use_systemd_repart();

// Use the install configuration to find the block setup, if we have one
let block_setup = if let Some(config) = install_config {
Expand Down
4 changes: 4 additions & 0 deletions docs/src/man/bootc-install-to-disk.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ set `discoverable-partitions = true` in their install configuration

Name of the UKI addons to install without the ".efi.addon" suffix. This option can be provided multiple times if multiple addons are to be installed (composefs backend only)

**--run-repart**

Whether to use systemd-repart for partitioning. This requires the image to have repart.d definitions

<!-- END GENERATED OPTIONS -->

# EXAMPLES
Expand Down
38 changes: 36 additions & 2 deletions tmt/tests/booted/test-install-repart.nu
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,40 @@ EOF

run_install_to_disk localhost/bootc-repart []

# since `--no-repart` wasn't passed in, sfdisk should've been used
let loop = (losetup -f --show /var/disk.img | str trim)
try {
partx -u $loop
udevadm settle
let parts = (lsblk -J -b -o name,parttype,partuuid,size $loop | from json)
let children = ($parts.blockdevices.0.children)
let part_types = ($children | get parttype)

# ESP GUID
let esp_guid = "c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
assert ($part_types | any {|t| ($t | str downcase) == $esp_guid }) "ESP partition not found"

let esp_mb = if (tap is_composefs) { 2048 } else { 512 }
# Verify ESP size
let esp_part = ($children | where {|t| ($t.parttype | str downcase) == $esp_guid } | first)
let esp_size_bytes = ($esp_part.size | into int)
let esp_expected = ($esp_mb * 1024 * 1024)

assert ($esp_size_bytes == $esp_expected) $"ESP should be ($esp_mb)M from sfdisk, got ($esp_size_bytes) bytes"

print "PASS: sfdisk created BIOS + ESP + root partitions"
} catch { |e|
losetup -d $loop
error make { msg: $"No-repart verification failed: ($e.msg)" }
}

losetup -d $loop

rm -rvf /var/disk.img
truncate -s 10G /var/disk.img

run_install_to_disk localhost/bootc-repart ["--run-repart"]

# Verify partition layout
let loop = (losetup -f --show /var/disk.img | str trim)
try {
Expand Down Expand Up @@ -184,13 +218,13 @@ EOF
truncate -s 10G /var/disk.img
setenforce 0

run_install_to_disk localhost/bootc-repart-noroot ["--filesystem" "ext4" "--root-size" "7G"]
run_install_to_disk localhost/bootc-repart-noroot ["--run-repart" "--filesystem" "ext4" "--root-size" "7G"]

# Verify partition layout
verify_part_layout_second_boot

# Install again without passing in root-size make sure it works
run_install_to_disk localhost/bootc-repart-noroot ["--filesystem" "ext4"]
run_install_to_disk localhost/bootc-repart-noroot ["--run-repart" "--filesystem" "ext4"]

# Verify partition layout (again)
verify_part_layout_second_boot
Expand Down
Loading