Incompatibility with modern GRUB2 which lacks grub2-mkdevicemap

Bug #2027676 reported by Ivan
18
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Grub Customizer
New
Undecided
Unassigned

Bug Description

Good day!

I am running CentOS 8 installed in a traditional BIOS mode (CSM) with grub2 2.02 (2.02-106, the latest packaged GRUB2 for this sytem).

I am trying to use grub-customizer 5.2.3 which I had to build & install from this launchpad's source code because a grub-customizer (like many other packages) is sadly not available at CentOS 8 repository and 5.0.8 taken from CentOS 7 crashes at launch.

So, when I try to launch "sudo grub-customizer" (after "xhost +SI:localuser:root" of course - to avoid the "cannot open display: :0" graphical error for a superuser), then a "Grub Customizer environment setup" window pops up with a correctly-detected "Type: Grub 2" type of my bootloader but incorrectly-autodetected paths:

( /!\ = yellow trianle "FAIL" icon, (-) = red circle "FAIL" icon, <-| - blue arrow "OK" icon )

CFG_DIR: /etc/grub.d =====> <-|
DEVICEMAP_FILE: /boot/grub/device.map =====> /!\
INSTALL_CMD: grub-install =====> (-)
MKCONFIG_CMD: grub-mkconfig =====> (-)
MKDEVICEMAP_CMD: grub-mkdevicemap --device-map=/dev/stdout =====> /!\
MKFONT_CMD: grub-mkfont =====> /!\
OUTPUT_DIR: /boot/grub =====> /!\
OUTPUT_FILE: /boot/grub/grub.cfg =====> /!\
SETTINGS_FILE: /etc/default/grub =====> <-|

After changing a lot of "grub" to "grub2" paths I've been able to partially resolve this:

CFG_DIR: /etc/grub.d =====> <-|
DEVICEMAP_FILE: /boot/grub2/device.map =====> <-|
INSTALL_CMD: grub2-install =====> <-|
MKCONFIG_CMD: grub2-mkconfig =====> <-|
MKDEVICEMAP_CMD: grub2-mkdevicemap --device-map=/dev/stdout =====> /!\
MKFONT_CMD: grub2-mkfont =====> <-|
OUTPUT_DIR: /boot/grub2 =====> <-|
OUTPUT_FILE: /boot/grub2/grub.cfg =====> <-|
SETTINGS_FILE: /etc/default/grub =====> <-|

However, there's one issue that's still unresolved:

MKDEVICEMAP_CMD: grub2-mkdevicemap --device-map=/dev/stdout =====> /!\

Unfortunately I found that a "mkdevicemap" utility simply doesn't exist in a modern GRUB2 - it has been removed with 8be63f2ef6fec43245bea2aa737cc5b1e2f84779 commit at the official repository:

commit 8be63f2ef6fec43245bea2aa737cc5b1e2f84779
Author: Vladimir 'phcoder' Serbinenko <email address hidden>
Date: Fri Feb 3 22:36:51 2012 +0100

        * Makefile.util.def (grub-mkdevicemap): Removed.
        * include/grub/emu/hostdisk.h (grub_util_get_os_disk): New proto.
        * include/grub/util/deviceiter.h: Removed.
        * util/deviceiter.c: Likewise.
        * util/getroot.c (grub_util_get_os_disk): New function.
        * util/grub-install.in: Remove grub-mkdevicemap. Use -t disk as
        replacement for EFI.
        * util/grub-mkdevicemap.c: Removed.
        * util/grub-probe.c (probe): Handle PRINT_DISK.
        (argp_parser): Handle -t disk

If we'd look at this commit, instead of ' $grub_mkdevicemap" --device-map=/dev/stdout ' - now the lines like

' "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}" '
' "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}/efi" '
' "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}/EFI" '

are being used, so probably I can get away with setting a

MKDEVICEMAP_CMD: grub2-probe --target=device --device-map=/dev/stdin /boot/grub2

- however, I'm unsure if the rest of the API / command line arguments ( grub-mkdevicemap.c VS grub-probe.c ) are the same and afraid to screw up my system.

I don't see this issue reported anywhere: probably because a lot of Linux distros still ship the outdated versions of GRUB - which still have this deprecated grub-mkdevicemap utility - the people get away with it. However, if unfixed, this issue above will bite all the Linux users in the long run, so it's really urgent priority to fix this

Revision history for this message
Ivan (qmastery16) wrote :

It still surprises me how this incompatibility hasn't been noticed, despite that a commit that removed grub-mkdevicemap utility is 11 years old... Please find a way to use grub2-probe instead

Revision history for this message
Daniel Richter (danielrichter2007) wrote :

This is because grub 2 at ubuntu still contains grub-mkdevicemap (for example grub 2.06 at ubuntu 23.04). Didn't know it was removed from the official grub 2 repo.

Revision history for this message
Ivan (qmastery16) wrote :

Daniel, thank you for reply! I'm really happy to tell you that after

" grub2-probe --target=device --device-map=/dev/stdin /boot/grub2 "
replacement of MKDEVICEMAP_CMD 's default
" grub-mkdevicemap --device-map=/dev/stdout "

- the grub-customizer 5.2.3 runs successfully on my CentOS 8, and populates the GRUB boot menu both with CentOS 8 entries and also the entries from another HDD ;-) Although, before this success I also had to overcome a few filepath errors during grub-customizer operation by making these symbolic links:

cd /usr/bin/ && sudo ln -s ./grub2-mkfont ./grub-mkfont
cd /usr/sbin/ && sudo ln -s ./grub2-mkconfig ./grub-mkconfig
cd /usr/sbin/ && sudo ln -s ./grub2-install ./grub-install
cd /boot/ && sudo ln -s ./grub2/ ./grub

That's despite I've been using all grub2 variables as above at "Grub Customizer environment setup". So it seems that grub-customizer has a few hardcoded values in its' source code, which should be replaced with using these variables to avoid such problems.

Daniel, thank you so much for the excellent software which helps to save a lot of time for GRUB configuration. Please help it walk one last inch to become compatible with modern systems other than Ubuntu (don't know why they preserve grub-mkdevicemap at Ubuntu's grub2, this only cover-ups a problem)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.