diff --git a/mkosi/initrd.py b/mkosi/initrd.py index 80c21ed38..14736033a 100644 --- a/mkosi/initrd.py +++ b/mkosi/initrd.py @@ -169,6 +169,20 @@ def main() -> None: cmdline += ["--sandbox-tree", sandbox_tree] + # Generate crypttab with all the x-initrd.attach entries + if Path("/etc/crypttab").exists(): + crypttab = [] + for line in Path("/etc/crypttab").read_text().splitlines(): + entry = line.split() + if len(entry) < 4 or entry[0].startswith("#") or "x-initrd.attach" not in entry[3]: + continue + crypttab.append(line) + if crypttab: + with (Path(staging_dir) / "crypttab").open("w") as f: + f.write("# Automatically generated by mkosi-initrd\n") + f.write("\n".join(crypttab)) + cmdline += ["--extra-tree", f"{staging_dir}/crypttab:/etc/crypttab"] + # Prefer dnf as dnf5 has not yet officially replaced it and there's a much bigger chance that there # will be a populated dnf cache directory. run(