OutputFormat,
SecureBootSignTool,
Verb,
+ format_bytes,
format_source_target,
parse_config,
summary,
from mkosi.util import (
InvokingUser,
flatten,
- format_bytes,
format_rlimit,
one_zero,
scopedenv,
if config.output_format == OutputFormat.disk and args.verb == Verb.boot:
run(["systemd-repart",
"--image", fname,
- "--size", "8G",
+ *([f"--size={config.runtime_size}"] if config.runtime_size else []),
"--no-pager",
"--dry-run=no",
"--offline=no",
tools_tree_release: Optional[str]
tools_tree_packages: list[str]
runtime_trees: list[tuple[Path, Optional[Path]]]
+ runtime_size: Optional[int]
# QEMU-specific options
qemu_gui: bool
parse=config_make_list_parser(delimiter=",", parse=make_source_target_paths_parser()),
help="Additional mounts to add when booting the image",
),
+ MkosiConfigSetting(
+ dest="runtime_size",
+ metavar="SIZE",
+ section="Host",
+ parse=config_parse_bytes,
+ help="Grow disk images to the specified size before booting them",
+ ),
)
MATCHES = (
return "\n ".join(items)
+def format_bytes(num_bytes: int) -> str:
+ if num_bytes >= 1024**3:
+ return f"{num_bytes/1024**3 :0.1f}G"
+ if num_bytes >= 1024**2:
+ return f"{num_bytes/1024**2 :0.1f}M"
+ if num_bytes >= 1024:
+ return f"{num_bytes/1024 :0.1f}K"
+
+ return f"{num_bytes}B"
+
+
+def format_bytes_or_none(num_bytes: Optional[int]) -> str:
+ return format_bytes(num_bytes) if num_bytes is not None else "none"
+
+
def summary(args: MkosiArgs, config: MkosiConfig) -> str:
def bold(s: Any) -> str:
return f"{Style.bold}{s}{Style.reset}"
Tools Tree Release: {none_to_none(config.tools_tree_release)}
Tools Tree Packages: {line_join_list(config.tools_tree_packages)}
Runtime Trees: {line_join_source_target_list(config.runtime_trees)}
+ Runtime Size: {format_bytes_or_none(config.runtime_size)}
QEMU GUI: {yes_no(config.qemu_gui)}
QEMU CPU Cores: {config.qemu_smp}
MkosiConfig,
OutputFormat,
QemuFirmware,
+ format_bytes,
)
from mkosi.log import die
from mkosi.partition import finalize_root, find_partitions
from mkosi.run import MkosiAsyncioThread, run, spawn
from mkosi.tree import copy_tree, rmtree
from mkosi.types import PathString
-from mkosi.util import format_bytes, qemu_check_kvm_support, qemu_check_vsock_support
+from mkosi.util import qemu_check_kvm_support, qemu_check_vsock_support
def machine_cid(config: MkosiConfig) -> int:
else:
fname = config.output_dir / config.output
- if config.output_format == OutputFormat.disk and not config.qemu_cdrom:
+ if config.output_format == OutputFormat.disk and config.runtime_size:
run(["systemd-repart",
"--definitions", "",
"--no-pager",
- "--size=8G",
+ f"--size={config.runtime_size}",
"--pretty=no",
"--offline=yes",
fname])
machine in these directories will be owned by the user running mkosi
on the host.
+`RuntimeSize=`, `--runtime-size`
+
+: If specified, disk images are grown to the specified size before
+ they're booted with systemd-nspawn or qemu. Takes a size in bytes.
+ Additionally, the suffixes `K`, `M` and `G` can be used to specify a
+ size in kilobytes, megabytes and gigabytes respectively.
+
## Supported distributions
Images may be created containing installations of the following
return True
-def format_bytes(num_bytes: int) -> str:
- if num_bytes >= 1024**3:
- return f"{num_bytes/1024**3 :0.1f}G"
- if num_bytes >= 1024**2:
- return f"{num_bytes/1024**2 :0.1f}M"
- if num_bytes >= 1024:
- return f"{num_bytes/1024 :0.1f}K"
-
- return f"{num_bytes}B"
-
-
def make_executable(path: Path) -> None:
st = path.stat()
os.chmod(path, st.st_mode | stat.S_IEXEC)