Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 765208 - sys-kernel/dracut: Can't find a uefi stub '/lib/systemd/boot/efi/linuxx64.efi.stub' to create a UEFI executable
Summary: sys-kernel/dracut: Can't find a uefi stub '/lib/systemd/boot/efi/linuxx64.efi...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Patrick McLean
URL:
Whiteboard:
Keywords: PATCH, PullRequest
Depends on:
Blocks:
 
Reported: 2021-01-13 12:41 UTC by Michał Górny
Modified: 2023-10-23 01:30 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix detection of UEFI stub on split-usr systems (0001-Fix-detection-of-UEFI-stub-on-split-usr-systems.patch,1.49 KB, patch)
2021-01-19 20:25 UTC, Mike Gilbert
Details | Diff
Fix UEFI stub path (0001-Fix-path-to-UEFI-stub-on-split-usr-systems.patch,2.20 KB, patch)
2023-05-26 18:23 UTC, Mike Gilbert
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-01-13 12:41:21 UTC
If I add to my dracut.conf:

  uefi=yes

then dracut fails with:

  dracut: Can't find a uefi stub '/usr/lib/gummiboot/linuxx64.efi.stub' to create a UEFI executable

However, according to the manpage it should just work™:

       --uefi-stub <FILE>
           Specifies the UEFI stub loader, which will load the attached kernel, initramfs and kernel command line and boots the kernel. The
           default is $prefix/lib/systemd/boot/efi/linux<EFI-MACHINE-TYPE-NAME>.efi.stub or
           $prefix/lib/gummiboot/linux<EFI-MACHINE-TYPE-NAME>.efi.stub

and /usr/lib/systemd/boot/efi/linuxx64.efi.stub does exist.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-01-13 12:42:59 UTC
The relevant code in /usr/bin/dracut seems to be :

        if ! [[ -s $uefi_stub ]]; then
            for uefi_stub in \
                $dracutsysrootdir"${systemdutildir}/boot/efi/linux${EFI_MACHINE_TYPE_NAME}.efi.stub" \
                    "$dracutsysrootdir/usr/lib/gummiboot/linux${EFI_MACHINE_TYPE_NAME}.efi.stub"; do
                [[ -s $uefi_stub ]] || continue
                break
            done
        fi


where systemdutildir is:

$ pkg-config systemd --variable=systemdutildir
/lib/systemd
Comment 2 Witaut Bajaryn 2021-01-19 17:06:28 UTC
I am experiencing this as well, but on an openrc system.

# dracut --uefi
cat: /usr/lib/os-release: No such file or directory
dracut: Executing: /usr/bin/dracut --uefi
dracut: Can't find a uefi stub '/usr/lib/gummiboot/linuxx64.efi.stub' to create a UEFI executable

# dracut --uefi --uefi-stub /usr/lib/systemd/boot/efi/linuxx64.efi.stub
<...>
dracut: *** Creating image file '/boot/EFI/Linux/linux-5.4.51-gentoo-x86_64-2bd880c4efdaa26032a95a625bcfa929.efi' ***
dracut: Using UEFI kernel cmdline:
^C


On my system, there is no systemd pkg-config file:

# pkg-config systemd --variable=systemdutildir
Package systemd was not found in the pkg-config search path.
Perhaps you should add the directory containing `systemd.pc'
to the PKG_CONFIG_PATH environment variable
No package 'systemd' found

Also, while investigating a related issue in ZFSBootMenu [1], a developer mentioned that dracut would try to look at [/usr]/lib/systemd/systemd-udevd to try to determine $systemdutildir. It turns out that I don't have that either:

# ls /lib/systemd/systemd-udevd
ls: cannot access '/lib/systemd/systemd-udevd': No such file or directory
# ls /usr/lib/systemd/systemd-udevd
ls: cannot access '/usr/lib/systemd/systemd-udevd': No such file or directory


[1] https://github.com/zbm-dev/zfsbootmenu/issues/135#issuecomment-761728463
Comment 3 Mike Gilbert gentoo-dev 2021-01-19 20:25:11 UTC
Created attachment 683770 [details, diff]
Fix detection of UEFI stub on split-usr systems

Here's a patch; please test it.
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-01-19 21:47:14 UTC
(In reply to Mike Gilbert from comment #3)
> Created attachment 683770 [details, diff] [details, diff]
> Fix detection of UEFI stub on split-usr systems
> 
> Here's a patch; please test it.

I can confirm that it works as expected.
Comment 5 Witaut Bajaryn 2021-01-19 21:57:36 UTC
The patch works for me as well (dracut-050-r2, /etc/portage/patches), thanks!
Comment 6 Mike Gilbert gentoo-dev 2023-05-26 18:23:56 UTC
Created attachment 862671 [details, diff]
Fix UEFI stub path

Here's a new patch; please test. I will send this upstream if it works properly on a split-usr system.
Comment 7 Sebastian Hamann 2023-05-26 19:08:35 UTC
The new patch does not apply to 057 nor 059, since set_global_var has only been added in 6f4a5c90ab993d2559720c2d4023d99ad43df00a, which has not been released, yet.

That being said, the patch works nicely for dracut-9999.

My testing environment:
- booted official minimal install cd
- chrooted into stage3-amd64-nomultilib-openrc
- installed systemd-utils and gentoo-kernel
- installed patched dracut
- ran emerge --config gentoo-kernel

I'll probably vary the test environment (using systemd) and test again in the near future.
Comment 8 Mike Gilbert gentoo-dev 2023-05-26 19:43:36 UTC
(In reply to Sebastian Hamann from comment #7)

Thanks! I'll send this upstream and work on a similar change for the released versions.
Comment 9 Larry the Git Cow gentoo-dev 2023-05-26 20:03:00 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e8f8be11a5cb38c954d54615d0a31c0378bf88f5

commit e8f8be11a5cb38c954d54615d0a31c0378bf88f5
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2023-05-26 20:02:07 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2023-05-26 20:02:07 +0000

    sys-kernel/dracut: fix uefi stub path for split-usr
    
    Closes: https://bugs.gentoo.org/765208
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 .../{dracut-059.ebuild => dracut-059-r1.ebuild}    |  1 +
 sys-kernel/dracut/files/059-uefi-split-usr.patch   | 46 ++++++++++++++++++++++
 2 files changed, 47 insertions(+)
Comment 10 Larry the Git Cow gentoo-dev 2023-05-26 20:27:43 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bf4a09fa9787fab26223f3b5bb0619219f3ec6c9

commit bf4a09fa9787fab26223f3b5bb0619219f3ec6c9
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2023-05-26 20:26:45 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2023-05-26 20:27:39 +0000

    sys-kernel/dracut: add fallback in case systemd.pc is not installed
    
    Bug: https://bugs.gentoo.org/765208
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 .../dracut/{dracut-059-r1.ebuild => dracut-059-r2.ebuild}  |  0
 sys-kernel/dracut/files/059-uefi-split-usr.patch           | 14 ++++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)
Comment 11 avidseeker7 2023-10-23 01:08:54 UTC
The problem persists on dracut 059. I checked if the commit was pushed into my system:

$ grep -r 'systemd_prefix=/usr'
sys-kernel/dracut/files/059-uefi-split-usr.patch:+[[ -n $systemd_prefix ]]
|| systemd_prefix=/usr


Here's the command that failed:

dracut: Executing: /usr/bin/dracut --uefi --kver=6.5.5-zen1
dracut: Can't find a uefi stub '/usr/lib/systemd/boot/efi/linuxx64.efi.stub' to create a UEFI executable

I'm using OpenRC on Gentoo.
Comment 12 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-10-23 01:10:01 UTC
Please file a ne wbug,
Comment 13 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-10-23 01:10:11 UTC
(In reply to Sam James from comment #12)
> Please file a ne wbug,

*a new bug
Comment 14 avidseeker7 2023-10-23 01:29:04 UTC
newb ug submitted here: https://bugs.gentoo.org/916144