1

Topic: How to correctly change grub.cfg?

Hi all . Please tell me how to change grub.cfg correctly and correctly, below I attach grub.cfg Libreboot. it is the same as Gnuboot.

For example, I want to post these lines (written below), will they work, that is, what I enter and it works.


Can I place them at the end of the file for this to work or does something else need to be added?

set prefix=(memdisk)/boot/grub

insmod at_keyboard
insmod usb_keyboard
insmod nativedisk
insmod ehci
insmod ohci
insmod uhci
insmod usb
insmod usbms
insmod regexp

terminal_input --append at_keyboard
terminal_input --append usb_keyboard
terminal_output --append cbmemc

gfxpayload=keep
terminal_output --append gfxterm

if [ -f (cbfsdisk)/background.png ]; then
    insmod png
    background_image (cbfsdisk)/background.png
elif [ -f (cbfsdisk)/background.jpg ]; then
    insmod jpeg
    background_image (cbfsdisk)/background.jpg
fi

set default="0"
if [ -f (cbfsdisk)/timeout.cfg ]; then
    source (cbfsdisk)/timeout.cfg
else    
    set timeout=5
fi
set grub_scan_disk="both"
if [ -f (cbfsdisk)/scan.cfg ]; then
    source (cbfsdisk)/scan.cfg
fi

if [ -f (cbfsdisk)/keymap.gkb ]; then
    keymap (cbfsdisk)/keymap.gkb
fi

function try_user_config {
    set root="${1}"

    # The @/... entries are for cases where the BTRFS filesystem is being used
    for dir in boot grub grub2 boot/grub boot/grub2 @/boot @/grub @/grub2 @/boot/grub @/boot/grub2; do
        for name in '' osboot_ autoboot_ libreboot_ coreboot_; do
            if [ -f /"${dir}"/"${name}"grub.cfg ]; then
                unset superusers
                configfile /"${dir}"/"${name}"grub.cfg
            fi
        done
    done
}
function search_grub {
    echo -n "Attempting to load grub.cfg from '${1}' devices"
    for i in 0 1 2 3 4 5 6 7 8 9 10 11; do
        for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
            try_user_config "(${1}${i},${part})"
        done
        # raw devices e.g. (ahci0) instead of (ahci0,1)
        try_user_config "(${1}${i})"
    done
    echo # Insert newline
}

function try_isolinux_config {
    set root="${1}"
    for dir in '' /boot /EFI /boot/EFI /@ /@/boot /@/boot/EFI /@/EFI; do
        if [ -f "${dir}"/isolinux/isolinux.cfg ]; then
            syslinux_configfile -i "${dir}"/isolinux/isolinux.cfg
        elif [ -f "${dir}"/syslinux/syslinux.cfg ]; then
            syslinux_configfile -s "${dir}"/syslinux/syslinux.cfg
        elif [ -f "${dir}"/syslinux/extlinux.conf ]; then
            syslinux_configfile -s "${dir}"/syslinux/extlinux.conf
        elif [ -f "${dir}"/extlinux/extlinux.conf ]; then
            syslinux_configfile -s "${dir}"/extlinux/extlinux.conf
        fi
    done
}
function search_isolinux {
    echo "\nAttempting to parse iso/sys/extlinux config from '${1}' devices"
    for i in 0 1 2 3 4 5 6 7 8 9 10 11; do
        for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
            try_isolinux_config "(${1}${i},${part})"
        done
        # raw devices e.g. (usb0) instead of (usb0,1)
        try_isolinux_config "(${1}${i})"
    done
    echo # Insert newline
}
function try_bootcfg {
    try_user_config "${1}"
    try_isolinux_config "${1}"
}
function search_bootcfg {
    search_grub "${1}"
    search_isolinux "${1}"
}
menuentry 'Load Operating System (incl. fully encrypted disks)  [o]' --hotkey='o' {

    if [ "${grub_scan_disk}" != "ata" ]; then
        search_bootcfg ahci
    fi
    if [ "${grub_scan_disk}" != "ahci" ]; then
        search_bootcfg ata
    fi

    # grub device enumeration is very slow, so checks are hardcoded

    # TODO: add more strings, based on what distros set up when
    # the user select auto-partitioning on those installers
    lvmvol="lvm/grubcrypt-bootvol lvm/grubcrypt-rootvol"

    raidvol="md/0 md/1 md/2 md/3 md/4 md/5 md/6 md/7 md/8 md/9"

    # in practise, doing multiple redundant checks is perfectly fast and
    # TODO: optimize grub itself, and use */? here for everything

    for vol in ${lvmvol} ${raidvol} ; do
        try_bootcfg "${vol}"
    done

    unset ahcidev
    unset atadev
    for i in 11 10 9 8 7 6 5 4 3 2 1 0; do
        for part in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1; do
            if [ "${grub_scan_disk}" != "ata" ]; then
                ahcidev="(ahci${i},${part}) ${ahcidev}"
            fi
            if [ "${grub_scan_disk}" != "ahci" ]; then
                atadev="(ata${i},${part}) ${atadev}"
            fi
        done
    done

    set pager=0
    echo -n "Attempting to unlock encrypted volumes"
    for dev in ${ahcidev} ${atadev} ${lvmvol} ${raidvol}; do
        if cryptomount "${dev}" ; then break ; fi
    done
    set pager=1
    echo

    # after cryptomount, lvm volumes might be available
    for vol in ${lvmvol}; do
        try_bootcfg "${vol}"
    done

    search_bootcfg crypto

    for vol in lvm/* ; do
        try_bootcfg "${vol}"
    done

    true # Prevent pager requiring to accept each line instead of whole screen
}

menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on USB  [s]' --hotkey='s' {
    search_bootcfg usb
}
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on AHCI  [a]' --hotkey='a' {
    search_bootcfg ahci
}
menuentry 'Search for GRUB/SYSLINUX/EXTLINUX/ISOLINUX on ATA/IDE  [d]' --hotkey='d' {
    search_bootcfg ahci
}
if [ -f (cbfsdisk)/grubtest.cfg ]; then
menuentry 'Load test configuration (grubtest.cfg) inside of CBFS  [t]' --hotkey='t' {
    set root='(cbfsdisk)'
    if [ -f /grubtest.cfg ]; then
        configfile /grubtest.cfg
    fi
}
fi
if [ -f (cbfsdisk)/seabios.elf ]; then
menuentry 'Load SeaBIOS (payload) [b]' --hotkey='b' {
    set root='cbfsdisk'
    chainloader /seabios.elf
}
fi
if [ -f (cbfsdisk)/img/grub2 ]; then
menuentry 'Return to SeaBIOS [b]' --hotkey='b' {
    set root='cbfsdisk'
    chainloader /fallback/payload
}
fi
menuentry 'Poweroff  [p]' --hotkey='p' {
    halt
}
menuentry 'Reboot  [r]' --hotkey='r' {
    reboot
}
if [ -f (cbfsdisk)/img/memtest ]; then
menuentry 'Load MemTest86+  [m]' --hotkey='m' {
    set root='cbfsdisk'
    chainloader /img/memtest
}
fi

Add these lines

{
cryptomount -a
set root='lvm/matrix-rootvol'
linux /boot/vmlinuz-linux-libre root=/dev/matrix/rootvol cryptdevice=/dev/sda1:lvm
initrd /boot/initramfs-linux-libre.img
}

2

Re: How to correctly change grub.cfg?

Unfortunately none of these wiki links work...

https://wiki.hyperbola.info/doku.php?id … te_grubcfg

https://wiki.hyperbola.info/doku.php?id … el_modules

https://wiki.hyperbola.info/doku.php?id … _from_grub

3 (edited by jim 2024-02-04 13:54:29)

Re: How to correctly change grub.cfg?

Found it here on the forum, I'll try to use it...

I will change the UUID and other identifiers..

menuentry 'Load hyperbola' {
        insmod ahci
        insmod part_msdos
        insmod part_gpt
        cryptomount -u 071b188644b14c528d1853efdf96d74c
        set root="lvm/matrix-root"
        echo  'Loading vmlinuz-linux-libre-lts ...'
        linux /boot/vmlinuz-linux-libre-lts \
        cryptdevice=UUID=071b1886-44b1-4c52-8d18-53efdf96d74c:root \
        cryptkey=rootfs:/etc/keys/ssd.key \
        root=UUID=bcea465c-b5ba-4df0-936d-04679c422904 \
        resume=UUID=9c3a41a5-672a-46bb-ac88-c70a5f1aba75 \
        keymap=de net.ifnames=0 biosdevname=0 acpi_osi=Linux

        echo  'Loading initramfs-linux-libre-lts.img ...'
        initrd /boot/initramfs-linux-libre-lts.img
        boot
}

4

Re: How to correctly change grub.cfg?

jim wrote:

Found it here on the forum, I'll try to use it...

I will change the UUID and other identifiers..

menuentry 'Load hyperbola' {
        insmod ahci
        insmod part_msdos
        insmod part_gpt
        cryptomount -u 071b188644b14c528d1853efdf96d74c
        set root="lvm/matrix-root"
        echo  'Loading vmlinuz-linux-libre-lts ...'
        linux /boot/vmlinuz-linux-libre-lts \
        cryptdevice=UUID=071b1886-44b1-4c52-8d18-53efdf96d74c:root \
        cryptkey=rootfs:/etc/keys/ssd.key \
        root=UUID=bcea465c-b5ba-4df0-936d-04679c422904 \
        resume=UUID=9c3a41a5-672a-46bb-ac88-c70a5f1aba75 \
        keymap=de net.ifnames=0 biosdevname=0 acpi_osi=Linux

        echo  'Loading initramfs-linux-libre-lts.img ...'
        initrd /boot/initramfs-linux-libre-lts.img
        boot
}

Tell me if you succeed. Hope you do!

HyperbolaBSD: The Future of Secure Libre Lightweight Operating Systems!

5

Re: How to correctly change grub.cfg?

Hello Zapper .

I have become a little closer to the goal, since no one at the moment can answer why I am getting this error, I am studying the issue further))

error : disk 'lvmid /WuGDE4-Po2w-3n6d-9pcY-sqsoV-eTsq-aLxagJ'

I have read various forums, usually it is related to Grub which is installed on the system.
But the BIG advantage is that we do not need to install Grub Hyperbola since it is in the ROM. As soon as I receive answers I will write instructions for Luks2+argon2id.

6 (edited by zapper 2024-02-06 02:56:34)

Re: How to correctly change grub.cfg?

jim wrote:

Hello Zapper .

I have become a little closer to the goal, since no one at the moment can answer why I am getting this error, I am studying the issue further))

error : disk 'lvmid /WuGDE4-Po2w-3n6d-9pcY-sqsoV-eTsq-aLxagJ'

I have read various forums, usually it is related to Grub which is installed on the system.
But the BIG advantage is that we do not need to install Grub Hyperbola since it is in the ROM. As soon as I receive answers I will write instructions for Luks2+argon2id.


I will be interested to see how you do this.

I don't know the method HyperbolaBSD will use for FDE + /boot or FDE - /boot

But its good to have you figure this out till 2024 Q4 which is when I believe the next variant OS of Hyperbola comes out as Stable according to FAQ.

HyperbolaBSD: The Future of Secure Libre Lightweight Operating Systems!

7 (edited by jim 2024-02-06 08:04:20)

Re: How to correctly change grub.cfg?

Welcome to GRUB!

error: disk `lvmid/p3y5O2-jync-R2Ao-Gtlj-It3j-FZXE-ipEDYG/bApewq-qSRB-zYqT-mzvP-pGiV-VQaf-di4Rcz` not found.
grub rescue> 

This error "disk `...` not found" error is originally caused by a grub bug. LVM metadata is stored on-disk in a ring buffer, so occasionally the current metadata will wrap around the end of the ring buffer. However, if there is a wraparound in the ring buffer, grub fails to parse the metadata and fails to boot with the above error.

Information that I have found so far on this problem
https://bugs.debian.org/cgi-bin/bugrepo … bug=987008