sexta-feira, 4 de junho de 2021

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. Video demonstration

Kernel parameters

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: The vga kernel parameters should be omitted if using kernel mode setting. (Discuss in Talk:Silent boot#)

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 dmesg. 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_level=3 to your kernel parameters. If systemd is used in an initramfs, append rd.udev.log_level=3 instead. See systemd-udevd.service(8) § KERNEL_COMMAND_LINE for details.

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_level=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#Session log 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 regenerate the initramfs.

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 [4] 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 or disabling 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_level=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, see also Intel graphics#Fastboot.

Further reading:

Disabling deferred takeover

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






getty

Jump to navigationJump to search

getty is the generic name for a program which manages a terminal line and its connected terminal. Its purpose is to protect the system from unauthorized access. Generally, each getty process is started by systemd and manages a single terminal line.

Installation

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements. See Help:Style for reference.Tango-edit-clear.png

Reason: Description of TTY settings and "staircase effect" is out of context here. The default number of TTYs can be moved to #Add additional virtual consoles as it does not depend on agetty. (Discuss in Talk:Getty#)

agetty is the default getty in Arch Linux, as part of the util-linux package. It modifies the TTY settings while waiting for a login so that the newlines are not translated to CR-LFs. This tends to cause a "staircase effect" for messages printed to the console. Agetty manages virtual consoles and six of these virtual consoles are provided by default in Arch Linux. They are usually accessible by pressing Ctrl+Alt+F1 through Ctrl+Alt+F6.

Alternatives include:

  • mingetty — A minimal getty which allows automatic logins.
mingettyAUR || mingettyAUR
  • fbgetty — A console getty like mingetty, which supports framebuffers.
http://projects.meuh.org/fbgetty/ || fbgettyAUR
  • mgetty — A versatile program to handle all aspects of a modem under Unix.
http://mgetty.greenie.net/ || mgettyAUR

Add additional virtual consoles

Open the file /etc/systemd/logind.conf and set the option NAutoVTs=6 to the number of virtual terminals that you want at boot.

If you wish to start one temporarily, you can start a getty service at the desired TTY by typing:

$ systemctl start getty@ttyN.service

Automatic login to virtual console

Configuration relies on systemd drop-in files to override the default parameters passed to agetty.

Configuration differs for virtual versus serial consoles. In most cases, you want to set up automatic login on a virtual console, (whose device name is ttyN, where N is a number). The configuration of automatic login for serial consoles will be slightly different. Device names of the serial consoles look like ttySN, where N is a number.

Virtual console

Edit the provided unit either manually by creating the following drop-in snippet, or by running systemctl edit getty@tty1 and pasting its content:

/etc/systemd/system/getty@tty1.service.d/override.conf
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin username --noclear %I $TERM
Tip: The option Type=idle found in the default getty@.service will delay the service startup until all jobs (state change requests to units) are completed in order to avoid polluting the login prompt with boot-up messages. When starting X automatically, it may be useful to start getty@tty1.service immediately by adding Type=simple into the drop-in snippet. Both the init system and startx can be silenced to avoid the interleaving of their messages during boot-up.

If you do not want full automatic login, but also do not want to type your username, you can replace --autologin username with --skip-login --login-options username.

If you want to use a tty other than tty1, see systemd FAQ.

Serial console

Create the following file (and leading directories):

/etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin username -s %I 115200,38400,9600 vt102

Nspawn console

To configure auto-login for a systemd-nspawn container, override console-getty.service:

/etc/systemd/system/console-getty.service.d/override.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty --noclear --autologin username --keep-baud console 115200,38400,9600 $TERM

If machinectl login my-container method is used to access the container, also add --autologin username to container-getty@.service template that manages pts/[0-9] pseudo ttys:

/etc/systemd/system/container-getty@.service.d/override.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty --noclear --autologin username --keep-baud pts/%I 115200,38400,9600 $TERM

Prompt only the password for a default user in virtual console login

Getty can be used to login from a virtual console with a default user, typing the password but without needing to insert the username. For instance, to prompt the password for username on tty1:

/etc/systemd/system/getty@tty1.service.d/override.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty -n -o username %I

and then

# systemctl enable getty@tty1

Have boot messages stay on tty1

By default, Arch has the getty@tty1 service enabled. The service file already passes --noclear, which stops agetty from clearing the screen. However systemd clears the screen before starting it. To disable this behavior, create /etc/systemd/system/getty@tty1.service.d/noclear.conf:

/etc/systemd/system/getty@tty1.service.d/noclear.conf
[Service]
TTYVTDisallocate=no

This overrides only TTYVTDisallocate for agetty on TTY1, and leaves the global service file /usr/lib/systemd/system/getty@.service untouched. See Systemd#Editing provided units.

Note:

Nenhum comentário:

Postar um comentário