Skip to content

Commit a291e5b

Browse files
authored
Merge pull request #41 from cgwalters/install-consume-space
install: Consume all space for root by default
2 parents 8381194 + 528d1bb commit a291e5b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/src/install.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::borrow::Cow;
12
use std::fmt::Display;
23
use std::io::BufWriter;
34
use std::io::Write;
@@ -68,8 +69,6 @@ const BOOTPN: u32 = 3;
6869
// This ensures we end up under 512 to be small-sized.
6970
const BOOTPN_SIZE_MB: u32 = 510;
7071
const ROOTPN: u32 = 4;
71-
// TODO calculate from ostree commit
72-
const ROOTFS_SIZE_MB: u32 = 5 * 1024;
7372
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
7473
const EFIPN: u32 = 2;
7574
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
@@ -91,10 +90,14 @@ pub(crate) struct InstallOpts {
9190
#[clap(long)]
9291
pub(crate) wipe: bool,
9392

94-
/// Size of the root partition (default specifier: M). Allowed specifiers: M (mebibytes), G (gibibytes), T (tebibytes)
93+
/// Size of the root partition (default specifier: M). Allowed specifiers: M (mebibytes), G (gibibytes), T (tebibytes).
94+
///
95+
/// By default, all remaining space on the disk will be used.
9596
#[clap(long)]
9697
pub(crate) root_size: Option<String>,
9798

99+
// TODO: A size specifier which allocates free space for the root in *addition* to the base container image size
100+
// pub(crate) root_additional_size: Option<String>
98101
/// The transport; e.g. oci, oci-archive. Defaults to `registry`.
99102
#[clap(long, default_value = "registry")]
100103
pub(crate) target_transport: String,
@@ -493,8 +496,7 @@ fn install_create_rootfs(state: &State) -> Result<RootSetup> {
493496
.as_deref()
494497
.map(crate::blockdev::parse_size_mib)
495498
.transpose()
496-
.context("Parsing root size")?
497-
.unwrap_or(ROOTFS_SIZE_MB as u64);
499+
.context("Parsing root size")?;
498500

499501
// Create a temporary directory to use for mount points. Note that we're
500502
// in a mount namespace, so these should not be visible on the host.
@@ -553,10 +555,13 @@ fn install_create_rootfs(state: &State) -> Result<RootSetup> {
553555
"boot",
554556
None,
555557
);
558+
let root_size = root_size
559+
.map(|v| Cow::Owned(format!("0:{v}M")))
560+
.unwrap_or_else(|| Cow::Borrowed("0:0"));
556561
sgdisk_partition(
557562
&mut sgdisk.cmd,
558563
ROOTPN,
559-
format!("0:{root_size}M"),
564+
root_size,
560565
"root",
561566
Some("0FC63DAF-8483-4772-8E79-3D69D8477DE4"),
562567
);

0 commit comments

Comments
 (0)