if config.bind_user:
cmdline += ["--bind-user", getpass.getuser()]
- if config.runtime_scratch == ConfigFeature.enabled or (
- config.runtime_scratch == ConfigFeature.auto and config.output_format == OutputFormat.disk
- ):
- scratch = Path(
- stack.enter_context(tempfile.TemporaryDirectory(dir="/var/tmp", prefix="mkosi-scratch-"))
- )
- scratch.chmod(0o1777)
- uidmap = "rootidmap" if scratch.stat().st_uid != 0 else "noidmap"
- cmdline += ["--bind", f"{scratch}:/var/tmp:{uidmap}"]
-
if args.verb == Verb.boot and config.forward_journal:
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
addr = (
storage_target_mode: ConfigFeature
runtime_trees: list[ConfigTree]
runtime_size: Optional[int]
- runtime_scratch: ConfigFeature
runtime_network: Network
runtime_build_sources: bool
bind_user: bool
help="Grow disk images to the specified size before booting them",
scope=SettingScope.main,
),
- ConfigSetting(
- dest="runtime_scratch",
- metavar="FEATURE",
- section="Runtime",
- parse=config_parse_feature,
- help="Mount extra scratch space to /var/tmp",
- scope=SettingScope.main,
- ),
ConfigSetting(
dest="runtime_network",
section="Runtime",
nargs=0,
action=IgnoreAction,
)
- parser.add_argument(
- "--default",
- action=IgnoreAction,
- )
- parser.add_argument(
- "--cache",
- action=IgnoreAction,
- )
+ for arg in ("--default", "--cache", "--runtime-scratch"):
+ parser.add_argument(arg, action=IgnoreAction)
parser.add_argument(
"verb",
Extra Kernel Command Line: {line_join_list(config.kernel_command_line_extra)}
Runtime Trees: {line_join_list(config.runtime_trees)}
Runtime Size: {format_bytes_or_none(config.runtime_size)}
- Runtime Scratch: {config.runtime_scratch}
Runtime Network: {config.runtime_network}
Runtime Build Sources: {config.runtime_build_sources}
Bind User: {yes_no(config.bind_user)}
)
-def want_scratch(config: Config) -> bool:
- return config.runtime_scratch == ConfigFeature.enabled or (
- config.runtime_scratch == ConfigFeature.auto
- and config.find_binary(f"mkfs.{config.distribution.installer.filesystem()}") is not None
- )
-
-
-@contextlib.contextmanager
-def generate_scratch_fs(config: Config) -> Iterator[Path]:
- with tempfile.NamedTemporaryFile(dir="/var/tmp", prefix="mkosi-scratch-") as scratch:
- maybe_make_nocow(Path(scratch.name))
- scratch.truncate(1024**4)
- fs = config.distribution.installer.filesystem()
- extra = config.finalize_environment().get(f"SYSTEMD_REPART_MKFS_OPTIONS_{fs.upper()}", "")
- run(
- [f"mkfs.{fs}", "-L", "scratch", "-q", *extra.split(), workdir(Path(scratch.name))],
- sandbox=config.sandbox(options=["--bind", scratch.name, workdir(Path(scratch.name))]),
- )
- yield Path(scratch.name)
-
-
def finalize_firmware(
config: Config,
kernel: Optional[Path],
sock = stack.enter_context(start_virtiofsd(config, tree.source))
add_virtiofs_mount(sock, Path("/root/src") / (tree.target or ""), cmdline, credentials)
- if want_scratch(config) or config.output_format in (OutputFormat.disk, OutputFormat.esp):
+ if config.output_format in (OutputFormat.disk, OutputFormat.esp):
cmdline += ["-device", "virtio-scsi-pci,id=mkosi"]
- if want_scratch(config):
- scratch = stack.enter_context(generate_scratch_fs(config))
- blockdev = [
- "driver=raw",
- "node-name=scratch",
- "discard=unmap",
- "file.driver=file",
- f"file.filename={scratch}",
- "file.aio=io_uring",
- "cache.direct=on",
- "cache.no-flush=on",
- ]
- cmdline += [
- "-blockdev", ",".join(blockdev),
- "-device", "virtio-blk-pci,drive=scratch",
- ] # fmt: skip
- kcl += [
- f"systemd.mount-extra=LABEL=scratch:/var/tmp:{config.distribution.installer.filesystem()}"
- ]
-
if config.output_format == OutputFormat.cpio:
cmdline += ["-initrd", fname]
elif (
bytes. Additionally, the suffixes `K`, `M` and `G` can be used to
specify a size in kilobytes, megabytes and gigabytes respectively.
-`RuntimeScratch=`, `--runtime-scratch=`
-: Takes a boolean value or `auto`. Specifies whether to mount extra
- scratch space to `/var/tmp`. If enabled, practically unlimited scratch
- space is made available under `/var/tmp` when booting the image with
- `mkosi vm`, `mkosi boot` or `mkosi shell`.
-
- Note that using this feature with `mkosi vm` requires systemd v254
- or newer in the guest.
-
`RuntimeNetwork=`, `--runtime-network=`
: Takes one of `user`, `interface` or `none`. Defaults to `user`.
Specifies the networking to set up when booting the image. `user` sets
Previous separate Include and Exclude options that take regexps are now
deprecated and are replaced by a single option that takes a list of
positive and negative globs. The new option is FirmwareFiles=.
+- The `RuntimeScratch=` option has been dropped. Use `RuntimeSize=`
+ instead to grow the image before booting it.
## v25
"RootShell": "/bin/tcsh",
"RuntimeBuildSources": true,
"RuntimeNetwork": "interface",
- "RuntimeScratch": "enabled",
"RuntimeSize": 8589934592,
"RuntimeTrees": [
{
root_shell="/bin/tcsh",
runtime_build_sources=True,
runtime_network=Network.interface,
- runtime_scratch=ConfigFeature.enabled,
runtime_size=8589934592,
runtime_trees=[
ConfigTree(Path("/foo/bar"), Path("/baz")),