Results 1 to 4 of 4

Thread: How to create a custom grub screen that is maintenance free for UEFI/GPT and Legacy/MBR systems

  1. #1
    Join Date
    Jul 2018
    Location
    US
    Posts
    79

    Default How to create a custom grub screen that is maintenance free for UEFI/GPT and Legacy/MBR systems

    How to create a custom grub menu and background of your choosing on openSUSE. Once it is setup, the only time you will need to change anything is if you add or delete a system or wish to change the background.
    This process uses the symlinks to access the kernel so, unless there are more than the normal 2 or you create more, you will only be able to boot into the most recently installed kernel.

    Every time you make a change to a grub file make sure and enter sudo grub2-mkconfig -o /boot/grub2/grub.cfg or the changes will not take effect.

    The goal of this is to make all of your linux systems boot from 06_custom so after you are comfortable that the custom file works, you make some of the other files in /etc/grub.d unexecutable: 10_linux, 20_memtest86+ and 30_os-prober (sudo chmod -x /etc/grub.d/10_linux, etc.) and update grub.

    In my 10 years experience with Linux, I have never once needed to boot into an older kernel and if you did you could make either 10_linux or 30_os-prober executable. (sudo chmod -x /etc/grub.d/10_linux, etc. and update grub)

    I have 9 Linux systems plus Windows 10 installed on my PC at the present time and this works for all of them.

    I recommend a darker background since the menu lines will be white/grey and too light to see on light backgrounds. This is entirely up to you.

    1st, find an image that you would like as a background that is the same resolution as your screen. JPG, TIF, etc are supposed to work but, do not always. So I'd go with a PNG image.

    You can easily convert a JPG or other type of image to PNG with GIMP. Just edit the picture with GIMP and then click File > Export As, then click on Select File Type and scroll down to PNG and click Export, then click OK on the next popup and close GIMP.
    It will save a PNG with the same name as the JPG in the same folder.

    You will edit /etc/grub.d/40_custom file and then save it as /etc/grub.d/06_custom so that it appears at the top.
    Leaving the original 40_custom file untouched.

    Although it says "do not change the exec tail line". Here is how you do and why:
    (default /etc/grub.d/40_custom​)
    Code:
    #!/bin/sh
    exec tail -n +3 $0
    # This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    You change the +3 to +4 so that execution begins on the 4th line and not the 3rd so that you can see some output when you update grub.
    This is the top of my 06_custom file (I keep a working copy in my home directory and move it to /etc/grub.d/06_custom when I make changes to it):
    Code:
    #!/bin/sh
    echo 1>&2 "Adding Arch Linux (rolling), Debian Buster, Debian Testing, Fedora 30, openSUSE Tumbleweed (rolling), MX Linux 18.3 Continuum, MX 19 Beta (Patito Feo), Xubuntu 18.04.2 Bionic Beaver LTS, Xubuntu 19.10 Eoan Ermine, and Windows 10"
    exec tail -n +4 $0
    # This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    What you see when you update grub is what you enter on that line between the quotes and what you see on the menu is what is between the quotes on the menuentry lines.
    Here is what it would look like if you just had openSUSE TW and Windows 10:
    Code:
    #!/bin/sh
    echo 1>&2 "Adding openSUSE Tumbleweed (rolling) and Windows 10"
    exec tail -n +4 $0
    # This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    menuentry 'openSUSE Tumbleweed (rolling)' {
        search --no-floppy --fs-uuid --set=root a04f3172-9e2d-4163-ac31-ffe586229602
        linuxefi  /boot/vmlinuz root=UUID=a04f3172-9e2d-4163-ac31-ffe586229602 splash=silent resume=/dev/disk/by-uuid/b564ed75-b9ee-410f-9f87-04afc30a0ff4 mitigations=auto quiet
        initrdefi /boot/initrd
    }
    menuentry 'Windows 10' {
        set root='hd2,gpt1'
        search --no-floppy --fs-uuid --set=root 688D-126B
        chainloader /EFI/Microsoft/Boot/bootmgfw.efi
    }
    UEFI/GPT systems can be customized by linking UUIDs of the Partition the system is on and sometimes the swap partition.
    sudo blkid will give the partitions (I always label my partitions too as it makes it a lot easier to read):
    Code:
    cavsfan@openSUSE:~> sudo blkid
    /dev/sdc1: UUID="688D-126B" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="15661847-bc65-401a-84b0-97a157f3949f"
    /dev/sdc2: PARTLABEL="Microsoft reserved partition" PARTUUID="6b26da12-6fdc-4ce5-bde3-c990cdfc081b"
    /dev/sdc3: LABEL="C:" UUID="C4968A52968A44C0" TYPE="ntfs" PARTLABEL="Windows_10" PARTUUID="a76c4894-4d85-457e-8bc6-9d5308bef571"
    /dev/sdc4: UUID="9C9AE5269AE4FE20" TYPE="ntfs" PARTUUID="94858fd1-334c-47f7-bfab-266b49f0a0ba"
    /dev/sdc5: UUID="b564ed75-b9ee-410f-9f87-04afc30a0ff4" TYPE="swap" PARTLABEL="swap" PARTUUID="dc354366-1300-48d4-8a60-133aa2e2ca57"
    /dev/sdc8: LABEL="openSUSE" UUID="a04f3172-9e2d-4163-ac31-ffe586229602" TYPE="ext4" PARTLABEL="openSUSE" PARTUUID="dcaa5edb-0510-4bab-93e4-b238b329dbf7"
    Then in /etc/default/grub you'll make just a couple of changes:
    Here is my whole file with the changes in red.
    I changed the default line to 18, it starts at 0, 1, 2, 3, etc.
    I added a # in front of the GRUB_THEME line and the location of the grub background (with no quotes).

    Code:
    # If you change this file, run 'grub2-mkconfig -o /boot/grub2/grub.cfg' afterwards to update
    # /boot/grub2/grub.cfg.
    
    
    # Uncomment to set your own custom distributor. If you leave it unset or empty, the default
    # policy is to determine the value from /etc/os-release
    GRUB_DISTRIBUTOR=
    GRUB_DEFAULT=18
    GRUB_HIDDEN_TIMEOUT=0
    GRUB_HIDDEN_TIMEOUT_QUIET=true
    GRUB_TIMEOUT=60
    GRUB_CMDLINE_LINUX_DEFAULT="splash=silent resume=/dev/disk/by-uuid/b564ed75-b9ee-410f-9f87-04afc30a0ff4 mitigations=auto quiet"
    GRUB_CMDLINE_LINUX=""
    
    
    # Uncomment to automatically save last booted menu entry in GRUB2 environment
    
    
    # variable `saved_entry'
    # GRUB_SAVEDEFAULT="true"
    #Uncomment to enable BadRAM filtering, modify to suit your needs
    
    
    # This works with Linux (no patch required) and with any kernel that obtains
    # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
    # GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
    #Uncomment to disable graphical terminal (grub-pc only)
    
    
    GRUB_TERMINAL="gfxterm"
    # The resolution used on graphical terminal
    #note that you can use only modes which your graphic card supports via VBE
    
    
    # you can see them in real GRUB with the command `vbeinfo'
    GRUB_GFXMODE="auto"
    # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
    # GRUB_DISABLE_LINUX_UUID=true
    #Uncomment to disable generation of recovery mode menu entries
    
    
    # GRUB_DISABLE_RECOVERY="true"
    #Uncomment to get a beep at grub start
    
    
    # GRUB_INIT_TUNE="480 440 1"
    GRUB_BACKGROUND=/boot/grub2/backgrounds/Beautiful-dark-forest-tree-with-red-leaves-3840x2160.png
    #GRUB_THEME=/boot/grub2/themes/openSUSE/theme.txt
    SUSE_BTRFS_SNAPSHOT_BOOTING="true"
    GRUB_USE_LINUXEFI="true"
    GRUB_DISABLE_OS_PROBER="false"
    GRUB_ENABLE_CRYPTODISK="n"
    GRUB_CMDLINE_XEN_DEFAULT="vga=gfx-1024x768x16"
    I mentioned the 9 Linux systems I have installed and here is my 06_custom file:
    Code:
    #!/bin/sh
    echo 1>&2 "Adding Arch Linux (rolling), Debian Buster, Debian Testing, Fedora 30, openSUSE Tumbleweed (rolling), MX Linux 18.3 Continuum, MX 19 Beta (Patito Feo), Xubuntu 18.04.2 Bionic Beaver LTS, Xubuntu 19.10 Eoan Ermine, and Windows 10"
    exec tail -n +4 $0
    # This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    menuentry 'Arch Linux' {
        search --no-floppy --fs-uuid --set=root 688D-126B
        linuxefi  /vmlinuz-linux root=UUID=bbca28b2-503e-4dc8-9850-c54bd0492da8 rw quiet
        initrdefi /intel-ucode.img /initramfs-linux.img
    }
    menuentry 'Arch Linux (fallback kernel)' {
        search --no-floppy --fs-uuid --set=root 688D-126B
        linuxefi  /vmlinuz-linux root=UUID=bbca28b2-503e-4dc8-9850-c54bd0492da8 rw quiet
        initrdefi /initramfs-linux-fallback.img
    }
    menuentry 'Debian Buster' {
        search --no-floppy --fs-uuid --set=root dbbd22d7-0110-47d4-932b-2f19c83bcbca
        linuxefi  /vmlinuz root=UUID=dbbd22d7-0110-47d4-932b-2f19c83bcbca ro quiet
        initrdefi /initrd.img
    }
    menuentry 'Debian Buster (recovery mode)' {
        search --no-floppy --fs-uuid --set=root dbbd22d7-0110-47d4-932b-2f19c83bcbca
        linuxefi  /vmlinuz root=UUID=dbbd22d7-0110-47d4-932b-2f19c83bcbca ro recovery nomodeset
        initrdefi /initrd.img
    }
    menuentry 'Debian Testing' {
        search --no-floppy --fs-uuid --set=root 1b019591-4bf0-4781-bf86-fdc044ef8ae7
        linuxefi  /vmlinuz root=UUID=1b019591-4bf0-4781-bf86-fdc044ef8ae7 ro quiet
        initrdefi /initrd.img
    }
    menuentry 'Debian Testing (recovery mode)' {
        search --no-floppy --fs-uuid --set=root 1b019591-4bf0-4781-bf86-fdc044ef8ae7
        linuxefi  /vmlinuz root=UUID=1b019591-4bf0-4781-bf86-fdc044ef8ae7 ro recovery nomodeset
        initrdefi /initrd.img
    }
    menuentry 'Fedora (Workstation) 30' {
        search --no-floppy --fs-uuid --set=root 43cd93b8-2442-42df-88a3-7bf069390d49
        linuxefi  /boot/vmlinuz root=UUID=43cd93b8-2442-42df-88a3-7bf069390d49 ro rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 resume=UUID=b564ed75-b9ee-410f-9f87-04afc30a0ff4 rhgb quiet LANG=en_US.UTF-8
        initrdefi /boot/initrd.img
    }
    menuentry 'openSUSE Tumbleweed (rolling)' {
        search --no-floppy --fs-uuid --set=root a04f3172-9e2d-4163-ac31-ffe586229602
        linuxefi  /boot/vmlinuz root=UUID=a04f3172-9e2d-4163-ac31-ffe586229602 splash=silent resume=/dev/disk/by-uuid/b564ed75-b9ee-410f-9f87-04afc30a0ff4 mitigations=auto quiet
        initrdefi /boot/initrd
    }
    menuentry 'MX 18.3 Continuum' {
        search --no-floppy --fs-uuid --set=root 5c08bfe7-ff75-4fcb-8da8-8500ea08da37
        lnuxefi  /boot/vmlinuz root=UUID=5c08bfe7-ff75-4fcb-8da8-8500ea08da37 ro quiet splash
        initrdefi /boot/initrd
    }
    menuentry 'MX 18.3 Continuum - Systemd' {
        search --no-floppy --fs-uuid --set=root 5c08bfe7-ff75-4fcb-8da8-8500ea08da37
        iinuxefi  /boot/vmlinuz root=UUID=5c08bfe7-ff75-4fcb-8da8-8500ea08da37 ro quiet splash init=/lib/systemd/systemd
        initrdefi /boot/initrd
    }
    menuentry 'MX 18.3 Continuum - Recovery Mode' {
         search --no-floppy --fs-uuid --set=root 5c08bfe7-ff75-4fcb-8da8-8500ea08da37
         linuxefi  /boot/vmlinuz root=UUID=5c08bfe7-ff75-4fcb-8da8-8500ea08da37 ro single
         initrdefi /boot/initrd
    }
    menuentry 'MX 19 Beta (Patito Feo)' {
         search --no-floppy --fs-uuid --set=root 1a1d8718-7e93-4fe5-9f11-2dbcb17e629e
         linuxefi  /boot/vmlinuz root=UUID=1a1d8718-7e93-4fe5-9f11-2dbcb17e629e ro quiet splash
         initrdefi /boot/initrd
    }
    menuentry 'MX 19 Beta (Patito Feo) Systemd' {
          search --no-floppy --fs-uuid --set=root 1a1d8718-7e93-4fe5-9f11-2dbcb17e629e
          linuxefi  /boot/vmlinuz root=UUID=1a1d8718-7e93-4fe5-9f11-2dbcb17e629e ro quiet splash init=/lib/systemd/systemd
          initrdefi /boot/initrd
    }
    menuentry 'MX 19 Beta (Patito Feo) Recovery Mode' {
          search --no-floppy --fs-uuid --set=root 1a1d8718-7e93-4fe5-9f11-2dbcb17e629e
          linuxefi  /boot/vmlinuz root=UUID=1a1d8718-7e93-4fe5-9f11-2dbcb17e629e ro single
          initrdefi /boot/initrd
    }
    menuentry 'Xubuntu 18.04.2 Bionic Beaver LTS' {
        search --no-floppy --fs-uuid --set=root 338e6d3b-cbd4-496d-9cc2-b688a90c17c3
        linuxefi  /vmlinuz root=UUID=338e6d3b-cbd4-496d-9cc2-b688a90c17c3 ro quiet resume=/dev/disk/by-uuid/b564ed75-b9ee-410f-9f87-04afc30a0ff4 splash
        initrdefi /initrd.img
    }
    menuentry 'Xubuntu 18.04.2 Bionic Beaver LTS (recovery mode)' {
        search --no-floppy --fs-uuid --set=root 338e6d3b-cbd4-496d-9cc2-b688a90c17c3
        linuxefi  /vmlinuz root=UUID=338e6d3b-cbd4-496d-9cc2-b688a90c17c3 ro recovery nomodeset
        initrdefi /initrd.img
    }
    menuentry 'Xubuntu 19.10 Eoan Ermine' {
        search --no-floppy --fs-uuid --set=root e855cdb4-de6e-458f-8715-dd5e9e8ed5d5
        linuxefi  /boot/vmlinuz root=UUID=e855cdb4-de6e-458f-8715-dd5e9e8ed5d5 ro quiet splash
        initrdefi /boot/initrd.img
    }
    menuentry 'Xubuntu 19.10 Eoan Ermine (recovery mode)' {
        search --no-floppy --fs-uuid --set=root e855cdb4-de6e-458f-8715-dd5e9e8ed5d5
        linuxefi /boot/vmlinuz root=e855cdb4-de6e-458f-8715-dd5e9e8ed5d5 ro recovery nomodeset
        initrdefi /boot/initrd.img
    }
    menuentry 'Windows 10' {
        set root='hd2,gpt1'
        search --no-floppy --fs-uuid --set=root 688D-126B
        chainloader /EFI/Microsoft/Boot/bootmgfw.efi
    }
    Once you get it somewhat setup you can determine what to put in the default line with this command:
    Code:
    sudo grep -e "menuentry " -e "submenu" /boot/grub2/grub.cfg | sed 's/^[ \t]*//' | cut -d "{" -f1 | nl --starting-line-number=0
    or if you just want to look at 06_custom in your home directory:
    Code:
    grep -e "menuentry " -e "submenu" ~/06_custom | sed 's/^[ \t]*//' | cut -d "{" -f1 | nl --starting-line-number=0
    Fedora does not create or use symlinks for the kernel but, if you are using Fedora I created a script that runs when a new kernel is installed and creates the symlinks. I'd be more than happy to share it with you.

    Here is what the output of my update grub looks like and it does it a lot faster than normal grub, sometimes 20 times faster.
    Code:
    cavsfan@openSUSE:~> sudo grub2-mkconfig -o /boot/grub2/grub.cfg
    [sudo] password for root: 
    Generating grub configuration file ...
    Found background: /boot/grub2/backgrounds/Beautiful-dark-forest-tree-with-red-leaves-3840x2160.png
    Adding Arch Linux (rolling), Debian Buster, Debian Testing, Fedora 30, openSUSE Tumbleweed (rolling), MX Linux 18.3 Continuum, MX 19 Beta (Patito Feo), Xubuntu 18.04.2 Bionic Beaver LTS, Xubuntu 19.10 Eoan Ermine, and Windows 10
    done


    I've just shown how to customize a UEFI/GPT SSD but, if this is worth adding to the How To section, I can add the Legacy/MBR partitioning method, which is much simpler.
    Intel Core i7-4770K, NVIDIA GeForce GTX 980 Ti, Mobo: ASUSTeK, model: Z87-K, Mem: 16GB, Sound Blaster Audigy Series, HD: Western Digital 1TB SSD, OCZ 500GB SSD and a Toshiba 2TB SATA HD

  2. #2
    Join Date
    Jul 2018
    Location
    US
    Posts
    79

    Default Re: How to create a custom grub screen that is maintenance free for UEFI/GPT and Legacy/MBR systems

    Also in /etc/grub.d/00_header on EFI systems, need to comment out line 243 or all 3 lines.:
    Code:
    242    if [ -d /sys/firmware/efi ]; then
    243     # echo 'echo "Please press 't' to show the boot menu on this console"'
    244    fi
    Since this is an erroneous statement, commenting it out makes the menu display faster.
    Intel Core i7-4770K, NVIDIA GeForce GTX 980 Ti, Mobo: ASUSTeK, model: Z87-K, Mem: 16GB, Sound Blaster Audigy Series, HD: Western Digital 1TB SSD, OCZ 500GB SSD and a Toshiba 2TB SATA HD

  3. #3
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,879
    Blog Entries
    3

    Default Re: How to create a custom grub screen that is maintenance free for UEFI/GPT and Legacy/MBR systems

    Quote Originally Posted by Cavsfan View Post
    Since this is an erroneous statement, commenting it out makes the menu display faster.
    I'm not so sure that's erroneous.

    Booting a virtual machine, I have occasionally setup a console in a root terminal. So I run the command:
    Code:
    virsh console virtual-machine-name
    immediately after starting the virtual machine.

    That line "Please press 't' to show the boot menu on this console" appears on that terminal screen. But the boot menu does not show up there unless I press 't'. The boot menu does always show up on the main GUI window for the VM.
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

  4. #4
    Join Date
    Jul 2018
    Location
    US
    Posts
    79

    Default Re: How to create a custom grub screen that is maintenance free for UEFI/GPT and Legacy/MBR systems

    Quote Originally Posted by nrickert View Post
    I'm not so sure that's erroneous.

    Booting a virtual machine, I have occasionally setup a console in a root terminal. So I run the command:
    Code:
    virsh console virtual-machine-name
    immediately after starting the virtual machine.

    That line "Please press 't' to show the boot menu on this console" appears on that terminal screen. But the boot menu does not show up there unless I press 't'. The boot menu does always show up on the main GUI window for the VM.
    I don't believe a custom grub is suitable for a virtual machine. It is meant for regular installed systems on desktops and laptops that mutli-boot more than one system. Not only that, it should be installed on a solid installation.

    That message is erroneous in this case. I have made these files unexecutable so they do not produce any output: /etc/grub.d/10_linux, /etc/grub.d/20_memtest86+ and /etc/grub.d/30_os-prober and the only thing produced is from /etc/grub.d/06_custom.

    That message displays before the custom grub menu does because it thinks there is no menu and you need to press the letter 't' to show the menu.
    So, since the menu is already there, pressing the letter 't' just makes the background go away but, the menu is there either way.

    I installed my old SATA HD in this PC and when normal grub runs it takes forever because it scans all 4 hard drives, finds those old Linux installs and adds them needlessly to the grub menu.
    To update grub with 10 systems (9 Linux and Windows 10) and a custom file takes ~5 seconds.
    Intel Core i7-4770K, NVIDIA GeForce GTX 980 Ti, Mobo: ASUSTeK, model: Z87-K, Mem: 16GB, Sound Blaster Audigy Series, HD: Western Digital 1TB SSD, OCZ 500GB SSD and a Toshiba 2TB SATA HD

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •