]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Remove support for RuntimeScratch=
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 21 Oct 2025 11:27:29 +0000 (13:27 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 21 Oct 2025 11:30:02 +0000 (13:30 +0200)
systemd-vmspawn solves the problem solved by RuntimeScratch= by
resizing the entire image instead. Let's align with vmspawn and drop
RuntimeScratch= and require users to use RuntimeSize= instead.

mkosi/__init__.py
mkosi/config.py
mkosi/qemu.py
mkosi/resources/man/mkosi.1.md
mkosi/resources/man/mkosi.news.7.md
tests/test_json.py

index 556ed70d100182c58401c723f500a33e13373e87..4bbd5e6c621f9baedf0f5cb67ae25992151d72af 100644 (file)
@@ -4234,16 +4234,6 @@ def run_shell(args: Args, config: Config) -> None:
         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 = (
index 01f02cba2f51bb060290da940cfcb373c439a12d..cf42dc328a218d810ba014680ac260fe9f24a608 100644 (file)
@@ -2111,7 +2111,6 @@ class Config:
     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
@@ -4004,14 +4003,6 @@ SETTINGS: list[ConfigSetting[Any]] = [
         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",
@@ -4497,14 +4488,8 @@ def create_argument_parser(chdir: bool = True) -> argparse.ArgumentParser:
         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",
@@ -5761,7 +5746,6 @@ def summary(config: Config) -> str:
           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)}
index 64f6c655e93c75ff9ea448e59054cd79473f1bc3..2e9ef759c1e3863db2f851c4041e493a819a62bc 100644 (file)
@@ -631,27 +631,6 @@ def qemu_version(config: Config, binary: Path) -> GenericVersion:
     )
 
 
-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],
@@ -1422,29 +1401,9 @@ def run_qemu(args: Args, config: Config) -> None:
             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 (
index 3406e9c081c6ad1e6aedd83357e5061c27251fa0..8dfd038b6d78e79e736d8b136e93641646446f17 100644 (file)
@@ -1933,15 +1933,6 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
     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
index 5e2fea52b154720ab167fb93bc09d4b7dfadca15..b6848733d6475de8a2d9e5e54387086b6967d7a1 100644 (file)
@@ -34,6 +34,8 @@
   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
 
index c43a5fe89935c964689c481a0b47875427baba01..d2d5c8759a9421c894c896c249d4b23e2fb41fb7 100644 (file)
@@ -317,7 +317,6 @@ def test_config() -> None:
             "RootShell": "/bin/tcsh",
             "RuntimeBuildSources": true,
             "RuntimeNetwork": "interface",
-            "RuntimeScratch": "enabled",
             "RuntimeSize": 8589934592,
             "RuntimeTrees": [
                 {
@@ -559,7 +558,6 @@ def test_config() -> None:
         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")),