Skip to content

Commit

Permalink
feat: explicit image sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
koehlma committed May 9, 2024
1 parent edbc668 commit 8b19e40
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crates/rugpi-bakery/src/bake/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ pub fn make_image(image_config: &ImageConfig, src: &Path, image: &Path) -> Anyho
fs::create_dir_all(parent).ok();
}
info!("creating image (size: {} bytes)", size);
run!(["fallocate", "-l", "{size}", image])?;
if let Some(size) = &image_config.size {
println!("Allocate image of size {size}.");
run!(["fallocate", "-l", "{size}", image])?;
} else {
run!(["fallocate", "-l", "{size}", image])?;
}
let layout = image_config.layout.clone().unwrap_or_else(pi_image_layout);
sfdisk_apply_layout(image, layout.sfdisk_render())?;
let disk_id = get_disk_id(image)?;
Expand Down
1 change: 1 addition & 0 deletions crates/rugpi-bakery/src/project/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct ImageConfig {
/// Indicates which boot flow to use for the image.
#[serde(default)]
pub boot_flow: BootFlow,
pub size: Option<String>,
pub layout: Option<ImageLayout>,
}

Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap/recipes/setup-boot/steps/02-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cat >"${RUGPI_ROOT_DIR}/boot/efi/loader/entries/rugpi-a.conf" <<EOF
title Rugpi System A
linux /rugpi/a/vmlinuz
initrd /rugpi/a/initrd.img
options root=/dev/sda2 rw
options root=/dev/sda2 ro init=/usr/bin/rugpi-ctrl
EOF

mkdir -p "${RUGPI_ROOT_DIR}/boot/efi/rugpi/a"
Expand Down
1 change: 1 addition & 0 deletions tests/bootstrap/rugpi-bakery.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ layer = "generic-boot"
architecture = "amd64"
include_firmware = "none"
boot_flow = "none"
size = "32G"

[images.generic.layout]
kind = "gpt"
Expand Down

0 comments on commit 8b19e40

Please sign in to comment.