Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: How to have a custom UEFI grub menu for a multiboot system

  1. #1
    Join Date
    Jul 2018
    Location
    Florida, US
    Posts
    32

    Default How to have a custom UEFI grub menu for a multiboot system

    I have an UEFI system with a custom grub that currently boots Arch Linux, Windows 10 and openSUSE Tumbleweed.
    There is a bug open because openSUSE (and every other Linux system) does not correctly add the 2nd part of the Arch Linux initrd line. So, if you have Arch and do not want to edit that line every time you boot into Arch, this is the answer.
    It is totally maintenance free; it does not need any updating when a new kernel is installed, it just always works. The only time you would ever need to touch this file is if you added/removed an OS, or if a UUID changed.
    I tried installing Debian Testing on this system about 4 times and each time it would change the swap UUID causing major problems with all of my other systems. Needless to say I dropped that quest.

    You can use /etc/grub.d/40_custom for a start and then save the file as /etc/grub.d/06_custom because the point is to have this at the top until you get comfortable with it booting your systems.

    Then you make /etc/grub.d/10_linux and /etc/grub.d/30_os-prober unexecutable so only the custom menu entries display.

    There are just UUIDs and partitions that will need to be changed for this to work on your system.

    You can leave 40_custom as is but, you will not get any display output when grub is updated.
    I like to see a line displaying something when it update myself and here is how:

    The reason it says not to change the exec tail line is because +3 starts execution at line 3, the first menuentry line.
    Below in my custom grub you can see that there is an echo line and the +3 has been changed to +4 to start execution at the 4th line.

    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.
    First here are my partitions on the SSD /dev/sdc:
    Code:
    cavsfan@opensuse:~> sudo blkid | grep sdc
    /dev/sdc1: UUID="688D-126B" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="3c1b6d6f-8a24-43da-b595-8c304ceee48d"
    /dev/sdc2: PARTLABEL="Microsoft reserved partition" PARTUUID="49992d5b-79cd-4934-a12f-11782bb345bd"
    /dev/sdc3: UUID="C4968A52968A44C0" TYPE="ntfs" PARTLABEL="Windows_10" PARTUUID="345c85f4-bce7-4bc7-bbe0-db03eb319cad"
    /dev/sdc4: UUID="701AE4631AE427B4" TYPE="ntfs" PARTUUID="1e337754-b45d-45a5-a971-b8cdcae8a002"
    /dev/sdc5: UUID="be437b2b-9c95-4590-8d32-4da8e6c90318" TYPE="swap" PARTLABEL="Basic data partition" PARTUUID="3a259867-656d-41ed-9931-cf15a3bd0148"
    /dev/sdc6: LABEL="ArchLinux" UUID="bbca28b2-503e-4dc8-9850-c54bd0492da8" TYPE="ext4" PARTLABEL="Arch_Linux" PARTUUID="5312b771-0835-4957-80a6-9a8a7107f24a"
    /dev/sdc7: LABEL="opensuse" UUID="274e3321-d7af-4544-9afa-b1b3c118c325" TYPE="ext4" PARTUUID="25d7851a-f45f-4d60-955a-4a31706f8452"
    /dev/sdc8: UUID="55bba398-68d4-48db-9b54-d98d27cdf3ba" TYPE="ext4" PARTLABEL="Spare" PARTUUID="c4e0fdc9-7eac-4661-a7c6-c5a00c9a46fc"
    /dev/sdc10: LABEL="Media" UUID="840ac879-510a-4b8d-be01-9d3a5f37dbb2" TYPE="ext4" PARTLABEL="Media" PARTUUID="61e2e7f9-1a98-44f7-881e-ae85fceaf994"

    Here is my /etc/grub.d/06_custom file:
    Code:
    #!/bin/sh
    echo 1>&2 "Adding Arch Linux, Windows 10 and openSUSE Tumbleweed"
    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' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-bbca28b2-503e-4dc8-9850-c54bd0492da8' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        set root='hd2,gpt1'
        search --no-floppy --fs-uuid --set=root 688D-126B
        linux    /vmlinuz-linux root=UUID=bbca28b2-503e-4dc8-9850-c54bd0492da8 rw  quiet
        initrd    /intel-ucode.img /initramfs-linux.img
    }
    menuentry 'Arch Linux (fallback kernel)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-bbca28b2-503e-4dc8-9850-c54bd0492da8' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        set root='hd2,gpt1'
        search --no-floppy --fs-uuid --set=root 688D-126B
        linux    /vmlinuz-linux root=UUID=bbca28b2-503e-4dc8-9850-c54bd0492da8 rw  quiet
        initrd    /initramfs-linux-fallback.img
    }
    menuentry 'Windows 10' --class windows --class os $menuentry_id_option 'osprober-efi-688D-126B' {
        insmod part_gpt
        insmod fat
        set root='hd2,gpt1'
        search --no-floppy --fs-uuid --set=root 688D-126B
        chainloader /EFI/Microsoft/Boot/bootmgfw.efi
    }
    menuentry 'openSUSE Tumbleweed' --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-274e3321-d7af-4544-9afa-b1b3c118c325' {
        insmod part_gpt
        insmod ext2
        set root='hd2,gpt7'
        search --no-floppy --fs-uuid --set=root 274e3321-d7af-4544-9afa-b1b3c118c325
        linux /boot/vmlinuz root=/dev/sdc7 splash=silent resume=/dev/disk/by-uuid/be437b2b-9c95-4590-8d32-4da8e6c90318 quiet
        initrd /boot/initrd
    }
    Then make it executable: sudo chmod +x /etc/grub.d/06_custom.

    If you do not add the red swap UUID to the openSUSE entry you will not be able to wake from suspend. Been there...

    Of course be sure and change the partitions on each entry as shown in color purple as well as the colored UUIDs.

    I've been using this with nary a problem for some time now.

    MBR partitioned drives are much more simple to customize but, here is an UEFI SSD customized.

    This is the link to a Wiki that I maintain for Ubuntu to customize MBR partitioned drives - https://help.ubuntu.com/community/Ma...tomGrub2Screen

    It's always good to label your ext4 partitions with a name that is contiguous so that files can be copied across partitions.

    On Arch Linux, I added a background but, on openSUSE I did not try to add a background, I just left the default background theme as I think it looks nice.

    After you have added this and it's executable, if you do not want the first menuentry to be your default just edit sudo nano /etc/default/grub and change GRUB_DEFAULT=n to whatever you want.

    This will produce a list of which number to put there - numbering starts at zero:
    Code:
    sudo grep -e "menuentry " -e "submenu" /boot/grub2/grub.cfg | sed 's/^[ \t]*//' | cut -d "{" -f1 | nl --starting-line-number=0
    Be sure to update grub after you make any changes or you will lose those changes and wonder what happened during the next boot:
    Code:
    sudo grub2-mkconfig -o /boot/grub2/grub.cfg
    I hope that I have presented this in a way that is easily understandable. If you have any questions let me know.
    Intel Core i7-4770K, NVIDIA GeForce GTX 980 Ti, Mobo: ASUSTeK, model: Z87-K, Mem: 16GB,
    HD: OCZ VERTEX460 480GB SSD, 2 Toshiba 2TB SATA drives configured RAID 0, Sound Blaster Audigy Series

  2. #2
    Join Date
    Dec 2008
    Location
    FL, USA
    Posts
    818

    Default Re: How to have a custom UEFI grub menu for a multiboot system

    Quote Originally Posted by Cavsfan View Post
    I tried installing Debian Testing on this system about 4 times and each time it would change the swap UUID causing major problems with all of my other systems.
    That misfeature is easily worked around by specifying no swap installing Debian, then after installation is complete adding swap to fstab manually. Something I never seem to remember to try is turning existing swap on before letting the Debian installer proceed, to see if the installation process will skip wanting to format it.

    My custom.cfg files are somewhat simpler than yours, omitting obfiscatory options and human immemorable UUIDs, e.g.:
    Code:
    menuentry "memtest86 7.4 EFI" {
    	search --no-floppy --label --set=root K25P01ESP
    	chainloader /mt74x64.efi
    }
    menuentry "openSUSE TW defkernel" {
    	search --no-floppy --set=root --hint-bios=hd0,gpt7 --label k25p07stw
    	linux	/boot/vmlinuz root=LABEL=k25p07stw noresume
    	initrd	/boot/initrd
    }
    menuentry "openSUSE 15.0 defkernel" {
    	search --no-floppy --set=root --hint-efi=hd0,gpt8 --label k25p08s150
    	linux	/boot/vmlinuz root=LABEL=k25p08s150 noresume
    	initrd	/boot/initrd
    }
    menuentry "openSUSE 15.1 defkernel" {
    	search --no-floppy --set=root --hint-efi=hd0,gpt9 --label k25p09s151
    	linux	/boot/vmlinuz root=LABEL=k25p09s151 noresume
    	initrd	/boot/initrd
    }
    menuentry "Debian 10 Buster defkernel" {
    	search --no-floppy --set=root --hint-baremetal=ahci0,gpt10 --label k25p10deb10
    	linux	/boot/vmlinuz root=LABEL=k25p10deb10 noresume
    	initrd	/boot/initrd
    }
    menuentry "Debian 10 Fat Buster defkernel" {
    	search --no-floppy --set=root --hint-baremetal=ahci0,gpt11 --label k25p11deb10fat
    	linux	/boot/vmlinuz root=LABEL=k25p11deb10fat noresume
    	initrd	/boot/initrd
    }
    menuentry "Tubuntu 18.04 defkernel" {
    	search --no-floppy --set=root --hint-baremetal=ahci0,gpt12 --label k25p12Ubionic
    	linux	/boot/vmlinuz root=LABEL=k25p12Ubionic noresume
    	initrd	/boot/initrd
    }
    I don't bother with the execute bits in /etc/grub.d/. 06_custom makes custom.cfg entries first, so the cruft grub2-mkconfig generates doesn't really matter, while keeping it retains easy access to prior kernels.

    All my MBR PCs boot from generic MBR code and openSUSE Gfxboot Grub 0.97-203.7 or older on a small primary partition with self-generated menu.lst, roughly similar to above custom.cfg, and penguin=100.

    This thread probably ought to be in Unreviewed How To and FAQ
    Reg. Linux User #211409 *** multibooting since 1992
    Primary: 42.3,TW,15.0 & 13.1 on Haswell w/ RAID
    Secondary: eComStation (OS/2) & 42.3 on 965P/Radeon
    Tertiary: TW,15.0,42.3,Fedora,Debian,others on Kaby Lake,Q45,Q43,G41,G3X,965G,Cedar,Caicos,GT218 &&&&

  3. #3
    Join Date
    Jul 2018
    Location
    Florida, US
    Posts
    32

    Default Re: How to have a custom UEFI grub menu for a multiboot system

    Quote Originally Posted by mrmazda View Post
    That misfeature is easily worked around by specifying no swap installing Debian, then after installation is complete adding swap to fstab manually. Something I never seem to remember to try is turning existing swap on before letting the Debian installer proceed, to see if the installation process will skip wanting to format it.

    My custom.cfg files are somewhat simpler than yours, omitting obfiscatory options and human immemorable UUIDs,

    I don't bother with the execute bits in /etc/grub.d/. 06_custom makes custom.cfg entries first, so the cruft grub2-mkconfig generates doesn't really matter, while keeping it retains easy access to prior kernels.

    All my MBR PCs boot from generic MBR code and openSUSE Gfxboot Grub 0.97-203.7 or older on a small primary partition with self-generated menu.lst, roughly similar to above custom.cfg, and penguin=100.

    This thread probably ought to be in Unreviewed How To and FAQ
    That's a great idea when installing Debian. If I do install Testing I will leave out swap while installing it. It is a rolling release too as testing is never finished, so I may try that and use your advice this time.

    I know there is the way of using labels like you have done but, I just went for the simplest things that would boot on my system. Some people said they were able to just use /dev/sdx but, I never had any luck with that.
    My method is simple if you don't mind copying UUIDs. But, I guess there are a lot of options to customizing grub; it just has to boot.

    My old PC is 10 years old next April and still works but, very slow. That is where I learned how to customize MBR partitions. I have Arch Linux, openSUSE TW, about 3 Xubuntu installs on it but, I dare not touch it.
    After I installed openSUSE TW, it would not boot and it appeared that Grub rescue was needed but, even that did not work. I tried several things and the last thing I did was booted with a Windows 10 recovery DVD in the drive, it booted up and my grub was mysteriously back on Arch Linux.
    Since there is no logical explanation for that, I will leave it as is and boot into Windows 10 only.

    My wife gets on it. Time for an upgrade of that one.

    I like Grub 2 as everything is fairly uniform across platforms. This EFI SSD concept is new to me but, I am learning.

    If an admin wants to move this thread to Unreviewed How To and FAQ that would be fine by me.

    Thanks for the reply!
    Intel Core i7-4770K, NVIDIA GeForce GTX 980 Ti, Mobo: ASUSTeK, model: Z87-K, Mem: 16GB,
    HD: OCZ VERTEX460 480GB SSD, 2 Toshiba 2TB SATA drives configured RAID 0, Sound Blaster Audigy Series

  4. #4
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    18,759
    Blog Entries
    14

    Default Re: How to have a custom UEFI grub menu for a multiboot system

    If this bug exists on all other linux distros, this is not a bug in those other distrosm, but one in Arch bug, since creating decent GRUB2 entries works for other installed distros. This is not the first time Arch can't coexist properly with other linuces. If they want changes in upstream GRUB2, that's where they have to be.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  5. #5
    Join Date
    Sep 2012
    Posts
    4,689

    Default Re: How to have a custom UEFI grub menu for a multiboot system

    Quote Originally Posted by Knurpht View Post
    If this bug exists on all other linux distros, this is not a bug in those other distrosm, but one in Arch bug
    This is a bug in os-prober which cannot parse legitimate grub command. Do your home work before coming up with such statements.

  6. #6
    Join Date
    Jul 2018
    Location
    Florida, US
    Posts
    32

    Default Re: How to have a custom UEFI grub menu for a multiboot system

    Quote Originally Posted by Knurpht View Post
    If this bug exists on all other linux distros, this is not a bug in those other distrosm, but one in Arch bug, since creating decent GRUB2 entries works for other installed distros. This is not the first time Arch can't coexist properly with other linuces. If they want changes in upstream GRUB2, that's where they have to be.
    Quote Originally Posted by arvidjaar View Post
    This is a bug in os-prober which cannot parse legitimate grub command. Do your home work before coming up with such statements.
    All other distros I've tried Xubuntu, openSUSE Tumbleweed and pretty much everything else do not take into account there could be 2 img entries on the initrd line, which must be new on UEFI systems.

    Here is the bug if you want to look it over but, that is pretty much what Michael Chang said.

    https://bugzilla.opensuse.org/show_bug.cgi?id=1101942

    At this time, there are only 3 users signed onto the bug. So I gather there are not many Arch Linux users that dual, multi-boot openSUSE.

    I know I opened another bug in Ubuntu but, I cannot find it. It had only 2 users on it last time I looked. A friend and I that dual boot Arch and other stuff.

    @mrmazda, I did install Debian daily and then turned it into testing so it's rolling too. But, I could not prevent it from finding my swap file, so of course it "formatted" it and changed the UUID.
    But, I edited the fstab on Arch and openSUSE before I booted into either of them. So, I won that battle.
    Intel Core i7-4770K, NVIDIA GeForce GTX 980 Ti, Mobo: ASUSTeK, model: Z87-K, Mem: 16GB,
    HD: OCZ VERTEX460 480GB SSD, 2 Toshiba 2TB SATA drives configured RAID 0, Sound Blaster Audigy Series

  7. #7
    Join Date
    Dec 2008
    Location
    FL, USA
    Posts
    818

    Default Re: How to have a custom UEFI grub menu for a multiboot system

    Quote Originally Posted by Cavsfan View Post
    I could not prevent it from finding my swap file, so of course it "formatted" it and changed the UUID.
    Finding and using aren't identical twins. In the Debian partitioner, change the "found" swap partition to "not used" before exiting partitioner to prevent the collateral damage.
    Reg. Linux User #211409 *** multibooting since 1992
    Primary: 42.3,TW,15.0 & 13.1 on Haswell w/ RAID
    Secondary: eComStation (OS/2) & 42.3 on 965P/Radeon
    Tertiary: TW,15.0,42.3,Fedora,Debian,others on Kaby Lake,Q45,Q43,G41,G3X,965G,Cedar,Caicos,GT218 &&&&

  8. #8
    Join Date
    Jul 2018
    Location
    Florida, US
    Posts
    32

    Default Re: How to have a custom UEFI grub menu for a multiboot system

    Quote Originally Posted by Cavsfan View Post
    I could not prevent it from finding my swap file, so of course it "formatted" it and changed the UUID.
    Quote Originally Posted by mrmazda View Post
    Finding and using aren't identical twins. In the Debian partitioner, change the "found" swap partition to "not used" before exiting partitioner to prevent the collateral damage.
    I attempted installation about 3 times and could not see any way to make it ignore the swap partition so, knowing that I only had 2 systems that used swap, I just went for it.
    Actually I installed it twice and the 2nd time was much better than the first for some reason. The first time never gave me access to compiz, ccsm, etc. and I gotta have those bells, whistles and bling but, the 2nd time did.

    If I every install it again, which I doubt, I'll look harder for what you are mentioning. For the life of me all I could see was use it or delete it and both would have left me with the same issue.

    But, for now I've got 3 rolling releases. Oh and openSUSE still did the count down at reboot for the 1:30 because I did not change the swap UUID on the openSUSE linux line:
    Code:
    linux /boot/vmlinuz root=/dev/sdc7 splash=silent resume=/dev/disk/by-uuid/be437b2b-9c95-4590-8d32-4da8e6c90318 quiet
    But, I remembered that last night and changed it this morning. It rebooted nicely after getting a dist upgrade.
    Code:
    cavsfan@opensuse:~> uname -r
    4.18.8-1-default
    I love how openSUSE is keeping up with Arch Linux on the latest kernels. Even Debian Testing has a 4.18 kernel.
    They both have excellent working Fusion-Icons too. +1
    Intel Core i7-4770K, NVIDIA GeForce GTX 980 Ti, Mobo: ASUSTeK, model: Z87-K, Mem: 16GB,
    HD: OCZ VERTEX460 480GB SSD, 2 Toshiba 2TB SATA drives configured RAID 0, Sound Blaster Audigy Series

  9. #9
    Join Date
    Dec 2008
    Location
    FL, USA
    Posts
    818

    Default Re: How to have a custom UEFI grub menu for a multiboot system

    Quote Originally Posted by Cavsfan View Post
    I attempted installation about 3 times and could not see any way to make it ignore the swap partition
    You can't make it "ignore" it. Instead you make it not use it. From https://wiki.debian.org/LennyIllustratedInstall

    Double click on swap partition (#5).
    Double click on "Use as" and change to "do not use", then double click on "Done setting up the partition"

    The logic is identical if using text mode installation, only the colors and text sizes differ, and you use keyboard <Enter> and cursor keys instead of pointing device.
    Reg. Linux User #211409 *** multibooting since 1992
    Primary: 42.3,TW,15.0 & 13.1 on Haswell w/ RAID
    Secondary: eComStation (OS/2) & 42.3 on 965P/Radeon
    Tertiary: TW,15.0,42.3,Fedora,Debian,others on Kaby Lake,Q45,Q43,G41,G3X,965G,Cedar,Caicos,GT218 &&&&

  10. #10
    Join Date
    Jul 2018
    Location
    Florida, US
    Posts
    32

    Default Re: How to have a custom UEFI grub menu for a multiboot system

    Quote Originally Posted by Cavsfan View Post
    I attempted installation about 3 times and could not see any way to make it ignore the swap partition
    Quote Originally Posted by mrmazda View Post
    You can't make it "ignore" it. Instead you make it not use it. From https://wiki.debian.org/LennyIllustratedInstall

    Double click on swap partition (#5).
    Double click on "Use as" and change to "do not use", then double click on "Done setting up the partition"

    The logic is identical if using text mode installation, only the colors and text sizes differ, and you use keyboard <Enter> and cursor keys instead of pointing device.
    Ok, I get it. I see that I should have double clicked on swap but, just didn't so, that's my fault. The good news is I recovered after changing all the other places swap UUID was used.
    The bad news is soon after that, my Debian install "messed up". It's hard to describe but, lots of things were just not displaying correctly so I deleted the partition. I'm tired of fighting with Debian based systems.

    Ubuntu and Debian, etc. are supposed to be the easiest Linux distribution to work with but, on this UEFI machine that has not been true as a matter of fact, I've had more trouble with them than anything.
    I installed Xubuntu 18.04 LTS about 5-6 times and each time, it became useless so I would install it again thinking I could make it work. But, now I have a new philosophy: if it does not have a working Fusion Icon, it's not for me.

    Here is a picture of my current grub screen on Arch. The font colors at the top and bottom I cannot change but, for COLOR_NORMAL I have cyan and for COLOR_HIGHLIGHT I have red.
    The cyan is the box and everything inside except the highlighted line.
    Just 4 entries:
    https://imgur.com/rTredvc

    The picture is not that good as I'm not a photographer. But, it shows what I have.

    When my grub is on openSUSE I just use the default theme but, one day I'll give a background and font colors a shot.
    Intel Core i7-4770K, NVIDIA GeForce GTX 980 Ti, Mobo: ASUSTeK, model: Z87-K, Mem: 16GB,
    HD: OCZ VERTEX460 480GB SSD, 2 Toshiba 2TB SATA drives configured RAID 0, Sound Blaster Audigy Series

Page 1 of 3 123 LastLast

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
  •