supported distributions except Clear Linux and this option
translates to enabling dracut's hostonly option.
+`CacheInitrd=`, `--cache-initrd`
+
+: If specified, and incremental mode is used, mkosi will build the initrd
+ in the cache image and reuse it in the final image. Note that this means
+ that any changes that are only applied to the final image and not the
+ cached image won't be included in the initrd.
+
`UsrOnly=`, `--usr-only`
: If specified, `mkosi` will only add the `/usr/` directory tree
action=BooleanAction,
help="Enable dracut hostonly option",
)
+ group.add_argument(
+ "--cache-initrd",
+ metavar="BOOL",
+ action=BooleanAction,
+ help="When using incremental mode, build the initrd in the cache image and don't rebuild it in the final image",
+ )
group.add_argument(
"--split-artifacts",
metavar="BOOL",
run(["systemctl", "--root", root, "enable", "systemd-networkd"])
-def run_kernel_install(args: MkosiArgs, root: Path, do_run_build_script: bool, for_cache: bool) -> None:
- if not args.bootable or do_run_build_script or for_cache:
+def run_kernel_install(args: MkosiArgs, root: Path, do_run_build_script: bool, for_cache: bool, cached: bool) -> None:
+ if not args.bootable or do_run_build_script:
+ return
+
+ if not args.cache_initrd and for_cache:
+ return
+
+ if args.cache_initrd and cached:
return
with complete_step("Generating initramfs images…"):
install_build_src(args, root, do_run_build_script, for_cache)
install_build_dest(args, root, do_run_build_script, for_cache)
install_extra_trees(args, root, for_cache)
- run_kernel_install(args, root, do_run_build_script, for_cache)
+ run_kernel_install(args, root, do_run_build_script, for_cache, cached_tree)
install_boot_loader(args, root, loopdev, do_run_build_script, cached_tree)
set_root_password(args, root, do_run_build_script, cached_tree)
set_serial_terminal(args, root, do_run_build_script, cached_tree)
"ephemeral": False,
"with_unified_kernel_images": True,
"hostonly_initrd": False,
+ "cache_initrd": False,
"ssh": False,
"ssh_key": None,
"ssh_timeout": 0,
]
if "HostonlyInitrd" in mk_config_output:
self.reference_config[job_name]["hostonly_initrd"] = mk_config_output["HostonlyInitrd"]
+ if "CacheInitrd" in mk_config_output:
+ self.reference_config[job_name]["cache_initrd"] = mk_config_output["CacheInitrd"]
if "MachineID" in mk_config_output:
self.reference_config[job_name]["MachineID"] = mk_config_output["MachineID"]
if "Packages" in mk_config: