Difference between revisions of "Silent boot"

From ArchWiki
Jump to: navigation, search
(Syslinux+Systemd)
m (Disabling deferred takeover: style, link to kernel parameter)
 
(83 intermediate revisions by 28 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]]
 +
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]
  
==Syslinux+Systemd==
+
== Kernel parameters ==
  
Your /boot/syslinux/syslinux.cfg should look something like:
+
Change the [[kernel parameters]] using the configuration options of your boot loader, to include the following parameters:
  
    $ grep APPEND /boot/syslinux/syslinux.cfg | head -n1
+
quiet vga=current
    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
+
{{ic|1=vga=current}} is the kernel argument that avoid weird behaviours like {{Bug|32309}}.
  
Video: http://r2d2.webconverger.org/2012-11-14/silent-boot.html
+
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.
  
You need a /etc/systemd/system/autologin@.service too, which looks something like http://ix.io/3ol, replace "hendry" with your username.
+
quiet loglevel=3 vga=current
  
To remove lastlog message you need to comment out in /etc/pam.d/login:
+
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.
    #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==
+
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.
  
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 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]]:
  
Example configuration for /boot/grub/menu.lst
+
  quiet loglevel=3 rd.systemd.show_status=auto rd.udev.log_priority=3
  
# (0) Arch Linux
+
Also {{ic|touch ~/.hushlogin}} to remove the Last login message.
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:
+
== Remove console cursor blinking ==
  
# (0) Arch Linux
+
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].
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==
+
To recover the cursor in the TTY, run:
 +
# setterm -cursor on >> /etc/issue
  
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: 
+
== sysctl ==
  
c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
+
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]:
  
This is what my inittab file looks like with that line commented:
+
{{hc|/etc/sysctl.d/20-quiet-printk.conf|2=
 +
kernel.printk = 3 3 3 3
 +
}}
  
  #
+
== startx ==
  # /etc/inittab
+
 
  #
+
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, remove ''fsck'' from:
 +
 
 +
  HOOKS=(...)
 +
 
 +
in {{ic|/etc/mkinitcpio.conf}} and then run:
 +
 
 +
  mkinitcpio -p linux
 +
 
 +
Now copy the files {{ic|systemd-fsck-root.service}} and {{ic|systemd-fsck@.service}} located at {{ic|/usr/lib/systemd/system/}} to {{ic|/etc/systemd/system/}} and edit them, configuring ''StandardOutput'' and ''StandardError'' like this:
 +
 
 +
  (...)
 
   
 
   
  #  Runlevels:
+
  [Service]
  #    0    Halt
+
  Type=oneshot
  #    1(S)      Single-user
+
  RemainAfterExit=yes
  #    2    Not used
+
  ExecStart=/usr/lib/systemd/systemd-fsck
#    3    Multi-user
+
  StandardOutput=null
  #    4    Not used
+
  StandardError=journal+console
  #    5    X11
+
  TimeoutSec=0
  #    6    Reboot
+
 
+
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.
## Only one of the following two lines can be uncommented!
+
 
# Boot to console
+
== Make GRUB silent ==
#id:3:initdefault:
+
 
# Boot to X11
+
To hide GRUB welcome and boot messages, you may install unofficial {{AUR|grub-silent}} package.
id:5:initdefault:
+
 
+
After the installation, it is required to reinstall [[GRUB]] to necessary partition first.
rc::sysinit:/etc/rc.sysinit
+
 
rs:S1:wait:/etc/rc.single
+
Then, take an example as {{ic|/etc/default/grub.silent}}, and make necessary changes to {{ic|/etc/default/grub}}.
rm:2345:wait:/etc/rc.multi
+
 
rh:06:wait:/etc/rc.shutdown
+
Below three lines are necessary:
su:S:wait:/sbin/sulogin -p
+
 
   
+
  GRUB_DEFAULT=0
  # -8 options fixes umlauts problem on login
+
  GRUB_TIMEOUT=0
  #c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
+
  GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
+
 
c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux
+
{{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.}}
c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux
+
 
c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
+
Lastly, regenerate {{ic|grub.cfg}} file.
c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux
+
 
+
== Retaining the vendor logo from BIOS ==
# Hypervisor Virtual Console for Xen and KVM
+
 
#h0:2345:respawn:/sbin/agetty -8 38400 hvc0 linux
+
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.
+
 
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
+
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}}.
+
 
# Example lines for starting a login manager
+
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.
#x:5:respawn:/usr/bin/xdm -nodaemon
+
 
#x:5:respawn:/usr/sbin/gdm -nodaemon
+
[https://www.youtube.com/watch?v=5DW2JgJmsuY Video demonstration]
#x:5:respawn:/usr/bin/kdm -nodaemon
+
 
#x:5:respawn:/usr/bin/slim >& /dev/null
+
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}}.
x:5:once:/bin/su yourusername -l -c "/bin/bash --login -c /usr/bin/startx >/dev/null 2>&1"
+
 
 +
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 14:11, 18 November 2018

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

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, remove fsck from:

HOOKS=(...) 

in /etc/mkinitcpio.conf and then run:

mkinitcpio -p linux

Now copy the files systemd-fsck-root.service and systemd-fsck@.service located at /usr/lib/systemd/system/ to /etc/systemd/system/ and edit them, 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.