All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add knobs to allow non-initrd boot config
@ 2019-02-15 11:07 Paul Menzel
  2019-02-15 15:44 ` Nick Vinson
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Menzel @ 2019-02-15 11:07 UTC (permalink / raw)
  To: grub-devel
  Cc: Chris Glass, Mathieu Trudel-Lapierre, Colin Watson, Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 3216 bytes --]

Date: Thu, 10 Nov 2016 13:44:25 -0500

Add GRUB_FORCE_PARTUUID and GRUB_DISABLE_INITRD configuration knobs to allow
users to generate GRUB menu entries booting directly to the kernel, without
using an initramfs.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
[1. Upstream patch from Ubuntu repository
    https://code.launchpad.net/ubuntu/+source/grub2
 2. Fix typo s/Then/When/]
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
---
 docs/grub.texi          | 13 +++++++++++++
 util/grub-mkconfig.in   |  4 +++-
 util/grub.d/10_linux.in | 11 +++++++++--
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/docs/grub.texi b/docs/grub.texi
index ecaba9d5c..6520d9f87 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -1522,6 +1522,19 @@ This option may be set to a list of GRUB module names separated by spaces.
 Each module will be loaded as early as possible, at the start of
 @file{grub.cfg}.
 
+@item GRUB_FORCE_PARTUUID
+This option forces the root disk entry to be the specified PARTUUID instead
+of whatever would be used instead. This is useful when you control the
+partitioning of the disk but cannot guarantee what the actual hardware will
+be, for example in virtual machine images.
+Setting this option to @samp{12345678-01} will produce:
+root=PARTUUID=12345678-01
+
+@item GRUB_DISABLE_INITRD
+When set to @samp{true}, this option prevents an initrd to be used at boot
+time, regardless of whether one is detected or not. @command{grub-mkconfig}
+will therefore not generate any initrd lines.
+
 @end table
 
 The following options are still accepted for compatibility with existing
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index 33332360e..265cf959b 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -238,7 +238,9 @@ export GRUB_DEFAULT \
   GRUB_ENABLE_CRYPTODISK \
   GRUB_BADRAM \
   GRUB_OS_PROBER_SKIP_LIST \
-  GRUB_DISABLE_SUBMENU
+  GRUB_DISABLE_SUBMENU \
+  GRUB_FORCE_PARTUUID \
+  GRUB_DISABLE_INITRD
 
 if test "x${grub_cfg}" != "x"; then
   rm -f "${grub_cfg}.new"
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 4532266be..d4498f106 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -139,11 +139,18 @@ linux_entry ()
     printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
   fi
   message="$(gettext_printf "Loading Linux %s ..." ${version})"
-  sed "s/^/$submenu_indentation/" << EOF
+  if [ x"$GRUB_FORCE_PARTUUID" = x ]; then
+    sed "s/^/$submenu_indentation/" << EOF
 	echo	'$(echo "$message" | grub_quote)'
 	linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
 EOF
-  if test -n "${initrd}" ; then
+  else
+    sed "s/^/$submenu_indentation/" << EOF
+	echo	'$(echo "$message" | grub_quote)'
+	linux	${rel_dirname}/${basename} root=$PARTUUID=${GRUB_FORCE_PARTUUID} ro ${args}
+EOF
+  fi
+  if test -n "${initrd}" && [ x"$GRUB_DISABLE_INITRD" != xtrue ]; then
     # TRANSLATORS: ramdisk isn't identifier. Should be translated.
     message="$(gettext_printf "Loading initial ramdisk ...")"
     initrd_path=
-- 
2.20.0


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5174 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add knobs to allow non-initrd boot config
  2019-02-15 11:07 [PATCH] Add knobs to allow non-initrd boot config Paul Menzel
@ 2019-02-15 15:44 ` Nick Vinson
  2019-02-18 12:58   ` Daniel Kiper
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Vinson @ 2019-02-15 15:44 UTC (permalink / raw)
  To: Paul Menzel; +Cc: grub-devel


[-- Attachment #1.1: Type: text/plain, Size: 4976 bytes --]

Paul,

Let me start of by saying that I am a contributor and do not have any
authority to approve or deny patches to GRUB.  That said I do have a few
comments below that I would like for you to consider.

On 2/15/19 3:07 AM, Paul Menzel wrote:
> Date: Thu, 10 Nov 2016 13:44:25 -0500
> 
> Add GRUB_FORCE_PARTUUID and GRUB_DISABLE_INITRD configuration knobs to allow
> users to generate GRUB menu entries booting directly to the kernel, without
> using an initramfs.
> 
> Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
> [1. Upstream patch from Ubuntu repository
>     https://code.launchpad.net/ubuntu/+source/grub2
>  2. Fix typo s/Then/When/]
> Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
> ---
>  docs/grub.texi          | 13 +++++++++++++
>  util/grub-mkconfig.in   |  4 +++-
>  util/grub.d/10_linux.in | 11 +++++++++--
>  3 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/docs/grub.texi b/docs/grub.texi
> index ecaba9d5c..6520d9f87 100644
> --- a/docs/grub.texi
> +++ b/docs/grub.texi
> @@ -1522,6 +1522,19 @@ This option may be set to a list of GRUB module names separated by spaces.
>  Each module will be loaded as early as possible, at the start of
>  @file{grub.cfg}.
>  
> +@item GRUB_FORCE_PARTUUID
> +This option forces the root disk entry to be the specified PARTUUID instead
> +of whatever would be used instead. This is useful when you control the
> +partitioning of the disk but cannot guarantee what the actual hardware will
> +be, for example in virtual machine images.
> +Setting this option to @samp{12345678-01} will produce:
> +root=PARTUUID=12345678-01
> 
> +@item GRUB_DISABLE_INITRD
> +When set to @samp{true}, this option prevents an initrd to be used at boot
> +time, regardless of whether one is detected or not. @command{grub-mkconfig}
> +will therefore not generate any initrd lines.
> +
>  @end table
>  
>  The following options are still accepted for compatibility with existing
> diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
> index 33332360e..265cf959b 100644
> --- a/util/grub-mkconfig.in
> +++ b/util/grub-mkconfig.in
> @@ -238,7 +238,9 @@ export GRUB_DEFAULT \
>    GRUB_ENABLE_CRYPTODISK \
>    GRUB_BADRAM \
>    GRUB_OS_PROBER_SKIP_LIST \
> -  GRUB_DISABLE_SUBMENU
> +  GRUB_DISABLE_SUBMENU \
> +  GRUB_FORCE_PARTUUID \
> +  GRUB_DISABLE_INITRD
>  
>  if test "x${grub_cfg}" != "x"; then
>    rm -f "${grub_cfg}.new"
> diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
> index 4532266be..d4498f106 100644
> --- a/util/grub.d/10_linux.in
> +++ b/util/grub.d/10_linux.in
> @@ -139,11 +139,18 @@ linux_entry ()
>      printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
>    fi
>    message="$(gettext_printf "Loading Linux %s ..." ${version})"
> -  sed "s/^/$submenu_indentation/" << EOF
> +  if [ x"$GRUB_FORCE_PARTUUID" = x ]; then
> +    sed "s/^/$submenu_indentation/" << EOF

Since grub has the option GRUB_DISABLE_LINUX_PARTUUID which is expected
to control whether `root=PARTUUID=...` is used, perhaps it would be
better to add something like:

GRUB_DEVICE_PARTUUID=${GRUB_FORCE_PARTUUID:-${GRUB_DEVICE_PARTUUID}}

near the beginning of 10_linux.in?

>  	echo	'$(echo "$message" | grub_quote)'
>  	linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
>  EOF
> -  if test -n "${initrd}" ; then
> +  else
> +    sed "s/^/$submenu_indentation/" << EOF
> +	echo	'$(echo "$message" | grub_quote)'
> +	linux	${rel_dirname}/${basename} root=$PARTUUID=${GRUB_FORCE_PARTUUID} ro ${args}
> +EOF
> +  fi
> +  if test -n "${initrd}" && [ x"$GRUB_DISABLE_INITRD" != xtrue ]; then

Perhaps instead of an all-or-nothing approach something similar to how
the GRUB_EARLY_INITRD_LINUX_STOCK and GRUB_EARLY_INITRD_LINUX_CUSTOM
variables are used could be adopted?

My thinking here is a user could set something like
GRUB_INITRD_LINUX_STOCK="" and GRUB_EARLY_INITRD_LINUX_STOCK="".  That
would allow for the same effect while also giving distros and users
greater flexibility in how early initrd and regular initrd images are named.

This also allows early initrds to still be used without normal initrds
to load CPU microcode updates at boot without having to recompile the
kernel on update.

However, for GRUB_EARLY_INITRD_LINUX_STOCK, this might require a small
code change as

`if [ "x${GRUB_EARLY_INITRD_LINUX_STOCK}" = "x" ]; then`

would probably need to be something like

`if ["x${GRUB_EARLY_INITRD_LINUX_STOCK+is_set} = "x"]; then`.

Thanks,
Nicholas Vinson

>      # TRANSLATORS: ramdisk isn't identifier. Should be translated.
>      message="$(gettext_printf "Loading initial ramdisk ...")"
>      initrd_path=
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add knobs to allow non-initrd boot config
  2019-02-15 15:44 ` Nick Vinson
@ 2019-02-18 12:58   ` Daniel Kiper
  2019-02-18 18:41     ` Paul Menzel
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Kiper @ 2019-02-18 12:58 UTC (permalink / raw)
  To: pmenzel; +Cc: nvinson234, grub-devel

On Fri, Feb 15, 2019 at 07:44:55AM -0800, Nick Vinson wrote:
> Paul,
>
> Let me start of by saying that I am a contributor and do not have any
> authority to approve or deny patches to GRUB.  That said I do have a few
> comments below that I would like for you to consider.

Paul, may I ask you to follow Nick's comments?

Daniel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add knobs to allow non-initrd boot config
  2019-02-18 12:58   ` Daniel Kiper
@ 2019-02-18 18:41     ` Paul Menzel
  2019-02-18 19:02       ` Daniel Kiper
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Menzel @ 2019-02-18 18:41 UTC (permalink / raw)
  To: The development of GNU GRUB, Daniel Kiper; +Cc: nvinson234

Dear Daniel,


On 18.02.19 13:58, Daniel Kiper wrote:
> On Fri, Feb 15, 2019 at 07:44:55AM -0800, Nick Vinson wrote:

>> Let me start of by saying that I am a contributor and do not have any
>> authority to approve or deny patches to GRUB.  That said I do have a few
>> comments below that I would like for you to consider.
> 
> Paul, may I ask you to follow Nick's comments?

Sure, but I’ll two more weeks to give the original authors time to reply 
and distrubtion maintainers to comment.


Kind regards,

Paul


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add knobs to allow non-initrd boot config
  2019-02-18 18:41     ` Paul Menzel
@ 2019-02-18 19:02       ` Daniel Kiper
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Kiper @ 2019-02-18 19:02 UTC (permalink / raw)
  To: Paul Menzel; +Cc: The development of GNU GRUB, nvinson234

On Mon, Feb 18, 2019 at 07:41:43PM +0100, Paul Menzel wrote:
> Dear Daniel,
>
> On 18.02.19 13:58, Daniel Kiper wrote:
> > On Fri, Feb 15, 2019 at 07:44:55AM -0800, Nick Vinson wrote:
>
> > > Let me start of by saying that I am a contributor and do not have any
> > > authority to approve or deny patches to GRUB.  That said I do have a few
> > > comments below that I would like for you to consider.
> >
> > Paul, may I ask you to follow Nick's comments?
>
> Sure, but I’ll two more weeks to give the original authors time to reply and
> distrubtion maintainers to comment.

I am OK with that. Go ahead. If it is possible please keep Nick and me in the loop.

Daniel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-18 20:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15 11:07 [PATCH] Add knobs to allow non-initrd boot config Paul Menzel
2019-02-15 15:44 ` Nick Vinson
2019-02-18 12:58   ` Daniel Kiper
2019-02-18 18:41     ` Paul Menzel
2019-02-18 19:02       ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.