Difference between revisions of "Silent boot"

From ArchWiki
Jump to navigation Jump to search
(Syslinux+Systemd)
 
(98 intermediate revisions by 32 users not shown)
Line 1: Line 1:
 
[[Category:Boot process]]
 
[[Category:Boot process]]
This page is for those who prefer to limit the verbosity of their system to a strict minimum, either for aesthetics or other reasons. Following this guide will remove all text from the bootup process.
+
[[es:Silent boot]]
 +
[[ja:サイレントブート]]
 +
[[pt:Silent boot]]
 +
{{Related articles start}}
 +
{{Related|Plymouth}}
 +
{{Related articles end}}
  
==Syslinux+Systemd==
+
This page is for those who prefer to limit the verbosity of their system to a strict minimum, either for aesthetics or other reasons. Following this guide will remove all text from the bootup process. [http://www.youtube.com/watch?v=tuqhsqrhXk0 Video demonstration]
  
Your /boot/syslinux/syslinux.cfg should look something like:
+
== Kernel parameters ==
  
    $ grep APPEND /boot/syslinux/syslinux.cfg | head -n1
+
Change the [[kernel parameters]] using the configuration options of your boot loader, to include the following parameters:
    APPEND root=/dev/sda1 ro 5 init=/usr/lib/systemd/systemd quiet vga=current
 
  
vga=current is the magic ''kernel argument'' not to do something crazy like: https://bugs.archlinux.org/task/32309
+
quiet vga=current
  
Video: http://r2d2.webconverger.org/2012-11-14/silent-boot.html
+
{{ic|1=vga=current}} is the kernel argument that avoid weird behaviours like {{Bug|32309}}.
  
You need a /etc/systemd/system/autologin@.service too, which looks something like http://ix.io/3ol, replace "hendry" with your username.
+
If you are still getting messages printed to the console, it may be dmesg sending you what it thinks are important messages. You can change the level at which these messages will be printed by using {{ic|1=quiet loglevel=<level>}}, where {{ic|<level>}} is any number between 0 and 7, where 0 is the most critical, and 7 is debug levels of printing.
  
To remove lastlog message you need to comment out in /etc/pam.d/login:
+
quiet loglevel=3 vga=current
    #session                optional        pam_lastlog.so
 
Outstanding Issues:
 
* https://bugs.archlinux.org/task/32729
 
* https://github.com/karelzak/util-linux/issues/21
 
* https://bugs.freedesktop.org/show_bug.cgi?id=57216
 
  
==Grub configs==
+
Note that this only seems to work if both {{ic|quiet}} and {{ic|1=loglevel=<level>}} are both used, and they must be in that order (quiet first). The loglevel parameter will only change that which is printed to the console, the levels of dmesg itself will not be affected and will still be available through the journal as well as the {{ic|dmesg}} command. For more information, see the {{ic|Documentation/kernel-parameters.txt}} file of the {{Pkg|linux-docs}} package.
  
To avoid the verbose text, you can add this line to the grub kernel command "quiet console=tty12". It will send the outpout of the boot process to the "tty 12", while remaining on the "tty 1".
+
If you also want to stop systemd from printing its version number when booting, you should also append {{ic|1=udev.log_priority=3}} to your kernel commandline ([http://www.freedesktop.org/software/systemd/man/systemd-udevd.service.html#Kernel%20command%20line source]). If systemd is used in an [[initramfs]], append {{ic|1=rd.udev.log_priority=3}} instead.
  
Example configuration for /boot/grub/menu.lst
+
If you are using the {{ic|systemd}} hook in the [[initramfs]], you may get systemd messages during initramfs initialization. You can pass {{ic|1=rd.systemd.show_status=false}} to disable them, or {{ic|1=rd.systemd.show_status=auto}} to only suppress successful messages (so in case of errors you can still see them). Actually, {{ic|1=auto}} is already passed to {{ic|1=systemd.show_status=auto}} when {{ic|1=quiet}} is used, however for some motive sometimes systemd inside initramfs does not get it. Below are the parameters that you need to pass to your kernel to get a completely clean boot with systemd in your [[initramfs]]:
  
# (0) Arch Linux
+
   quiet loglevel=3 rd.systemd.show_status=auto rd.udev.log_priority=3
title  Arch Linux
 
root   (hd0,5)
 
kernel /vmlinuz26 root=/dev/disk/by-uuid/b2f2fc9a-6305-4770-aed2-fccb3ec51d5c ro quiet console=tty12
 
initrd /kernel26.img
 
  
This configuration will only leave the Arch logo on the screen for the whole boot process. If you would like to also remove the logo, simply add "logo.nologo" to the kernel command, like this:
+
Also {{ic|touch ~/.hushlogin}} to remove the Last login message.
  
# (0) Arch Linux
+
== Remove console cursor blinking ==
title  Arch Linux
 
root  (hd0,5)
 
kernel /vmlinuz26 root=/dev/disk/by-uuid/b2f2fc9a-6305-4770-aed2-fccb3ec51d5c ro quiet console=tty12 logo.nologo
 
initrd /kernel26.img
 
  
==/etc/inittab==
+
The console cursor at boot keeps blinking if you follow these instructions. This can be solved by passing {{ic|1=vt.global_cursor_default=0}} to the kernel [http://www.friendlyarm.net/forum/topic/2998].
  
The file /etc/inittab is responsible for the prompts you get in your ttys. The boot process taking place in tty 1, i want to remove the prompt in that tty so that no text is displayed whatsoever. So i am gonna deactivate tty1 completely. Simply comment the line responsible for it in the /etc/initab file. The line to comment is this one: 
+
To recover the cursor in the TTY, run:
 +
# setterm -cursor on >> /etc/issue
  
c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
+
== sysctl ==
  
This is what my inittab file looks like with that line commented:
+
To hide any kernel messages from the console, add or modify the {{ic|kernel.printk}} line according to [http://unix.stackexchange.com/a/45525/27433]:
  
  #
+
{{hc|/etc/sysctl.d/20-quiet-printk.conf|2=
  # /etc/inittab
+
kernel.printk = 3 3 3 3
  #
+
}}
 +
 
 +
== agetty ==
 +
 
 +
To hide agetty printed issue and "login:" prompt line from the console[https://github.com/karelzak/util-linux/commit/933956cb499e12d0d0e5228b6de34ffa5c9a9e08], create a [[drop-in snippet]] for {{ic|getty@tty1.service}}.
 +
 
 +
{{hc|/etc/systemd/system/getty@tty1.service.d/skip-prompt.conf|2=
 +
[Service]
 +
ExecStart=
 +
ExecStart=-/usr/bin/agetty '''--skip-login''' --nonewline --noissue --autologin ''username'' --noclear %I $TERM
 +
}}
 +
 
 +
== startx ==
 +
 
 +
To hide {{ic|startx}} messages, you could redirect its output to {{ic|/dev/null}}, in your [https://github.com/kaihendry/Kai-s--HOME/blob/master/.bash_profile .bash_profile] like so:
 +
 
 +
{{Note|Redirection is broken with rootless login. See [[Xorg#Broken redirection]].}}
 +
 
 +
  $ [[ $(fgconsole 2>/dev/null) == 1 ]] && exec startx -- vt1 &> /dev/null
 +
 
 +
== fsck ==
 +
 
 +
To hide fsck messages during boot, let systemd check the root filesystem. For this, replace ''udev'' hook with ''systemd'':
 +
 
 +
  HOOKS=( base systemd fsck ...)
 +
 
 +
in {{ic|/etc/mkinitcpio.conf}} and then run:
 +
 
 +
  mkinitcpio -p linux
 +
 
 +
Now edit {{ic|systemd-fsck-root.service}} and {{ic|systemd-fsck@.service}}:
 
   
 
   
  # Runlevels:
+
  # systemctl edit --full systemd-fsck-root.service
  #   0    Halt
+
  # systemctl edit --full systemd-fsck@.service
#    1(S)      Single-user
+
 
#    2    Not used
+
Configuring ''StandardOutput'' and ''StandardError'' like this:
#    3    Multi-user
+
 
#    4    Not used
+
  (...)
  #    5    X11
 
#    6    Reboot
 
 
   
 
   
  ## Only one of the following two lines can be uncommented!
+
  [Service]
  # Boot to console
+
  Type=oneshot
  #id:3:initdefault:
+
  RemainAfterExit=yes
  # Boot to X11
+
  ExecStart=/usr/lib/systemd/systemd-fsck
  id:5:initdefault:
+
  StandardOutput=null
   
+
  StandardError=journal+console
  rc::sysinit:/etc/rc.sysinit
+
  TimeoutSec=0
rs:S1:wait:/etc/rc.single
+
 
rm:2345:wait:/etc/rc.multi
+
See [http://www.freedesktop.org/software/systemd/man/systemd-fsck@.service.html this] for more info on the options you can pass to {{ic|systemd-fsck}} - you can change how often the service will check (or not) your filesystems.
rh:06:wait:/etc/rc.shutdown
+
 
su:S:wait:/sbin/sulogin -p
+
== Make GRUB silent ==
   
+
 
  # -8 options fixes umlauts problem on login
+
To hide GRUB welcome and boot messages, you may install unofficial {{AUR|grub-silent}} package.
  #c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
+
 
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
+
After the installation, it is required to reinstall [[GRUB]] to necessary partition first.
c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux
+
 
c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux
+
Then, take an example as {{ic|/etc/default/grub.silent}}, and make necessary changes to {{ic|/etc/default/grub}}.
c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
+
 
c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux
+
Below three lines are necessary:
+
 
# Hypervisor Virtual Console for Xen and KVM
+
  GRUB_DEFAULT=0
#h0:2345:respawn:/sbin/agetty -8 38400 hvc0 linux
+
  GRUB_TIMEOUT=0
+
  GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
+
 
+
{{Note|If you set {{ic|1=GRUB_TIMEOUT=0}} and {{ic|1=GRUB_HIDDEN_TIMEOUT=1}} (or any positive value), set {{ic|1=GRUB_RECORDFAIL_TIMEOUT=$GRUB_HIDDEN_TIMEOUT}} instead of {{ic|1=GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT}}. Otherwise pressing {{ic|Esc}} on boot to show GRUB menu will not work.}}
# Example lines for starting a login manager
+
 
#x:5:respawn:/usr/bin/xdm -nodaemon
+
Lastly, regenerate {{ic|grub.cfg}} file.
#x:5:respawn:/usr/sbin/gdm -nodaemon
+
 
#x:5:respawn:/usr/bin/kdm -nodaemon
+
== Retaining the vendor logo from BIOS ==
#x:5:respawn:/usr/bin/slim >& /dev/null
+
 
x:5:once:/bin/su yourusername -l -c "/bin/bash --login -c /usr/bin/startx >/dev/null 2>&1"
+
Modern UEFI systems display a vendor logo on boot until handing over control to the bootloader; e.g. Lenovo laptops display a bright red Lenovo logo. This vendor logo is typically blanked by the bootloader (if standard GRUB is used) or by the kernel.
 +
 
 +
To prevent the kernel from blanking the vendor logo, Linux 4.19 introduced a new configuration option {{ic|FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER}} that retains the contents of the framebuffer until text needs to be printed on the framebuffer console. As of November 2018 (Linux 4.19.1), the official Arch Linux kernels are compiled with {{ic|1=CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y}}.
 +
 
 +
When combined with a low loglevel (to prevent text from being printed), the vendor logo can be retained while the system is initialized. Note that GRUB in the standard configuration blanks the screen; consider using [[EFISTUB]] booting instead to boot directly into the kernel and thus leverage deferred takeover.
 +
 
 +
[https://www.youtube.com/watch?v=5DW2JgJmsuY Video demonstration]
 +
 
 +
The kernel command line should use {{ic|1=loglevel=3}} or {{ic|1=rd.udev.log_priority=3}} as mentioned above. Note that if you often receive {{ic|Core temperature above threshold, cpu clock throttled}} messages in the kernel log, you need to use log level 2 to silence these at boot time. Alternatively, if you compile your own kernel, adjust the log level of the message in {{ic|arch/x86/kernel/cpu/mcheck/therm_throt.c}}.
 +
 
 +
If you use [[Intel graphics]], set {{ic|1=i915.fastboot=1}} in the kernel command line to avoid unnecessary modesetting (and screen blanking) on boot.
 +
 
 +
 
 +
''Further reading:''
  
==Patching grub==
+
* [https://www.phoronix.com/scan.php?page=news_item&px=Linux-4.19-FBDEV-Defer-Console Phoronix: Linux 4.19 Adds Deferred Console Takeover Support For FBDEV - Cleaner Boot Process]
 +
* [https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org/thread/3MWCKJ2DVJPC4INXPKB4ECFZLA7X5RTI/ Hans de Goede: Adding deferred fbcon console takeover to the Fedora kernels]
  
(coming soon)
+
=== Disabling deferred takeover ===
  
==Other==
+
If the new behavior leads to issues, you can disable deferred takeover by using the {{ic|1=fbcon=nodefer}} [[kernel parameter]].

Latest revision as of 19:32, 20 May 2019

This page is for those who prefer to limit the verbosity of their system to a strict minimum, either for aesthetics or other reasons. Following this guide will remove all text from the bootup process. Video demonstration

Kernel parameters

Change the kernel parameters using the configuration options of your boot loader, to include the following parameters:

quiet vga=current

vga=current is the kernel argument that avoid weird behaviours like FS#32309.

If you are still getting messages printed to the console, it may be dmesg sending you what it thinks are important messages. You can change the level at which these messages will be printed by using quiet loglevel=<level>, where <level> is any number between 0 and 7, where 0 is the most critical, and 7 is debug levels of printing.

quiet loglevel=3 vga=current

Note that this only seems to work if both quiet and loglevel=<level> are both used, and they must be in that order (quiet first). The loglevel parameter will only change that which is printed to the console, the levels of dmesg itself will not be affected and will still be available through the journal as well as the dmesg command. For more information, see the Documentation/kernel-parameters.txt file of the linux-docs package.

If you also want to stop systemd from printing its version number when booting, you should also append udev.log_priority=3 to your kernel commandline (source). If systemd is used in an initramfs, append rd.udev.log_priority=3 instead.

If you are using the systemd hook in the initramfs, you may get systemd messages during initramfs initialization. You can pass rd.systemd.show_status=false to disable them, or rd.systemd.show_status=auto to only suppress successful messages (so in case of errors you can still see them). Actually, auto is already passed to systemd.show_status=auto when quiet is used, however for some motive sometimes systemd inside initramfs does not get it. Below are the parameters that you need to pass to your kernel to get a completely clean boot with systemd in your initramfs:

 quiet loglevel=3 rd.systemd.show_status=auto rd.udev.log_priority=3

Also touch ~/.hushlogin to remove the Last login message.

Remove console cursor blinking

The console cursor at boot keeps blinking if you follow these instructions. This can be solved by passing vt.global_cursor_default=0 to the kernel [1].

To recover the cursor in the TTY, run:

# setterm -cursor on >> /etc/issue

sysctl

To hide any kernel messages from the console, add or modify the kernel.printk line according to [2]:

/etc/sysctl.d/20-quiet-printk.conf
kernel.printk = 3 3 3 3

agetty

To hide agetty printed issue and "login:" prompt line from the console[3], create a drop-in snippet for getty@tty1.service.

/etc/systemd/system/getty@tty1.service.d/skip-prompt.conf
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --skip-login --nonewline --noissue --autologin username --noclear %I $TERM

startx

To hide startx messages, you could redirect its output to /dev/null, in your .bash_profile like so:

Note: Redirection is broken with rootless login. See Xorg#Broken redirection.
$ [[ $(fgconsole 2>/dev/null) == 1 ]] && exec startx -- vt1 &> /dev/null

fsck

To hide fsck messages during boot, let systemd check the root filesystem. For this, replace udev hook with systemd:

HOOKS=( base systemd fsck ...) 

in /etc/mkinitcpio.conf and then run:

mkinitcpio -p linux

Now edit systemd-fsck-root.service and systemd-fsck@.service:

# systemctl edit --full systemd-fsck-root.service
# systemctl edit --full systemd-fsck@.service

Configuring StandardOutput and StandardError like this:

(...)

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/systemd-fsck
StandardOutput=null
StandardError=journal+console
TimeoutSec=0

See this for more info on the options you can pass to systemd-fsck - you can change how often the service will check (or not) your filesystems.

Make GRUB silent

To hide GRUB welcome and boot messages, you may install unofficial grub-silentAUR package.

After the installation, it is required to reinstall GRUB to necessary partition first.

Then, take an example as /etc/default/grub.silent, and make necessary changes to /etc/default/grub.

Below three lines are necessary:

GRUB_DEFAULT=0
GRUB_TIMEOUT=0
GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT
Note: If you set GRUB_TIMEOUT=0 and GRUB_HIDDEN_TIMEOUT=1 (or any positive value), set GRUB_RECORDFAIL_TIMEOUT=$GRUB_HIDDEN_TIMEOUT instead of GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT. Otherwise pressing Esc on boot to show GRUB menu will not work.

Lastly, regenerate grub.cfg file.

Retaining the vendor logo from BIOS

Modern UEFI systems display a vendor logo on boot until handing over control to the bootloader; e.g. Lenovo laptops display a bright red Lenovo logo. This vendor logo is typically blanked by the bootloader (if standard GRUB is used) or by the kernel.

To prevent the kernel from blanking the vendor logo, Linux 4.19 introduced a new configuration option FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER that retains the contents of the framebuffer until text needs to be printed on the framebuffer console. As of November 2018 (Linux 4.19.1), the official Arch Linux kernels are compiled with CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y.

When combined with a low loglevel (to prevent text from being printed), the vendor logo can be retained while the system is initialized. Note that GRUB in the standard configuration blanks the screen; consider using EFISTUB booting instead to boot directly into the kernel and thus leverage deferred takeover.

Video demonstration

The kernel command line should use loglevel=3 or rd.udev.log_priority=3 as mentioned above. Note that if you often receive Core temperature above threshold, cpu clock throttled messages in the kernel log, you need to use log level 2 to silence these at boot time. Alternatively, if you compile your own kernel, adjust the log level of the message in arch/x86/kernel/cpu/mcheck/therm_throt.c.

If you use Intel graphics, set i915.fastboot=1 in the kernel command line to avoid unnecessary modesetting (and screen blanking) on boot.


Further reading:

Disabling deferred takeover

If the new behavior leads to issues, you can disable deferred takeover by using the fbcon=nodefer kernel parameter.