Originally posted by zahtar
View Post
Announcement
Collapse
No announcement yet.
Manually configure GRUB for multi-boot, persistent to kernel updates
Collapse
X
-
that last unmatched "{" is a problem. I suggest removing the $vt_handoff too.
- Top
- Bottom
-
Fair enough, it seems I´ll need to do some homework before I can complete this.
The asterisks in the windows menu entry in the previous post are in the place of a UUID, but let´s forget about that, because that syntax was the suggestion of chatgpt.
The menu entry mentioned below for windows is copied and pasted from the laptops /boot/grub/grub.cfg (kubuntu partition) and works fine. I think I did some tweaks to the kubuntu entry, to make it persistent to kernel updates.
The Vanilla menu entry that looks different, was copied from the grub.cfg in the Vanilla partition. But maybe I need a different syntax here? Or perhaps to chainload it somehow?
I tidied up the code and I am now re-posting it, I´ve commented out the lines you said are redundant:
Code:#!/bin/sh exec tail -n +3 $0 menuentry 'Kubuntu 26.04' --class kubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-[UUID of kubuntu root partition]' { recordfail # load_video # set gfxpayload=$linux_gfx_mode # insmod gzio # if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi # insmod part_gpt # insmod ext2 search --no-floppy --fs-uuid --set=root [UUID of kubuntu root partition] linux /boot/vmlinuz root=UUID=[UUID of kubuntu root partition] ro quiet splash $vt_handoff{ initrd /boot/initrd.img } menuentry 'Windows Boot Manager' --class windows --class os $menuentry_id_option 'osprober-efi-[UUID of windows partition]' { insmod part_gpt insmod fat search --no-floppy --fs-uuid --set=root [UUID of windows partition] chainloader /efi/Microsoft/Boot/bootmgfw.efi } menuentry "Vanilla OS - Current State (A)" --class abroot-a { search --fs-uuid --no-floppy --set=root(lvm/vos--root-init) configfile "/vos-a/abroot.cfg" chainloader /boot/efi/EFI/vanilla/grub.cfg } menuentry "Vanilla OS - Previous State (B)" --class abroot-b { search --fs-uuid --no-floppy --set=root(lvm/vos--root-init) configfile "/vos-b/abroot.cfg" chainloader /boot/efi/EFI/vanilla/grub.cfg }
Are the above supposed to be added to /etc/grub.d/40_custom ?
If I understand correctly, the main thing now is to find how to create a menu entry for Vanilla, either for chainloading, or for direct boot. The chainloading option sounds better due to the special way the os has to apply updates.Last edited by zahtar; May 03, 2026, 07:21 AM.
- Top
- Bottom
Leave a comment:
-
Firstly, a general note. Manually coding grub files suggests one should learn about- sudo efibootmgr
- /etc/fstab
- /etc/default/grub
- grub.cfg as it is generated by Kubuntu
The entries for Vanilla OS have problems:- They should not have chainloader statements; the configfile statements should bring up the Vanilla OS grub menus. If you wanted to chain load vanilla OS it would be the .efi file in the ESP somewhere.
- I'm not sure about the syntax in those search statements; looks quite wrong.
Presumably in the Windows entry "*****" stands for the ID of the ESP where the bootmgfw.efi is.
- Top
- Bottom
Leave a comment:
-
Manually configure GRUB for multi-boot, persistent to kernel updates
Hello everyone!
I have a laptop with Windows 11, vanilla OS 2, and kubuntu 26.04 LTS (in order of installation). I want to make a manual grub configuration, that will offer all three operating systems during boot up and that will be able to boot any future kernel and initrd without needing further modifications. I looked it up and prompted chatGPT, and now I think it is best to ask for some advice before I commit.
I got the idea from John Little in this thread. I considered it best to create a new thread because manual grub configuration could prove future-proof (according to what John mentioned there) and therefore helpful to other members not just myself. Additionally, that specific thread was about partitioning and pre-install, so I felt we were starting to go off-topic.
Following suggestions were produced by the AI tool, with the first one to backup my configuration files:
After that, the tool suggested that I ¨use /etc/grub.d/40_custom¨ on which I could copy+paste the text it provided and then make it executable and then run update-grub.Code:sudo cp /etc/default/grub /etc/default/grub.bak sudo cp -r /etc/grub.d /etc/grub.d.bak sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg.bak Backup ESP (example ESP = /dev/nvme0n1p1): sudo mkdir -p /mnt/esp && sudo mount /dev/nvme0n1p1 /mnt/esp sudo cp -r /mnt/esp /root/esp-backup sudo umount /mnt/esp
I didn´t copy paste blindly,I copied the entries from the kubuntu grub file (regarding kubuntu and windows entries) and then booted to vanilla and copied the vanilla entries too.
The ai tool suggested I should then run:Code:#!/bin/sh exec tail -n +3 $0 menuentry 'Kubuntu 26.04' --class kubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-[UUID of kubuntu root partition]' { recordfail load_video set gfxpayload=$linux_gfx_mode insmod gzio if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_gpt insmod ext2 search --no-floppy --fs-uuid --set=root [UUID of kubuntu root partition] linux /boot/vmlinuz root=UUID=[UUID of kubuntu root partition] ro quiet splash $vt_handoff{ initrd /boot/initrd.img #For the last two lines, I followed this advice: https://help.ubuntu.com/community/Grub2/CustomMenus } #linux /vmlinuz root=UUID=[UUID of kubuntu root partition] ro quiet splash #initrd /initrd.img menuentry "Vanilla OS - Current State (A)" --class abroot-a { search --fs-uuid --no-floppy --set=root(lvm/vos--root-init) configfile "/vos-a/abroot.cfg" chainloader /boot/efi/EFI/vanilla/grub.cfg # I am not sure about this one... Copied from within Vanilla. } menuentry "Vanilla OS - Previous State (B)" --class abroot-b { search --fs-uuid --no-floppy --set=root(lvm/vos--root-init) configfile "/vos-b/abroot.cfg" chainloader /boot/efi/EFI/vanilla/grub.cfg # I am not sure about this one... Copied from within Vanilla. } # COMMENT: the ai tool suggested I chainloaded Vanilla´s EFI bootloader, but I copied the above from vanilla´s boot partition. Not sure if it will work... # AI said: Replace /EFI/OtherDistro/grubx64.efi below with the actual path found under /boot/efi/EFI # I need to understand what the above line does, haven´t figured it out yet! #chainloader /boot/efi/EFI/vanilla/grub.cfg # I am not sure about this one... Copied from within Vanilla. menuentry "Windows 11 - chainload Windows Boot Manager" { search --fs-uuid --no-floppy --set=root ***** chainloader /EFI/Microsoft/Boot/bootmgfw.efi } # COMMENT: no changes for the win menuentry- sudo chmod +x /etc/grub.d/40_custom
- sudo update-grub
I have no idea if any of the above will work well... Do they look okay? Did I miss anything important?
Thank you in advance!
Users Viewing This Topic
Collapse
There are 0 users viewing this topic.
Leave a comment: