Skip to contentSkip to conversation

grub.d: Use linuxefi and initrdefi commands if platform is efi

PATCH In review Tianjia Zhang 6 participants 9 messages Mar 23, 2020 – Mar 27, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 grub.d: Use linuxefi and initrdefi commands if platform is efi

When the platform is EFI platform, use 'linuxefi' and 'initrdefi' commands instead of 'linux' and 'initrd'.

---
 util/grub.d/10_linux.in | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
util/grub.d/10_linux.in +9 -2
index e8b01c0d0..8c5c3dab7 100644
@@ -138,10 +138,17 @@ linux_entry ()
     fi
     printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
   fi
+  if [ "@GRUB_PLATFORM@" != "efi" ] ; then
+    linux_cmd="linux"
+    initrd_cmd="initrd"
+  else
+    linux_cmd="linuxefi"
+    initrd_cmd="initrdefi"
+  fi
   message="$(gettext_printf "Loading Linux %s ..." ${version})"
   sed "s/^/$submenu_indentation/" << EOF
 	echo	'$(echo "$message" | grub_quote)'
-	linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
+	${linux_cmd}	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
 EOF
   if test -n "${initrd}" ; then
     # TRANSLATORS: ramdisk isn't identifier. Should be translated.
@@ -152,7 +159,7 @@ EOF
     done
     sed "s/^/$submenu_indentation/" << EOF
 	echo	'$(echo "$message" | grub_quote)'
-	initrd	$(echo $initrd_path)
+	${initrd_cmd}	$(echo $initrd_path)
 EOF
   fi
   sed "s/^/$submenu_indentation/" << EOF
Signature · 1 line
2.17.1
#1 lore raw

Dear Tianjia,

Am 23.03.20 um 12:53 schrieb Tianjia Zhang:

Quoted 33 lines

When the platform is EFI platform, use 'linuxefi' and 'initrdefi' commands instead of 'linux' and 'initrd'.

---
  util/grub.d/10_linux.in | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)
util/grub.d/10_linux.in +8 -1
index e8b01c0d0..8c5c3dab7 100644
@@ -138,10 +138,17 @@ linux_entry ()
      fi
      printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
    fi
+  if [ "@GRUB_PLATFORM@" != "efi" ] ; then
+    linux_cmd="linux"
+    initrd_cmd="initrd"
+  else
+    linux_cmd="linuxefi"
+    initrd_cmd="initrdefi"
+  fi
    message="$(gettext_printf "Loading Linux %s ..." ${version})"
    sed "s/^/$submenu_indentation/" << EOF
  	echo	'$(echo "$message" | grub_quote)'
-	linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
+	${linux_cmd}	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
  EOF
    if test -n "${initrd}" ; then
      # TRANSLATORS: ramdisk isn't identifier. Should be translated.

util/grub.d/10_linux.in EOF · line 165

Quoted 8 lines
util/grub.d/10_linux.in +1 -1
@@ -152,7 +159,7 @@ EOF
      done
      sed "s/^/$submenu_indentation/" << EOF
  	echo	'$(echo "$message" | grub_quote)'
-	initrd	$(echo $initrd_path)
+	${initrd_cmd}	$(echo $initrd_path)
  EOF
    fi
    sed "s/^/$submenu_indentation/" << EOF

What problem does your change address?

Kind regards,

Paul

#2 lore raw
In reply to Tianjia Zhang
Quoted 3 lines · Tianjia Zhang

When the platform is EFI platform, use 'linuxefi' and 'initrdefi' commands instead of 'linux' and 'initrd'.

These two commands are added by most distros as a part of their Secure Boot patch-set, but aren't present in upstream GRUB so this patch doesn't apply.

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat
#3 lore raw
Quoted 7 lines · Javier Martinez Canillas
Quoted 3 lines · Tianjia Zhang

When the platform is EFI platform, use 'linuxefi' and 'initrdefi' commands instead of 'linux' and 'initrd'.

These two commands are added by most distros as a part of their Secure Boot patch-set, but aren't present in upstream GRUB so this patch doesn't apply.

I was about to say that at least in Ubuntu, linux automatically loads via EFI and then falls back to native grub kernel loading if that does not work (and it's not on secure boot). Which IMO is the right thing to do.

Also the other point is that this actually breaks stuff if you install both MBR and EFI bootloaders. Which is something you actually should be doing because you still want to be able to boot even if user switches their BIOS from UEFI to BIOS or vice versa or other shenanigans.

Signature · 2 lines
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer                              i speak de, en
#4 lore raw
Quoted 6 lines · Julian Andres Klode
Quoted 5 lines · Javier Martinez Canillas
Quoted 3 lines · Tianjia Zhang

When the platform is EFI platform, use 'linuxefi' and 'initrdefi' commands instead of 'linux' and 'initrd'.

Quoted 8 lines
Quoted 2 lines

These two commands are added by most distros as a part of their Secure Boot patch-set, but aren't present in upstream GRUB so this patch doesn't apply.

I was about to say that at least in Ubuntu, linux automatically loads via EFI and then falls back to native grub kernel loading if that does not work (and it's not on secure boot). Which IMO is the right thing to do.

In Fedora also always 'linux' and 'initrd' is used nowadays. There's no need to have separate linux16, linuxefi and linux commands although these are supported for backward compatibility.

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat
#6 lore raw

I got it, Thanks for review.

Tianjia

Quoted 16 lines · Daniel Kiper
Quoted 5 lines · Tianjia Zhang

When the platform is EFI platform, use 'linuxefi' and 'initrdefi' commands instead of 'linux' and 'initrd'.

Sorry, NAK! We do not want more "linuxefi" kinda commands in the GRUB upstream.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw
In reply to Daniel Kiper
Quoted 8 lines · Daniel Kiper
Quoted 5 lines · Tianjia Zhang

When the platform is EFI platform, use 'linuxefi' and 'initrdefi' commands instead of 'linux' and 'initrd'.

Sorry, NAK! We do not want more "linuxefi" kinda commands in the GRUB upstream.

Are you saying that the existing 'linux' and 'initrd' should be fixed to work under EFI?

Thanks.

#8 lore raw
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 4 lines · Daniel Kiper
Quoted 3 lines · Tianjia Zhang

When the platform is EFI platform, use 'linuxefi' and 'initrdefi' commands instead of 'linux' and 'initrd'.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Sorry, NAK! We do not want more "linuxefi" kinda commands in the GRUB upstream.

Are you saying that the existing 'linux' and 'initrd' should be fixed to work under EFI?

Exactly, this is the plan for after 2.06 release.

Daniel