Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use grub-mkstandalone instead of grub-mkimage for UEFI #2293

Merged
merged 8 commits into from Jan 23, 2020

Conversation

pcahyna
Copy link
Member

@pcahyna pcahyna commented Dec 8, 2019

Pull Request Details:
  • Type: Bug Fix / Cleanup

  • Impact: Normal

  • Reference to related issue (URL):
    uefi: Search for Grub2 modules in /usr/lib/grub*/x86_64-efi and not in /boot #2199 Currently, ReaR is using hard-coded set of Grub2 modules for UEFI #2283 fedora29 grub2-efi-x64-modules does not contain linuxefi module #2001 ReaR fails on Fedora 29 with UEFI when grub2-efi-modules are missing #1996 (comment)

  • How was this pull request tested?
    the two cases that use the code touched by this PR:

    • creating a rescue ISO on a RHEL 8.1 UEFI system and booting it
    • creating a rescue system using GRUB_RESCUE and booting it using the EFI boot menu
    • repeating both with GRUB2_MODULES=(part_gpt part_msdos fat ext2 normal chain boot configfile linux jfs iso9660 usb usbms usb_keyboard video udf ntfs all_video gzio efi_gop reboot search test echo btrfs lvm)
  • Brief description of the changes in this pull request:
    There have been several cases recently where ReaR on UEFI was broken due to either a wrong assumption about what Grub2 modules to load (fedora29 grub2-efi-x64-modules does not contain linuxefi module #2001) or, in an attempt to fix it, a wrong assumption about where to search for them (see uefi: Search for Grub2 modules in /usr/lib/grub*/x86_64-efi and not in /boot #2199). I believe that such Grub internal details are better handled by Grub itself and we should not hardcode them (making them configurable is only a workaround - the default should work in most scenarios). Therefore this change switches to using grub-mkstandalone for te Grub2 UEFI image generation, which, unlike grub-mkimage, relies less on supplied information about modules. It embeds a ramdisk in the Grub2 image and by defaults includes all modules in it.
    I found that the current method is broken at least on RHEL and GRUB_RESCUE, because the current default set of modules does not include xfs and /boot is XFS by default on RHEL, making it inaccessible from Grub2. This change also fixes this, therefore it is a bugfix in addition to a cleanup.
    I found that the image creation using grub-mkstandalone still needs to be told to load partition modules, otherwise partitions will not be detected out of the box. I therefore added a dynamic detection of all modules needed to access /boot (partitions, filesystems, and others like lvm, should it be needed) using grub-probe, as it is more robust and relies on less assumptions than trying to guess a reasonable set of default modules.
    The change still honors GRUB2_MODULES, but changes it into an array. (Other lists in configuration are specified as arrays already, like MODULES, so having GRUB2_MODULES an a string with blank-separated words is not consistent with the rest of the configuration.) If GRUB2_MODULES is set and nonempty, only the specified modules will be embedded in the standalone image ramdisk and also only those will be loaded. The detection using grub-probe will be switched off.

@gozora
Copy link
Member

gozora commented Dec 9, 2019

Hello @pcahyna,

I just run a simple test and created ReaR rescue system with your code.
On ISO boot, I don't get Grub2 boot menu but first boot entry is booted immediately without any prompt. Can you please fix this behavior ?

Thanks

V.

@gozora gozora self-assigned this Dec 9, 2019
@gozora gozora added this to the ReaR v2.6 milestone Dec 9, 2019
@pcahyna
Copy link
Member Author

pcahyna commented Dec 9, 2019

Hi @gozora ,
thank you for testing, unfortunately I tested this case and it worked fine for me, so I don't know how to reproduce the problem, what is your distribution and Grub2 version?

Copy link
Member

@gozora gozora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grub2 menu is not displayed on boot time.

@gozora
Copy link
Member

gozora commented Dec 9, 2019

Hello @pcahyna,

I've used SLES12SP4 for SAP ...

# cat /etc/os-release
NAME="SLES"
VERSION="12-SP4"
VERSION_ID="12.4"
PRETTY_NAME="SUSE Linux Enterprise Server 12 SP4"
ID="sles"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles_sap:12:sp4"

V.

@gozora
Copy link
Member

gozora commented Dec 9, 2019

Excerpt from debug log:

...
++ cp -v /boot/efi/EFI/sles/grubx64.efi /tmp/rear.IEzPq6u2M2oANaW/tmp/mnt/EFI/BOOT/BOOTX64.efi
'/boot/efi/EFI/sles/grubx64.efi' -> '/tmp/rear.IEzPq6u2M2oANaW/tmp/mnt/EFI/BOOT/BOOTX64.efi'
+++ dirname /boot/efi/EFI/sles/grubx64.efi
++ local uefi_bootloader_dirname=/boot/efi/EFI/sles
++ test -f ''
+++ basename /usr/bin/xorrisofs
++ test ebiso = xorrisofs
+++ type -p grub
++ [[ -n '' ]]
++ create_grub2_cfg
+++ get_root_disk_UUID
++++ grep ' on / '
++++ awk '{print $1}'
++++ xargs blkid -s UUID -o value
++++ mount
+++ echo 7e36992b-b7a6-48a2-89d1-499c93a825ed
++ root_uuid=7e36992b-b7a6-48a2-89d1-499c93a825ed
++ cat
++ test -f ''
++ build_bootx86_efi /tmp/rear.IEzPq6u2M2oANaW/tmp/mnt/EFI/BOOT/BOOTX64.efi /tmp/rear.IEzPq6u2M2oANaW/tmp/mnt/EFI/BOOT/grub.cfg
++ local outfile=/tmp/rear.IEzPq6u2M2oANaW/tmp/mnt/EFI/BOOT/BOOTX64.efi
++ local embedded_config=
++ local gmkstandalone=
++ local gprobe=
++ dirs=()
++ local dirs
++ modules=(${GRUB2_MODULES:+"${GRUB2_MODULES[@]}"})
++ local modules
++ shift
++ [[ -n /tmp/rear.IEzPq6u2M2oANaW/tmp/mnt/EFI/BOOT/grub.cfg ]]
++ embedded_config=/boot/grub/grub.cfg=/tmp/rear.IEzPq6u2M2oANaW/tmp/mnt/EFI/BOOT/grub.cfg
++ shift
++ dirs=(${@:+"$@"})
++ has_binary grub-mkstandalone
++ for bin in '$@'
++ type grub-mkstandalone
/usr/share/rear/lib/_input-output-functions.sh: line 476: type: grub-mkstandalone: not found
++ return 1
++ has_binary grub2-mkstandalone
++ for bin in '$@'
++ type grub2-mkstandalone
++ return 0
++ gmkstandalone=grub2-mkstandalone
++ ((  0  ))
++ test /usr/lib/grub2/x86_64-efi/moddep.lst
++ grub2-mkstandalone -v -O x86_64-efi -o /tmp/rear.IEzPq6u2M2oANaW/tmp/mnt/EFI/BOOT/BOOTX64.efi /boot/grub/grub.cfg=/tmp/rear.IEzPq6u2M2oANaW/tmp/mnt/EFI/BOOT/grub.cfg
grub2-mkstandalone: info: copying `/usr/lib/grub2/x86_64-efi/acpi.mod' -> `/tmp/grub.rKUK6E/boot/grub/x86_64-efi/acpi.mod'.
grub2-mkstandalone: info: copying `/usr/lib/grub2/x86_64-efi/adler32.mod' -> `/tmp/grub.rKUK6E/boot/grub/x86_64-efi/adler32.mod'.
...
# cat /tmp/rear.IEzPq6u2M2oANaW/tmp/mnt/EFI/BOOT/grub.cfg
set default="0"

insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod all_video

set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2

set timeout=5

search --no-floppy --file /boot/efiboot.img --set
#set root=(cd0)

menuentry "Relax-and-Recover (no Secure Boot)"  --class gnu-linux --class gnu --class os {
     echo 'Loading kernel ...'
     linux /isolinux/kernel root=UUID=7e36992b-b7a6-48a2-89d1-499c93a825ed  selinux=0 biosdevname=1 net.ifnames=0
     echo 'Loading initial ramdisk ...'
     initrd /isolinux/initrd.cgz
}

menuentry "Relax-and-Recover (Secure Boot)"  --class gnu-linux --class gnu --class os {
     echo 'Loading kernel ...'
     linuxefi /isolinux/kernel root=UUID=7e36992b-b7a6-48a2-89d1-499c93a825ed  selinux=0 biosdevname=1 net.ifnames=0
     echo 'Loading initial ramdisk ...'
     initrdefi /isolinux/initrd.cgz
}

menuentry "Reboot" {
     reboot
}

menuentry "Exit to EFI Shell" {
     exit
}

@gozora
Copy link
Member

gozora commented Dec 9, 2019

@pcahyna do not spent your time on this for now!
I've reset my server several times an sometimes menu is shown and sometimes not.
This might indicate possible problem with my firmware, and display of menu might be related to bigger size of bootx64.efi.

I'll run couple of deeper tests in upcoming days and let you know if I find something ...

V.

@pcahyna
Copy link
Member Author

pcahyna commented Dec 9, 2019

@gozora , thanks. I suggest that you also try GRUB_RESCUE, which uses the same code.

@gozora
Copy link
Member

gozora commented Dec 9, 2019

@pcahyna I've tested GRUB_RESCUE as you've suggested and got following:

image

I'm pretty sure that kernel and initrd are available but Grub2 somehow can't locate them:

# ls /boot/
System.map-4.12.14-95.24-default  initrd-4.12.14-95.24-default        symvers-4.12.14-95.24-default.gz
boot.readme                       initrd-4.12.14-95.24-default-kdump  sysctl.conf-4.12.14-95.24-default
config-4.12.14-95.24-default      initrd-4.4.176-94.88-default        vmlinux-4.12.14-95.24-default.gz
efi                               rear-initrd.cgz                     vmlinuz
grub2                             rear-kernel                         vmlinuz-4.12.14-95.24-default
initrd                            symtypes-4.12.14-95.24-default.gz

Same ReaR configuration works fine with "old" code ...
It can be related to fact that my /boot/ is located on BTRFS.
Can you maybe extend your tests for /boot on BTRFS ?

Thanks

V.

@gozora
Copy link
Member

gozora commented Dec 9, 2019

@pcahyna I just realized that I'm running my server from BTRFS snapshot ...
Can it be that build_bootx86_efi() (grub-mkstandalone) somehow can't deal with with BTRFS snapshots ?

V.

@gozora
Copy link
Member

gozora commented Dec 9, 2019

@pcahyna just FYI:
My structure looks something like this:

# findmnt /
TARGET SOURCE                              FSTYPE OPTIONS
/      /dev/sda3[/@/.snapshots/1/snapshot] btrfs  rw,relatime,space_cache,subvolid=279,subvol=/@/.snapshots/1/snapshot

# df -h /boot
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        48G  9.2G   39G  20% /

V.

@pcahyna
Copy link
Member Author

pcahyna commented Dec 9, 2019

@gozora has the build code loaded a btrfs and LVM module in Grub2? If not, can you manuallly load them (insmod btrfs, insmod lvm) and try the menu again?

@pcahyna
Copy link
Member Author

pcahyna commented Dec 9, 2019

P.S. you will see what modules get loaded from the grub2-mkstandalone command from the debug log. (I also added a separate log statement which will show them)

@gozora
Copy link
Member

gozora commented Dec 9, 2019

I assume that all modules were loaded, because I was able to read content /boot directory from Grub2 command line without any problems.

V.

@pcahyna
Copy link
Member Author

pcahyna commented Dec 9, 2019

@gozora you are able to read the content, but is the content correct? If yes, I don't see how you are able to read the content but not able to boot a kernel which is part of the very same content.

@gozora
Copy link
Member

gozora commented Dec 9, 2019

I just simply read content of directory in Grub2 cmdline . I dont know what content / directory is the "correct" one for Grub2. grub-mkimage in old code worked well though ...

V.

@pcahyna
Copy link
Member Author

pcahyna commented Dec 9, 2019

I mean if you read the content of the directory, do you see the kernel and initrd that you want to load?

@jsmeix
Copy link
Member

jsmeix commented Dec 9, 2019

From my experience with the SUSE's special btrfs default structure
basically everything that can go wrong will go wrong with it.

From my personal point of view it is just too complicated.
What I mean is it does not behave sufficiently fail-safe in practice.

When all and everything is fully correctly set up for it,
it provides some extradordinary and powerful functionality.

But from my experience things fall apart as soon
as something is not set up fully correctly.

As far as I know (but I am not at all a real expert in this area)
one main reason of confusion is that what looks like /dir in the
normal running system is not /dir in the whole btrfs tree
because in the normal running system '/' is not the root of the btrfs
but a sub-directory of the btrfs tree (actually a btrfs subvolume)
that get mounted as '/' in the normal running system.

With SUSE's special btrfs default structure what is mounted as '/' in the
normal running system is a snapper snapshot sub-directory/subvolume
of the btrfs tree.

And then other sub-directories of the btrfs tree (actually btrfs subvolumes)
get mounted below what is mounted as '/' in the normal running system.

To see what of the btrfs tree is acually mounted one must mount
the root of the btrfs at a separated mountpoint so that one can
inspect the whole btrfs tree starting at its actual root.

For example on my current SLES12-SP4 system with LVM and btrfs
but with BIOS and not with UEFI, it is the same system as in
#2291 (comment)
I have

# lsblk -ipo NAME,KNAME,PKNAME,TRAN,TYPE,FSTYPE,SIZE,MOUNTPOINT
NAME                        KNAME     PKNAME    TRAN TYPE FSTYPE       SIZE MOUNTPOINT
/dev/sda                    /dev/sda            ata  disk               20G 
`-/dev/sda1                 /dev/sda1 /dev/sda       part LVM2_member   20G 
  |-/dev/mapper/system-swap /dev/dm-0 /dev/sda1      lvm  swap         1.4G [SWAP]
  `-/dev/mapper/system-root /dev/dm-1 /dev/sda1      lvm  btrfs       18.6G /
/dev/sr0                    /dev/sr0            ata  rom  iso9660      3.8G 

# findmnt -at btrfs
TARGET                    SOURCE                                             FSTYPE OPTIONS
/                         /dev/mapper/system-root[/@/.snapshots/1/snapshot]  btrfs  rw,relatime,s
|-/usr/local              /dev/mapper/system-root[/@/usr/local]              btrfs  rw,relatime,s
|-/var/opt                /dev/mapper/system-root[/@/var/opt]                btrfs  rw,relatime,s
|-/var/lib/mysql          /dev/mapper/system-root[/@/var/lib/mysql]          btrfs  rw,relatime,s
|-/boot/grub2/i386-pc     /dev/mapper/system-root[/@/boot/grub2/i386-pc]     btrfs  rw,relatime,s
|-/.snapshots             /dev/mapper/system-root[/@/.snapshots]             btrfs  rw,relatime,s
|-/var/crash              /dev/mapper/system-root[/@/var/crash]              btrfs  rw,relatime,s
|-/var/lib/pgsql          /dev/mapper/system-root[/@/var/lib/pgsql]          btrfs  rw,relatime,s
|-/var/spool              /dev/mapper/system-root[/@/var/spool]              btrfs  rw,relatime,s
|-/var/lib/mailman        /dev/mapper/system-root[/@/var/lib/mailman]        btrfs  rw,relatime,s
|-/opt                    /dev/mapper/system-root[/@/opt]                    btrfs  rw,relatime,s
|-/var/cache              /dev/mapper/system-root[/@/var/cache]              btrfs  rw,relatime,s
|-/home                   /dev/mapper/system-root[/@/home]                   btrfs  rw,relatime,s
|-/var/lib/mariadb        /dev/mapper/system-root[/@/var/lib/mariadb]        btrfs  rw,relatime,s
|-/var/tmp                /dev/mapper/system-root[/@/var/tmp]                btrfs  rw,relatime,s
|-/boot/grub2/x86_64-efi  /dev/mapper/system-root[/@/boot/grub2/x86_64-efi]  btrfs  rw,relatime,s
|-/srv                    /dev/mapper/system-root[/@/srv]                    btrfs  rw,relatime,s
|-/var/lib/named          /dev/mapper/system-root[/@/var/lib/named]          btrfs  rw,relatime,s
|-/var/lib/machines       /dev/mapper/system-root[/@/var/lib/machines]       btrfs  rw,relatime,s
|-/var/lib/libvirt/images /dev/mapper/system-root[/@/var/lib/libvirt/images] btrfs  rw,relatime,s
`-/var/log                /dev/mapper/system-root[/@/var/log]                btrfs  rw,relatime,s

# ls -l /boot/grub2
drwxr-xr-x 1 root root    0 Jul 12  2017 backgrounds
-rw-r--r-- 1 root root   15 Nov 21 11:51 device.map
drwxr-xr-x 1 root root   22 Nov 21 11:52 fonts
-rw------- 1 root root 7910 Nov 21 11:52 grub.cfg
-rw-r--r-- 1 root root 1024 Nov 21 11:51 grubenv
drwxr-xr-x 1 root root 6186 Nov 21 11:52 i386-pc
drwxr-xr-x 1 root root  356 Nov 21 11:52 locale
drwxr-xr-x 1 root root    6 Nov 21 11:50 themes
drwxr-xr-x 1 root root    0 Nov 21 11:47 x86_64-efi

# mkdir /tmp/btrfsroot

# mount -t btrfs -o subvolid=0 /dev/mapper/system-root /tmp/btrfsroot

# ls -l /tmp/btrfsroot
drwxr-xr-x 1 root root 72 Nov 21 11:47 @

# ls -l /tmp/btrfsroot/@
drwxr-x--- 1 root root   42 Nov 21 11:54 .snapshots
drwxr-xr-x 1 root root   10 Nov 21 11:47 boot
drwxr-xr-x 1 root root   14 Nov 21 11:47 etc
drwxr-xr-x 1 root root   16 Nov 21 11:51 home
drwxr-xr-x 1 root root    0 Jun 27  2017 opt
drwxr-xr-x 1 root root   12 Nov 21 11:47 srv
drwxrwxrwt 1 root root 1032 Dec  9 11:46 tmp
drwxr-xr-x 1 root root   10 Nov 21 11:47 usr
drwxr-xr-x 1 root root   54 Nov 21 11:47 var

# ls -l /tmp/btrfsroot/@/boot/
drwxr-xr-x 1 root root 34 Nov 21 11:47 grub2

# ls -l /tmp/btrfsroot/@/boot/grub2/
drwxr-xr-x 1 root root 6186 Nov 21 11:52 i386-pc
drwxr-xr-x 1 root root    0 Nov 21 11:47 x86_64-efi

so what looks like /boot/grub2/i386-pc on SLES12 with btrfs
is actually /@/boot/grub2/i386-pc in the whole btrfs tree.

I guess with UEFI the same kind of confusion could happen.

I think what file and directory paths a GRUB2 command "sees"
while it runs inside a normal running SLES with btrfs
is different compared to what file and directory paths
the GRUB2 bootloader "sees" on plain btrfs during booting.

Again:
I am not at all an expert in this area so something of what I wrote above
could be wrong.

But what is true is that file and directory paths look different
from inside a running SLES12 with its mounted btrfs stuff
compared to when looking directly at the plain whole btrfs.

Cf. my fun with it in
#1828
see in particular
#1828 (comment)
which proves things depend on how btrfs stuff is mounted inside SLE12.

@gozora
Copy link
Member

gozora commented Dec 9, 2019

Thanks @jsmeix i coldnt explain it better!
It looks like grub-mkstandalone is doing something differently compared to grub-mkimage ...

V.

@gozora
Copy link
Member

gozora commented Dec 9, 2019

When I'm using "old" code ReaR executes code as follows:

grub2-mkimage -v -O x86_64-efi --config /boot/grub2/rear_embed.cfg -o /boot/efi/EFI/BOOT/rear.efi -p /EFI/BOOT part_gpt part_msdos fat ext2 normal chain boot configfile linux linuxefi multiboot jfs iso9660 usb usbms usb_keyboard video udf ntfs all_video gzio efi_gop reboot search test echo btrfs lvm

However with "new" code, I have only following modules:

2019-12-09 12:30:04.779046992 GRUB2 modules to load: btrfs fat part_gpt

Any idea why only 3 modules are auto-detected? (a site note; on this server I don't have BTRFS located on LVM, so missing modules should not be a showstopper for booting)

Excerpt from debug log:

++ for bin in '$@'
++ type grub2-probe
++ return 0
++ gprobe=grub2-probe
++ '[' -n grub2-probe ']'
++ modules=($( for p in "${dirs[@]}" ; do
                             $gprobe --target=fs "$p"
                             $gprobe --target=partmap "$p" | sed -e 's/^/part_/'
                             $gprobe --target=abstraction "$p"
                         done | sort -u ))
+++ sort -u
+++ for p in '"${dirs[@]}"'
+++ grub2-probe --target=fs /boot
+++ sed -e 's/^/part_/'
+++ grub2-probe --target=partmap /boot
+++ grub2-probe --target=abstraction /boot
+++ for p in '"${dirs[@]}"'
+++ grub2-probe --target=fs /boot/efi
+++ sed -e 's/^/part_/'
+++ grub2-probe --target=partmap /boot/efi
+++ grub2-probe --target=abstraction /boot/efi
++ Log 'GRUB2 modules to load: btrfs fat part_gpt'
++ echo '2019-12-09 12:30:04.779046992 GRUB2 modules to load: btrfs fat part_gpt'
2019-12-09 12:30:04.779046992 GRUB2 modules to load: btrfs fat part_gpt

If I add modules manually by:

GRUB2_MODULES="part_gpt part_msdos fat ext2 normal chain boot configfile linux linuxefi multiboot jfs iso9660 usb usbms usb_keyboard video udf ntfs all_video gzio efi_gop reboot search test echo btrfs lvm"

It still doesn't work though ... (when I type ls I get message ls module is missing ...`

V.

@gozora
Copy link
Member

gozora commented Dec 9, 2019

I can see that bootx64.efi and rear.efi are created differently:

++ build_bootx86_efi /boot/efi/EFI/BOOT/rear.efi /boot/grub2/rear.cfg /boot /boot/efi
++ build_bootx86_efi /tmp/rear.g3pKTRZrSI3pKGk/tmp/mnt/EFI/BOOT/BOOTX64.efi /tmp/rear.g3pKTRZrSI3pKGk/tmp/mnt/EFI/BOOT/grub.cfg

What is the purpose of $3 and $4 when creating rear.efi ?

V.

@pcahyna
Copy link
Member Author

pcahyna commented Dec 9, 2019

++ build_bootx86_efi /boot/efi/EFI/BOOT/rear.efi /boot/grub2/rear.cfg /boot /boot/efi

What is the purpose of $3 and $4 when creating rear.efi ?

The purpose is to pass directories/files that must be accessible from Grub. My code makes sure that Grub modules needed to access those are loaded. Without this feature, you would risk not having part_gpt and / or btrfs modules loaded and you would not even see your /boot. (The log snipped you have shown proves that this part is working correctly.)

Not strictly required, but useful and good for consistency with the GRUB2_RESCUE
Grub image.
Since $UEFI_BOOTLOADER contains the path to the bootloader and grub-probe can
work with file paths as well as with directories, take advantage of it and use
$UEFI_BOOTLOADER to determine the modules needed to access the ESP (EFI system
partition).
@gozora
Copy link
Member

gozora commented Dec 15, 2019

Unfortunately I've found another problem while running some tests on SLE15.
When I tried to boot rear.efi I got stuck in boot process with following message:
Screenshot from 2019-12-15 20-03-37
I had to add all_video to GRUB2_MODULES_LOAD to fix this problem.
I'm not really sure how this could efficiently solved, looks like hard coding of at least some modules will be required after all ...

V.

@pcahyna
Copy link
Member Author

pcahyna commented Dec 15, 2019

Unfortunately I've found another problem while running some tests on SLE15.
When I tried to boot rear.efi I got stuck in boot process with following message:
Screenshot from 2019-12-15 20-03-37
I had to add all_video to GRUB2_MODULES_LOAD to fix this problem.
I'm not really sure how this could efficiently solved, looks like hard coding of at least some modules will be required after all ...

V.

@gozora thanks for the test. The all_video module should not be built into the image, grub-install does not do it either. Rather, there should be a command to load it it the grub config file (look at your distribution grub.cfg). create_grub2_cfg in lib/bootloader-functions.sh does this already:

, so you should not have the problem with the ISO, but 940_grub2_rescue.sh does not use it (the function is not ready to be used this way).
The problem is, we have unified Grub2 image creation between the ISO and GRUB2_RESCUE, but we have not unified the config file creation.

Copy graphics-related commands from create_grub2_cfg (in
bootloader-functions.sh) to the GRUB2_RESCUE Grub2 config file.

XXX the Grub2 config file generation for GRUB2_RESCUE should be unified with
config file generation for ISO (create_grub2_cfg).
@pcahyna
Copy link
Member Author

pcahyna commented Dec 15, 2019

@gozora hope your issue is fixed now. I just copied the graphics-related code from create_grub2_cfg, because sharing the code would mean a bigger refactoring.

@gozora
Copy link
Member

gozora commented Dec 19, 2019

Hello @pcahyna,

Thanks for your update, I'll test it again soon ...

V.

@gozora
Copy link
Member

gozora commented Jan 20, 2020

After running several other tests this PR looks good to me.
If there aren't any further objections I'll merge it soon.

V.

@pcahyna
Copy link
Member Author

pcahyna commented Jan 20, 2020

@gozora thanks for testing! Does it fix your btrfs-on-lvm case without the need of setting GRUB2_MODULES(_LOAD) manually?

@gozora
Copy link
Member

gozora commented Jan 20, 2020

Hello @pcahyna, yes btrfs-on-lvm problem is now solved without any explicit Grub module configuration inside ReaR.

V.

Copy link
Member

@jsmeix jsmeix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcahyna
thank you for making things simpler and more straightforward!

@gozora
thank you for all your testing and your reviews!
I trust you basicaly blindly so I "just blindly approve" it.

@jsmeix
Copy link
Member

jsmeix commented Jan 21, 2020

@rmetrich
currently you request changes here.
Is your request still valid or is it meanwhile outdated or solved?

@rmetrich rmetrich self-requested a review January 21, 2020 10:21
@gozora gozora merged commit c9e61ba into rear:master Jan 23, 2020
@gozora
Copy link
Member

gozora commented Jan 23, 2020

@pcahyna thanks for your work on this PR, it is appreciated!

V.

@pcahyna
Copy link
Member Author

pcahyna commented Jan 30, 2020

By the way, are those variables going to be used in another file? If not, shouldn't they be lowercase and local?

Most of that code is borrowed from 670_run_efibootmgr.sh and not written by me ...
But I agree that everything can be written simpler and more elegant ...

#2324

jsmeix added a commit that referenced this pull request May 11, 2020
…EFI-specific

Make GRUB2_MODULES variables having UEFI specific names:
Renamed GRUB2_MODULES and GRUB2_MODULES_LOAD
for installing GRUB2 as recovery system UEFI bootloader into
GRUB2_MODULES_UEFI and GRUB2_MODULES_UEFI_LOAD
see #2392
Those config variables have not been in a released ReaR version, cf.
#2293 (comment)
pcahyna added a commit to pcahyna/rear that referenced this pull request Jun 23, 2020
Sometimes the search command in GRUB2 used in UEFI ISO does not find
the root device. This was seen at least in Debian Buster running in Qemu
(VirtualBox works fine, RHEL/CentOS in Qemu works fine as well).

To make ReaR work in this case, set $root to a sensible value before
trying `search`. The GRUB2 image created by grub-mkstandalone has $root
set to memdisk, which can't work.

This essentially matches how it used to work before PR rear#2293.

Fixes rear#2434.
pcahyna added a commit to pcahyna/rear that referenced this pull request Jul 3, 2020
Sometimes the search command in GRUB2 used in UEFI ISO does not find
the root device. This was seen at least in Debian Buster running in Qemu
(VirtualBox works fine, RHEL/CentOS in Qemu works fine as well).

To make ReaR work in this case, set $root to a sensible value before
trying `search`. The GRUB2 image created by grub-mkstandalone has $root
set to memdisk, which can't work.

This essentially matches how it used to work before PR rear#2293.

Fixes rear#2434.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants