1 From 4225ea9ee7c546c4340e658b0bd6983c436a5f51 Mon Sep 17 00:00:00 2001
2 From: Colin Watson <cjwatson@ubuntu.com>
3 Date: Mon, 13 Jan 2014 12:13:26 +0000
4 Subject: Add configure option to reduce visual clutter at boot time
6 If this option is enabled, then do all of the following:
8 Don't display introductory message about line editing unless we're
9 actually offering a shell prompt. (This is believed to be a workaround
10 for a different bug. We'll go with this for now, but will drop this in
11 favour of a better fix upstream if somebody figures out what that is.)
13 Don't clear the screen just before booting if we never drew the menu in
16 Remove verbose messages printed before reading configuration. In some
17 ways this is awkward because it makes debugging harder, but it's a
18 requirement for a smooth-looking boot process; we may be able to do
19 better in future. Upstream doesn't want this, though.
21 Disable the cursor as well, for similar reasons of tidiness.
23 Suppress kernel/initrd progress messages, except in recovery mode.
25 Suppress "GRUB loading" message unless Shift is held down. Upstream
26 doesn't want this, as it makes debugging harder. Ubuntu wants it to
27 provide a cleaner boot experience.
29 Author: Will Thompson <will@willthompson.co.uk>
30 Bug-Ubuntu: https://bugs.launchpad.net/bugs/386922
31 Bug-Ubuntu: https://bugs.launchpad.net/bugs/861048
32 Forwarded: (partial) http://lists.gnu.org/archive/html/grub-devel/2009-09/msg00056.html
33 Last-Update: 2019-06-24
35 Patch-Name: maybe-quiet.patch
38 configure.ac | 16 ++++++++++++++++
39 grub-core/boot/i386/pc/boot.S | 11 +++++++++++
40 grub-core/boot/i386/pc/diskboot.S | 26 ++++++++++++++++++++++++++
41 grub-core/kern/main.c | 17 +++++++++++++++++
42 grub-core/kern/rescue_reader.c | 2 ++
43 grub-core/normal/main.c | 11 +++++++++++
44 grub-core/normal/menu.c | 17 +++++++++++++++--
45 util/grub.d/10_linux.in | 15 +++++++++++----
46 9 files changed, 111 insertions(+), 6 deletions(-)
48 diff --git a/config.h.in b/config.h.in
49 index 9e8f9911b..d2c4ce8e5 100644
53 /* Define to 1 to enable disk cache statistics. */
54 #define DISK_CACHE_STATS @DISK_CACHE_STATS@
55 #define BOOT_TIME_STATS @BOOT_TIME_STATS@
56 +/* Define to 1 to make GRUB quieter at boot time. */
57 +#define QUIET_BOOT @QUIET_BOOT@
59 /* We don't need those. */
60 #define MINILZO_CFG_SKIP_LZO_PTR 1
61 diff --git a/configure.ac b/configure.ac
62 index 1e5abc67d..ea00ccd69 100644
65 @@ -1857,6 +1857,17 @@ else
67 AC_SUBST([UBUNTU_RECOVERY])
69 +AC_ARG_ENABLE([quiet-boot],
70 + [AS_HELP_STRING([--enable-quiet-boot],
71 + [emit fewer messages at boot time (default=no)])],
72 + [], [enable_quiet_boot=no])
73 +if test x"$enable_quiet_boot" = xyes ; then
78 +AC_SUBST([QUIET_BOOT])
82 AC_SUBST([FONT_SOURCE])
83 @@ -2114,5 +2125,10 @@ echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excus
85 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
87 +if [ x"$enable_quiet_boot" = xyes ]; then
88 +echo With quiet boot: Yes
90 +echo With quiet boot: No
92 echo "*******************************************************"
94 diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S
95 index 2bd0b2d28..b0c0f2225 100644
96 --- a/grub-core/boot/i386/pc/boot.S
97 +++ b/grub-core/boot/i386/pc/boot.S
100 #include <grub/symbol.h>
101 #include <grub/machine/boot.h>
102 +#if QUIET_BOOT && !defined(HYBRID_BOOT)
103 +#include <grub/machine/memory.h>
107 * defines for the code go here
108 @@ -249,9 +252,17 @@ real_start:
109 /* save drive reference first thing! */
112 +#if QUIET_BOOT && !defined(HYBRID_BOOT)
113 + /* is either shift key held down? */
114 + movw $(GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR + 0x17), %bx
119 /* print a notification message on the screen */
120 MSG(notification_string)
123 /* set %si to the disk address packet */
124 movw $disk_address_packet, %si
126 diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S
127 index c1addc0df..9b6d7a7ed 100644
128 --- a/grub-core/boot/i386/pc/diskboot.S
129 +++ b/grub-core/boot/i386/pc/diskboot.S
132 #include <grub/symbol.h>
133 #include <grub/machine/boot.h>
135 +#include <grub/machine/memory.h>
139 * defines for the code go here
142 #define MSG(x) movw $x, %si; call LOCAL(message)
145 +#define SILENT(x) call LOCAL(check_silent); jz LOCAL(x)
153 @@ -50,11 +59,14 @@ _start:
154 /* save drive reference first thing! */
157 + SILENT(after_notification_string)
159 /* print a notification message on the screen */
161 MSG(notification_string)
164 +LOCAL(after_notification_string):
165 /* this sets up for the first run through "bootloop" */
166 movw $LOCAL(firstlist), %di
168 @@ -279,7 +291,10 @@ LOCAL(copy_buffer):
169 /* restore addressing regs and print a dot with correct DS
170 (MSG modifies SI, which is saved, and unused AX and BX) */
172 + SILENT(after_notification_step)
173 MSG(notification_step)
175 +LOCAL(after_notification_step):
178 /* check if finished with this dataset */
179 @@ -295,8 +310,11 @@ LOCAL(copy_buffer):
180 /* END OF MAIN LOOP */
183 + SILENT(after_notification_done)
184 /* print a newline */
185 MSG(notification_done)
187 +LOCAL(after_notification_done):
188 popw %dx /* this makes sure %dl is our "boot" drive */
189 ljmp $0, $(GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
191 @@ -320,6 +338,14 @@ LOCAL(general_error):
192 /* go here when you need to stop the machine hard after an error condition */
193 LOCAL(stop): jmp LOCAL(stop)
196 +LOCAL(check_silent):
197 + /* is either shift key held down? */
198 + movw $(GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR + 0x17), %bx
203 notification_string: .asciz "loading"
205 notification_step: .asciz "."
206 diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
207 index 9cad0c448..714b63d67 100644
208 --- a/grub-core/kern/main.c
209 +++ b/grub-core/kern/main.c
210 @@ -264,15 +264,25 @@ reclaim_module_space (void)
211 void __attribute__ ((noreturn))
215 + struct grub_term_output *term;
218 /* First of all, initialize the machine. */
219 grub_machine_init ();
221 grub_boot_time ("After machine init.");
224 + /* Disable the cursor until we need it. */
225 + FOR_ACTIVE_TERM_OUTPUTS(term)
226 + grub_term_setcursor (term, 0);
229 grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
230 grub_printf ("Welcome to GRUB!\n\n");
231 grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
236 @@ -308,5 +318,12 @@ grub_main (void)
237 grub_boot_time ("After execution of embedded config. Attempt to go to normal mode");
239 grub_load_normal_mode ();
242 + /* If we have to enter rescue mode, enable the cursor again. */
243 + FOR_ACTIVE_TERM_OUTPUTS(term)
244 + grub_term_setcursor (term, 1);
249 diff --git a/grub-core/kern/rescue_reader.c b/grub-core/kern/rescue_reader.c
250 index dcd7d4439..a93524eab 100644
251 --- a/grub-core/kern/rescue_reader.c
252 +++ b/grub-core/kern/rescue_reader.c
253 @@ -78,7 +78,9 @@ grub_rescue_read_line (char **line, int cont,
254 void __attribute__ ((noreturn))
255 grub_rescue_run (void)
258 grub_printf ("Entering rescue mode...\n");
263 diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
264 index 1b03dfd57..0aa389fa1 100644
265 --- a/grub-core/normal/main.c
266 +++ b/grub-core/normal/main.c
267 @@ -389,6 +389,15 @@ static grub_err_t
268 grub_normal_read_line_real (char **line, int cont, int nested)
272 + static int displayed_intro;
274 + if (! displayed_intro)
276 + grub_normal_reader_init (nested);
277 + displayed_intro = 1;
282 /* TRANSLATORS: it's command line prompt. */
283 @@ -441,7 +450,9 @@ grub_cmdline_run (int nested, int force_auth)
288 grub_normal_reader_init (nested);
293 diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
294 index 3611ee9ea..ebf5a0f10 100644
295 --- a/grub-core/normal/menu.c
296 +++ b/grub-core/normal/menu.c
297 @@ -827,12 +827,18 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
299 /* Callback invoked immediately before a menu entry is executed. */
301 -notify_booting (grub_menu_entry_t entry,
302 +notify_booting (grub_menu_entry_t entry
304 + __attribute__((unused))
307 void *userdata __attribute__((unused)))
311 grub_printf_ (N_("Booting `%s'"), entry->title);
312 grub_printf ("\n\n");
316 /* Callback invoked when a default menu entry executed because of a timeout
317 @@ -880,6 +886,9 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
322 + int initial_timeout = grub_menu_get_timeout ();
325 boot_entry = run_menu (menu, nested, &auto_boot);
327 @@ -889,7 +898,11 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
329 continue; /* Menu is empty. */
333 + /* Only clear the screen if we drew the menu in the first place. */
334 + if (initial_timeout != 0)
339 grub_menu_execute_with_fallback (menu, e, autobooted,
340 diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
341 index 61335e908..2e4dff9fb 100644
342 --- a/util/grub.d/10_linux.in
343 +++ b/util/grub.d/10_linux.in
344 @@ -21,6 +21,7 @@ prefix="@prefix@"
345 exec_prefix="@exec_prefix@"
346 datarootdir="@datarootdir@"
347 ubuntu_recovery="@UBUNTU_RECOVERY@"
348 +quiet_boot="@QUIET_BOOT@"
350 . "$pkgdatadir/grub-mkconfig_lib"
352 @@ -158,10 +159,12 @@ linux_entry ()
354 printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
356 - message="$(gettext_printf "Loading Linux %s ..." ${version})"
357 - sed "s/^/$submenu_indentation/" << EOF
358 + if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
359 + message="$(gettext_printf "Loading Linux %s ..." ${version})"
360 + sed "s/^/$submenu_indentation/" << EOF
361 echo '$(echo "$message" | grub_quote)'
364 if test -d /sys/firmware/efi && test -e "${linux}.efi.signed"; then
365 sed "s/^/$submenu_indentation/" << EOF
366 linux ${rel_dirname}/${basename}.efi.signed root=${linux_root_device_thisversion} ro ${args}
367 @@ -173,13 +176,17 @@ EOF
369 if test -n "${initrd}" ; then
370 # TRANSLATORS: ramdisk isn't identifier. Should be translated.
371 - message="$(gettext_printf "Loading initial ramdisk ...")"
372 + if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
373 + message="$(gettext_printf "Loading initial ramdisk ...")"
374 + sed "s/^/$submenu_indentation/" << EOF
375 + echo '$(echo "$message" | grub_quote)'
379 for i in ${initrd}; do
380 initrd_path="${initrd_path} ${rel_dirname}/${i}"
382 sed "s/^/$submenu_indentation/" << EOF
383 - echo '$(echo "$message" | grub_quote)'
384 initrd $(echo $initrd_path)