The patch optionally makes grub not show any text (be fully quiet) when timeout_style=hidden is set and the user does not interrupt the boot.
Combined with a later patch in this series which makes grub not touch the EFI console unless it actually has some text to print, this will keep the vendor logo which EFI put on the display in place until the kernel touches the display. Leading to a more smooth / seamless boot experience. At least Fedora/RHEL/CentOS and Ubuntu have been carrying patches for this for a long time now (since 2013). There have been several attempts to upstream these patches in the past already, which have been rejected because not everyone likes the quiet behavior. This patch makes the quiet behavior optional and defaults to off, so unless grub is compiled with the new --enable-quiet-boot configure option this patch changes nothing. This patch is a mix of the Fedora patches for this and: https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/patches/maybe_quiet.patch https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/patches/gettext_quiet.patch Specifically the configure.ac changes for making this optional come from the Ubuntu patches, as Fedora's patches where simply unconditionally removing all the unwanted grub_printf calls. Cc: Colin Watson <cjwat...@ubuntu.com> Signed-off-by: Hans de Goede <hdego...@redhat.com> --- config.h.in | 2 ++ configure.ac | 16 ++++++++++++++++ grub-core/boot/i386/pc/boot.S | 2 ++ grub-core/boot/i386/pc/diskboot.S | 12 +++++++++--- grub-core/gettext/gettext.c | 7 +++++++ grub-core/kern/main.c | 2 ++ grub-core/normal/menu.c | 2 ++ grub-core/normal/menu_entry.c | 2 ++ util/grub.d/10_linux.in | 19 ++++++++++++++----- 9 files changed, 56 insertions(+), 8 deletions(-) diff --git a/config.h.in b/config.h.in index 9e8f9911b..d2c4ce8e5 100644 --- a/config.h.in +++ b/config.h.in @@ -12,6 +12,8 @@ /* Define to 1 to enable disk cache statistics. */ #define DISK_CACHE_STATS @DISK_CACHE_STATS@ #define BOOT_TIME_STATS @BOOT_TIME_STATS@ +/* Define to 1 to make GRUB quieter at boot time. */ +#define QUIET_BOOT @QUIET_BOOT@ /* We don't need those. */ #define MINILZO_CFG_SKIP_LZO_PTR 1 diff --git a/configure.ac b/configure.ac index c7888e40f..a544080d7 100644 --- a/configure.ac +++ b/configure.ac @@ -1834,6 +1834,17 @@ fi AC_SUBST([LIBZFS]) AC_SUBST([LIBNVPAIR]) +AC_ARG_ENABLE([quiet-boot], + [AS_HELP_STRING([--enable-quiet-boot], + [emit fewer messages at boot time (default=no)])], + [], [enable_quiet_boot=no]) +if test x"$enable_quiet_boot" = xyes ; then + QUIET_BOOT=1 +else + QUIET_BOOT=0 +fi +AC_SUBST([QUIET_BOOT]) + LIBS="" AC_SUBST([FONT_SOURCE]) @@ -2086,5 +2097,10 @@ echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excus else echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)" fi +if [ x"$enable_quiet_boot" = xyes ]; then +echo With quiet boot: Yes +else +echo With quiet boot: No +fi echo "*******************************************************" ] diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S index 2bd0b2d28..a0b023589 100644 --- a/grub-core/boot/i386/pc/boot.S +++ b/grub-core/boot/i386/pc/boot.S @@ -249,8 +249,10 @@ real_start: /* save drive reference first thing! */ pushw %dx +#if !QUIET_BOOT /* print a notification message on the screen */ MSG(notification_string) +#endif /* set %si to the disk address packet */ movw $disk_address_packet, %si diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S index 1ee4cf5b2..9fb44acbb 100644 --- a/grub-core/boot/i386/pc/diskboot.S +++ b/grub-core/boot/i386/pc/diskboot.S @@ -23,7 +23,13 @@ * defines for the code go here */ +#if !QUIET_BOOT #define MSG(x) movw $x, %si; call LOCAL(message) +#else +#define MSG(x) +#endif + +#define ERR(x) movw $x, %si; call LOCAL(message) .file "diskboot.S" @@ -305,17 +311,17 @@ LOCAL(bootit): * BIOS Geometry translation error (past the end of the disk geometry!). */ LOCAL(geometry_error): - MSG(geometry_error_string) + ERR(geometry_error_string) jmp LOCAL(general_error) /* * Read error on the disk. */ LOCAL(read_error): - MSG(read_error_string) + ERR(read_error_string) LOCAL(general_error): - MSG(general_error_string) + ERR(general_error_string) /* go here when you need to stop the machine hard after an error condition */ LOCAL(stop): jmp LOCAL(stop) diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c index 4880cefe3..f0e7a24ed 100644 --- a/grub-core/gettext/gettext.c +++ b/grub-core/gettext/gettext.c @@ -427,6 +427,13 @@ grub_gettext_init_ext (struct grub_gettext_context *ctx, if (locale[0] == 'e' && locale[1] == 'n' && (locale[2] == '\0' || locale[2] == '_')) grub_errno = err = GRUB_ERR_NONE; + +#if QUIET_BOOT + /* If no translations are available, silently fall back to untranslated. */ + if (err == GRUB_ERR_FILE_NOT_FOUND) + grub_errno = err = GRUB_ERR_NONE; +#endif + return err; } diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c index 9cad0c448..1f7bf9a9a 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -269,10 +269,12 @@ grub_main (void) grub_boot_time ("After machine init."); +#if !QUIET_BOOT /* Hello. */ grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); grub_printf ("Welcome to GRUB!\n\n"); grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); +#endif grub_load_config (); diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index d813fade1..7675c77bf 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -342,7 +342,9 @@ grub_menu_execute_with_fallback (grub_menu_t menu, { int fallback_entry; +#if !QUIET_BOOT callback->notify_booting (entry, callback_data); +#endif grub_menu_execute_entry (entry, 1); diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index cdf3590a3..32b35d895 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1167,9 +1167,11 @@ run (struct screen *screen) char *dummy[1] = { NULL }; grub_cls (); +#if !QUIET_BOOT grub_printf (" "); grub_printf_ (N_("Booting a command list")); grub_printf ("\n\n"); +#endif errs_before = grub_err_printed_errors; diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index faedf74e1..a1046a21a 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -20,6 +20,7 @@ set -e prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" +quiet_boot="@QUIET_BOOT@" . "$pkgdatadir/grub-mkconfig_lib" @@ -128,20 +129,28 @@ linux_entry () fi 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"$quiet_boot" = x0 ]; then + message="$(gettext_printf "Loading Linux %s ..." ${version})" + sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' +EOF + fi + sed "s/^/$submenu_indentation/" << EOF linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then - # TRANSLATORS: ramdisk isn't identifier. Should be translated. - message="$(gettext_printf "Loading initial ramdisk ...")" + if [ x"$quiet_boot" = x0 ]; then + # TRANSLATORS: ramdisk isn't identifier. Should be translated. + message="$(gettext_printf "Loading initial ramdisk ...")" + sed "s/^/$submenu_indentation/" << EOF + echo '$(echo "$message" | grub_quote)' +EOF + fi initrd_path= for i in ${initrd}; do initrd_path="${initrd_path} ${rel_dirname}/${i}" done sed "s/^/$submenu_indentation/" << EOF - echo '$(echo "$message" | grub_quote)' initrd $(echo $initrd_path) EOF fi -- 2.17.0.rc1 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel