]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Install kernels to /boot 2154/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 10 Dec 2023 16:06:51 +0000 (17:06 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 10 Dec 2023 17:12:13 +0000 (18:12 +0100)
If users want to use XBOOTLDR partitions, then we have to put the
kernels in a separate location from the ESP stuff. Currently we put
everything in /efi when building the image, which means that users
don't have a way to specify that the kernels should be put in an
XBOOTLDR partition.

Let's fix this by installing kernels to /boot so that users can
populate an XBOOTLDR partition by simply using CopyFiles=/boot:/
in a repart xbootldr partition definition.

NEWS.md
mkosi/__init__.py
mkosi/resources/mkosi.md
tests/test_initrd.py

diff --git a/NEWS.md b/NEWS.md
index 175851ae1d39ac407103761340b558d226e2ef89..0c36ff59b24f2da02945a9f3bd84aa31b328c932 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,17 @@
 # mkosi Changelog
 
+## v20
+
+- During the image build we now install UKIs/kernels/initrds to `/boot`
+  instead of `/efi`. While this will generally not be noticeable, users
+  with custom systemd-repart ESP partition definitions will need to add
+  `CopyFiles=/boot:/` along with the usual `CopyFiles=/efi:/` to their
+  ESP partition definitions. By installing UKIs/kernels/initrds to
+  `/boot`, it becomes possible to use `/boot` to populate an XBOOTLDR
+  partition which wasn't possible before. Note that this is also safe to
+  do before `v20` so `CopyFiles=/boot:/` can unconditionally be added to
+  any ESP partition definition files.
+
 ## v19
 
 - Support for RHEL was added!
index 9abce4185f54515ba90ef855ed1d1c16949cfeb2..5420bab4d725995044588754c61f9f97f2bac4bc 100644 (file)
@@ -1039,12 +1039,12 @@ def prepare_grub_efi(state: MkosiState) -> None:
     with config.open("a") as f:
         f.write('if [ "${grub_platform}" == "efi" ]; then\n')
 
-        for uki in (state.root / "efi/EFI/Linux").glob("*.efi"):
+        for uki in (state.root / "boot/EFI/Linux").glob("*.efi"):
             f.write(
                 textwrap.dedent(
                     f"""\
                     menuentry "{uki.stem}" {{
-                        chainloader /{uki.relative_to(state.root / "efi")}
+                        chainloader /{uki.relative_to(state.root / "boot")}
                     }}
                     """
                 )
@@ -1065,7 +1065,7 @@ def prepare_grub_bios(state: MkosiState, partitions: Sequence[Partition]) -> Non
 
     token = find_entry_token(state)
 
-    dst = state.root / "efi" / token
+    dst = state.root / "boot" / token
     with umask(~0o700):
         dst.mkdir(exist_ok=True)
 
@@ -1089,10 +1089,10 @@ def prepare_grub_bios(state: MkosiState, partitions: Sequence[Partition]) -> Non
                 ]
                 initrds += [Path(shutil.copy2(kmods, kdst / "kmods"))]
 
-                image = Path("/") / kimg.relative_to(state.root / "efi")
+                image = Path("/") / kimg.relative_to(state.root / "boot")
                 cmdline = " ".join(state.config.kernel_command_line)
                 initrds = " ".join(
-                    [os.fspath(Path("/") / initrd.relative_to(state.root / "efi")) for initrd in initrds]
+                    [os.fspath(Path("/") / initrd.relative_to(state.root / "boot")) for initrd in initrds]
                 )
 
                 f.write(
@@ -1567,9 +1567,9 @@ def install_uki(state: MkosiState, partitions: Sequence[Partition]) -> None:
             token = find_entry_token(state)
             if roothash:
                 _, _, h = roothash.partition("=")
-                boot_binary = state.root / f"efi/EFI/Linux/{token}-{kver}-{h}{boot_count}.efi"
+                boot_binary = state.root / f"boot/EFI/Linux/{token}-{kver}-{h}{boot_count}.efi"
             else:
-                boot_binary = state.root / f"efi/EFI/Linux/{token}-{kver}{boot_count}.efi"
+                boot_binary = state.root / f"boot/EFI/Linux/{token}-{kver}{boot_count}.efi"
 
         microcode = build_microcode_initrd(state)
 
@@ -2291,6 +2291,7 @@ def make_disk(
                         [Partition]
                         Type=esp
                         Format=vfat
+                        CopyFiles=/boot:/
                         CopyFiles=/efi:/
                         SizeMinBytes={"1G" if bios else "512M"}
                         SizeMaxBytes={"1G" if bios else "512M"}
index 6efc52750c6c8cecf3575d9112a57fc4569c3cd3..10c19e786d9b8198f2a91128cfe37aa3dac06587 100644 (file)
@@ -1868,6 +1868,7 @@ local directory:
   [Partition]
   Type=esp
   Format=vfat
+  CopyFiles=/boot:/
   CopyFiles=/efi:/
   SizeMinBytes=512M
   SizeMaxBytes=512M
index 428edc36a207a869e8094f4123774f01c67d3607..f2730ce27a940480719b6570eec0987a47a6925a 100644 (file)
@@ -117,6 +117,7 @@ def test_initrd_luks(initrd: Image, passphrase: Path) -> None:
                 [Partition]
                 Type=esp
                 Format=vfat
+                CopyFiles=/boot:/
                 CopyFiles=/efi:/
                 SizeMinBytes=512M
                 SizeMaxBytes=512M