From: Daan De Meyer Date: Tue, 21 Oct 2025 11:27:29 +0000 (+0200) Subject: Remove support for RuntimeScratch= X-Git-Tag: v26~66^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=054d0690b08afa6163b53ad2dca0e1374e9069f7;p=thirdparty%2Fmkosi.git Remove support for RuntimeScratch= 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. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 556ed70d1..4bbd5e6c6 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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 = ( diff --git a/mkosi/config.py b/mkosi/config.py index 01f02cba2..cf42dc328 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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)} diff --git a/mkosi/qemu.py b/mkosi/qemu.py index 64f6c655e..2e9ef759c 100644 --- a/mkosi/qemu.py +++ b/mkosi/qemu.py @@ -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 ( diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index 3406e9c08..8dfd038b6 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -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 diff --git a/mkosi/resources/man/mkosi.news.7.md b/mkosi/resources/man/mkosi.news.7.md index 5e2fea52b..b6848733d 100644 --- a/mkosi/resources/man/mkosi.news.7.md +++ b/mkosi/resources/man/mkosi.news.7.md @@ -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 diff --git a/tests/test_json.py b/tests/test_json.py index c43a5fe89..d2d5c8759 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -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")),