#3349 PR merged: After doing lots of experiments with RAMdisks it is good to have some…

Labels: enhancement, fixed / solved / done, Dedicated Priority Support

gdha opened issue at 2024-11-27 10:32:

Pull Request Details:
  • Type: Enhancement

  • Impact: Low

  • Reference to related issue (URL): n/a

  • How was this pull request tested? many times for a customer project

  • Description of the changes in this pull request: adding 2 extra software pieces to the default PROGS array to assist in grub2 steps

jsmeix commented at 2024-11-27 12:54:

I would like to clarify here via comment
WHY it is "the right thing" that
systemd-detect-virt grub2-editenv grubby
are added to the PROGS array
and not to the REQUIRED_PROGS array
regardless that the comments in the code

# In some cases to detect an USB device properly we need:
systemd-detect-virt
# In case we want to recreate initial ramdisks it is good to have:
grub2-editenv
grubby

indicate that REQUIRED_PROGS might be even better?

I think the PROGS array is exactly right here because
we can sufficiently safely assume that on systems where
systemd-detect-virt is needed to detect an USB device properly
systemd-detect-virt is installed
and same argument for grub2-editenv and grubby:
On systems where grub2-editenv and/or grubby are needed
to recreate the initial ramdisk, we can sufficiently safely
assume that there grub2-editenv and/or grubby are installed.

So using the PROGS array is exactly right because
this way things behave backward compatible on systems
where systemd-detect-virt grub2-editenv grubby do not exist,
e.g. on my openSUSE Leap 15.5 system where grubby is not installed:

# for p in systemd-detect-virt grub2-editenv grubby ; do type -a $p ; done
systemd-detect-virt is /usr/bin/systemd-detect-virt
grub2-editenv is /usr/bin/grub2-editenv
-bash: type: grubby: not found

# rpm -qf /usr/bin/systemd-detect-virt
systemd-249.17-150400.8.43.1.x86_64

# rpm -qf /usr/bin/grub2-editenv
grub2-2.06-150500.29.34.2.x86_64

# zypper search grubby
S  | Name   | Summary                                           | Type
---+--------+---------------------------------------------------+--------
   | grubby | Command line tool for updating bootloader configs | package

pcahyna commented at 2024-12-02 18:02:

It is right to use PROGS and not REQUIRED_PROGS - GRUB2 is not the only bootloader and we still support non-systemd distros to some extent. grubby is not even a standard tool packaged with GRUB2, it is a separate tool, not always available.

However, adding GRUB tools here does not seem right, all other GRUB tools get added in usr/share/rear/prep/GNU/Linux/300_include_grub_tools.sh. Would you agree to moving the grub2-editenv line and perhaps the grubby line there?

By the way, @gdha , can you please share details of your experiments and how/where have you recreated initial ramdisks? I am curious why you have needed to include anything more for this, because ramdisk recreation should run in the recreated system (under chroot $TARGET_FS_ROOT), and I checked the sources that this is indeed happening, and all the tools are available there, even if they are not in in the ReaR rescue ramdisk. Even Grubby should be IMO used only in the chroot and not in the ReaR rescue ramdisk.


[Export of Github issue for rear/rear.]