Flicker Free Boot

From Gentoo Wiki
Jump to: navigation, search
Warning
This page has been nominated for deletion.

The given reason is: Requires pulling from unverified sources and use of pastebin

If you disagree with its deletion, do not remove this notice; discuss your objections on the associated discussion page.

Administrators, please remember to check if anything links here and the page history before deleting.

This notice should remain for a minimum of 1 month after it was placed on the page. If discussion is still ongoing it should remain until a consensus is reached, at which time the page may be deleted or this notice may be removed. (However, if the page has only been edited by the user who nominated it for deletion and/or is in the nominator's user space, then a speedy deletion may be called for.)

Flicker Free Boot is a relatively new feature, that was created by Hans de Goede and is available in Fedora since version 30.

Warning
This is not an easy task to accomplish and might break the system. It's recommended to make a backup of all files in the /boot partition before attempting this tutorial. No support for boot failures will be provided by Gentoo (forums, bugs, email, irc) when using software outside of the repository. Follow this tutorial at your own risk!

Testing

Dell PowerEdge T20

This process was tested on a Dell PowerEdge T20 with Intel Xeon E3-1225v3 (Haswell Based) processor. On the Dell PowerEdge the boot proces is around 80% fluent. It flickers once for 2 - 3 sec. Unfortunately it's the same when booting from a Microsoft Windows 10 based USB key, so it appears to be the way it was implemented.

Lenovo ThinkPad P52

This process was tested on a Lenovo ThinkPad P52 with Intel Core i7-8750H (Coffee Lake Based) processor. On the Lenovo ThinkPad P52 the boot proces is around completely fluent. It doesn't flicker, so this guide should work as expected.

Other results

Please share your success or failure results if you can. This way we can get a more accurate view of what is working.

Requirements

Hardware / Software

  • A working UEFI setup, preferably with a Intel Skylake (6th Generation) or more recent processor should work.
  • Older (3rd to 5th Generation Core iXXXX series processors might work.
  • You must be using the Intel Onboard (i915) series graphics. Other graphics cards are not supported.
  • The specified system must boot up in native UEFI mode. CSM mode needs to be disabled.
  • The specified system must use a manually compiled kernel. I haven't tested this with a genkernel created kernel.
  • If you're using an older (e.g. Ivy Bridge / Haswell / Broadwell) based system, it's recommended that you use at least sys-kernel/gentoo-sources version 4.20.17 or higher due to a bug that actually causes the screen to go to stand-by mode and turn back on.
  • This guide assumes that you've configured your kernel correctly and set the appropriate options for framebuffer support and such.
  • This guide assumes that you're using /dev/sda1 as ESP (/boot) partition. If it's not, then adjust the commands for your own paths accordingly.
  • This guide assumes that you're using systemd as your init system.
  • It's recommended to have a /boot partition of at least 512MB, as 128MB might be too small.
  • This guide assumes that you're using a standardized naming scheme for your kernel that grub identifies and accepts (vmlinuz- or kernel-).
  • The specified system must use grub as a bootloader. I've tried getting it to work with EFI stub, but it just does not seem to work.
  • The modified version of grub will use a sub-folder fedora instead of grub on the /boot partition. Keep this in mind

Knowledge

  • A working Gentoo setup, preferably configured with grub.
  • Intermediate to advanced knowledge about the Linux boot process.
  • Knowledge on how to manually patch and compile.

Summary

This tutorial assumes that you've currently got a working Gentoo setup. This setup boots in (U)EFI mode using grub with CSM mode disabled and is using an Intel processor with it's own integrated graphics card.

Installing the required software

In order to be able to successfully get everything working, there's a things you'll need to do in order to be able to successfully getting this running on a system

Using the GIT version of plymouth and setting the correct USE flags

The only version that currently has these patches is the GIT version of plymouth. In order to emerge the GIT version of plymouth, you'll need to take the following steps:

  1. Run the command:
    root #nano -w /etc/portage/package.use/plymouth
  2. Add the following line to the file:
    FILE /etc/portage/package.use/plymouth
    sys-boot/plymouth libkms pango
    1. NOTE: libkms is the minimal requirement for the splash screen even to show up and pango is required For interactivity (e.g.: If you want to have the ability to enter a LUKS password on a nice graphical screen). The gtk and gdm USE flags should be added respectively when using GDM as Display Manager or lightdm with GTK.
    2. NOTE: Do NOT use the static-libs USE flag. This USE flags break plymouth and causes the package not to compile or show any themes.
  3. Press CTRL + O, press [Enter] and press CTRL + X in order to save the file.
  4. Run the command:
    root #nano -w /etc/portage/package.use/plymouth
  5. Add the following line to the file:
    FILE /etc/portage/package.accept_keywords/plymouth
    sys-boot/plymouth **
  6. Press CTRL + O, press [Enter] and press CTRL + X in order to save the file.
  7. Now install the package: sys-boot/plymouth:
    root #emerge --ask sys-boot/plymouth
    Verify if the package is actually version 9999 (otherwise there might be a typo in one of the files).

Using dracut version 0.49-r1 (the ~amd64 version of dracut)

This has been tested to work by using the ~amd64 version of dracut. genkernel-next fails to work properly. Using the latest available version of dracut from portage is recommended.

  1. Run the command:
    root #nano -w /etc/portage/package.accept_keywords/dracut
  2. Add the following line to the file:
    FILE /etc/portage/package.accept_keywords/dracut
    sys-kernel/dracut
  3. Press CTRL + O, press [Enter] and press CTRL + X in order to save the file.
  4. Now install the package: sys-kernel/dracut:
    root #emerge --ask sys-kernel/dracut
    Verify if the package is actually at least version 0.49-r1 (otherwise there might be a typo in one of the files).

Getting the custom version of grub

Hans de Goede from Fedora made a customized version of grub in order to get this to work. This is not the default grub you get by emerging the software. For this you'll need to use the customized version of grub.

  1. Git should already be installed, as it should've been pulled in by emerging the 9999 version of plymouth. If it's not, then install dev-vcs/git by running the command :
    root #emerge --ask dev-vcs/git
  2. Now let's make a directory which we'll clone the project in and enter it
    root #mkdir -p /root/grub/fedora
    root #cd /root/grub/fedora
  3. Now let's clone the project from Fedora:
    root #git clone https://github.com/rhboot/grub2 -b fedora-30

Building and compiling

Getting the splash screen to show

In order to get the splash screen to show, we'll need to adjust a few settings and generate working initramfs using dracut.

  1. First, edit the plymouthd file, to specify the theme to be used. Run the command:
    root #nano -w /etc/plymouth/plymouthd.conf
  2. Change the settings to make it look like the following:
    FILE /etc/plymouth/plymouthd.conf
    [Daemon]
    Theme=bgrt
    ShowDelay=0
    
  3. Press CTRL + O, press [Enter] and press CTRL + X in order to save the file.
  4. Now, mount the boot partition in order for plymouth to be able to automatically install the initramfs file:
    root #mount /dev/sda1 /boot
  5. Finally, generate the initramfs with the plymouth theme and have it automatically:
    root #plymouth-set-default-theme -R bgrt
    Note
    This command automatically generates an initramfs file and will install it onto the /boot partition with the name initramfs-[version]-gentoo-[release].img which grub will pick up automatically.

Getting the customized version of grub compiled and installed

This is the hardest part. Installing the customized version of grub and generating a working grub.conf

  1. First, enter the grub directory:
    root #cd /root/grub/fedora/grub2
  2. Now, generate the autogen filesy:
    root #./autogen.sh
  3. Next, get a working configure and make file:
    root #autoreconf -ivf
  4. Finally, compile grub. For this I've got 2 scripts that were shared with me by Hans de Goede.
FILE /root/grub/fedora/grub2/configure2
#!/bin/bash
 
mkdir -p /root/grub/fedora/grub2/efi-64
cd /root/grub/fedora/grub2/efi-64
 
if [ ! -f unifont.pcf.gz ]; then
    wget http://unifoundry.com/unifont-5.1.20080820.pcf.gz
    mv unifont-5.1.20080820.pcf.gz unifont.pcf.gz
fi
 
export CPPFLAGS="-I/root/grub/fedora/grub2"
export CFLAGS="-fno-strict-aliasing -g3 -pipe -Wall -Werror=format-security -grecord-gcc-switches -m64 -mtune=generic -I/root/grub/fedora/grub2"
export LDFLAGS="-Wl,-z,relro"
export TARGET_LDFLAGS="-static"
 
exec ../configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --program-prefix= --disable-dependency-tracking --with-platform=efi --target=x86_64-redhat-linux-gnu --with-grubdir=grub --disable-grub-mount --disable-werror --enable-quiet-boot
FILE /root/grub/fedora/grub2/make2
#!/bin/bash
 
set -e
 
mkdir -p /root/grub/fedora/grub2/efi-64
cd /root/grub/fedora/grub2/efi-64
 
make -j4 ascii.h widthspec.h
make -j4 -C grub-core
rm -f grubx64.efi
grub-mkimage -O x86_64-efi -o grubx64.efi -p /EFI/fedora -d grub-core blscfg btrfs cat chain configfile echo efi_netfs efifwsetup efinet ext2 fat font gfxmenu gfxterm gzio halt hfsplus http iso9660 jpeg loadenv loopback linux lvm lsefi mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 png search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp xfs backtrace usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug all_video video videoinfo videotest keystatus
  1. Create 1 file using the following command:
    root #nano -w /root/grub/fedora/grub2/configure2
    and paste the contents of the configure script in there.
  2. Press CTRL + O, press [Enter] and press CTRL + X in order to save the file.
  3. Create 1 file using the following command:
    root #nano -w /root/grub/fedora/grub2/make2
    and paste the contents of the make script in there.
  4. Press CTRL + O, press [Enter] and press CTRL + X in order to save the file.
  5. Run the command
    root #./configure2
    and wait until it finishes.
  6. Run the command
    root #./make2
    and wait until it finishes.
  7. Once these scripts are done, a grubx64.efi file should have been automatically generated in the efi-64 sub folder. Copy this and replace the bootx64.efi
    root #cp /root/grub/fedora/grub2/efi-64/grubx64.efi /boot/EFI/BOOT/BOOTx64.efi
  8. Next, copy a file manually, in order to prevent a generated Error during reboot
    root #cp /usr/share/grub/unicode.pf2 /boot/EFI/fedora/fonts
  9. Then, generate a working grub.cfg file in order to be able to boot successfully. Run the command:
    root #nano -w /etc/default/grub
    and change it accordingly to look something like the file below.
FILE /etc/default/grub
GRUB_DISTRIBUTOR="Gentoo"
GRUB_DEFAULT=0
GRUB_DISABLE_OS_PROBER=true
GRUB_TIMEOUT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_CMDLINE_LINUX_DEFAULT="splash quiet i915.fastboot=1 loglevel=3 udev.log-priority=3 vt.global_cursor_default=0 init=/usr/lib/systemd/systemd"
GRUB_GFXMODE=auto
GRUB_GFXPAYLOAD_LINUX=keep
  1. Press CTRL + O, press [Enter] and press CTRL + X in order to save the file.
  2. Now, regenerate the grub.cfg file
    root #grub-mkconfig -o /boot/EFI/fedora/grub.cfg
  3. Finally, reboot and pray it's working:
    root #shutdown -r now

See also

  • Dracut — an initramfs infrastructure and aims to have as little as possible hard-coded into the initramfs.
  • Plymouth

External References