Bug 1972223

Summary: /sys/firmware/efi/efivars is not mounted on installed system
Product: Red Hat Enterprise Linux 9 Reporter: Jan Stodola <jstodola>
Component: systemdAssignee: Michal Sekletar <msekleta>
Status: CLOSED CURRENTRELEASE QA Contact: Frantisek Sumsal <fsumsal>
Severity: high Docs Contact:
Priority: high    
Version: 9.0CC: bgoncalv, coxu, dtardon, efuller, ernunes, fsumsal, fweimer, jamacku, jbastian, jieli, jjaburek, jpazdziora, msalter, msekleta, pbunyan, pholica, piliu, pvlasin, ravarghe, systemd-maint-list, systemd-maint, xiawu, zbyszek
Target Milestone: betaKeywords: TestBlocker, Triaged
Target Release: 9.0 Beta   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: systemd-249-6.el9_b Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2003130 (view as bug list) Environment:
Last Closed: 2021-12-07 21:57:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1942219, 1971841, 1972424, 1977651, 2003130    

Description Jan Stodola 2021-06-15 13:03:37 UTC
Description of problem:
After a fresh installation of compose RHEL-9.0.0-20210614.6 on an aarch64 system, /sys/firmware/efi/efivars is not automatically mounted, which causes a problem for example for efibootmgr:

# efibootmgr 
EFI variables are not supported on this system.
# mount | grep efi
/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)
# mount -t efivarfs efivarfs /sys/firmware/efi/efivars
# efibootmgr 
BootCurrent: 0001
Timeout: 10 seconds
BootOrder: 0001,0002,0003,0004,0000
Boot0000* Fedora
Boot0001* Red Hat Enterprise Linux
Boot0002* UEFI: PXE IP4 EMAC SNP Controller
Boot0003* UEFI: Built-in EFI Shell
Boot0004* RedHat Boot Manager
#


Version-Release number of selected component (if applicable):
RHEL-9.0.0-20210614.6
systemd-248-5.el9

How reproducible:
Always on particular systems

Steps to Reproduce:
1. Install RHEL-9.0
2. Boot into the installed system
3. Run efibootmgr or check if /sys/firmware/efi/efivars is mounted

Actual results:
/sys/firmware/efi/efivars in not mounted

Expected results:
/sys/firmware/efi/efivars is mounted automatically

Comment 2 Jiri Jaburek 2021-06-15 17:51:25 UTC
I also encountered this recently and today (what a coincidence) asked about /sys/firmware/efi/vars vs efivarfs on tech-list.

My efibootmgr is working, however, thanks to a /sys/firmware/efi/vars fallback:

# mount | grep efivarfs

# efibootmgr 
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0001,0002,0000,0003
Boot0000* UiApp
Boot0001* Red Hat Enterprise Linux
Boot0002* UEFI Misc Device
Boot0003* EFI Internal Shell

# strace -f efibootmgr
...
access("/sys/firmware/efi/efivars/", F_OK) = 0
statfs("/sys/firmware/efi/efivars/", {f_type=SYSFS_MAGIC, ...) = 0
openat(AT_FDCWD, "/sys/firmware/efi/vars/", ...) = 4
...

Comment 3 Jiri Jaburek 2021-06-15 17:55:04 UTC
(In reply to Jiri Jaburek from comment #2)
> I also encountered this recently and today (what a coincidence) asked about
> /sys/firmware/efi/vars vs efivarfs on tech-list.
> 
> My efibootmgr is working, however, thanks to a /sys/firmware/efi/vars
> fallback:

To be clear - this is x86_64 UEFI (efibootmgr working, but no efivarfs mount), whereas the OP is aarch64.

Comment 4 David Tardon 2021-06-16 08:03:10 UTC
Caused by bug 1957211.

Comment 6 Jeff Bastian 2021-06-30 15:13:28 UTC
*** Bug 1975541 has been marked as a duplicate of this bug. ***

Comment 7 Mark Salter 2021-06-30 15:31:44 UTC
Commit 963fabf37f6a has been around since 5.10-rc1, so that probably isn't the problem.

Comment 8 Jeff Bastian 2021-06-30 15:53:08 UTC
(In reply to Mark Salter from comment #7)
> Commit 963fabf37f6a has been around since 5.10-rc1, so that probably isn't
> the problem.

No, I mean, it's the reason we _don't_ see a problem on x86: RHEL9 on x86 still has the old efivars feature enabled and efibootmgr will fall back to it if efivarfs is not available.  efivars is not available on ARM -- due to commit 963fabf37f6a -- so efibootmgr does not have a fallback path on ARM systems.

Note: bug 1972424 is about disabling efivars on x86 too, so when that happens, efibootmgr will fail on x86 too (unless efivarfs is manually mounted or this systemd bug is fixed).


It's hard on the eyes to tell the difference between efivars and efivarfs :-)

Comment 10 Pavel Holica 2021-08-06 12:18:34 UTC
I've hit this bug as well on aarch64 and very unfortunate effect is that the rhts-reboot effectively cannot be used as many of the systems just boot to efishell (after unsuccessful netboot) and won't continue booting from HDD (which rhts-reboot would do by running efibootmgr -n XXXX).

I'm adding TESTBLOCKER keyword as this bug prevents way to many tests executed in Beaker cannot finish due to this bug.

Comment 11 Jiri Jaburek 2021-08-06 17:17:50 UTC
Changing Hardware to All as my report in this BZ is from x86_64 (where it doesn't block anything, but is an obsolete interface) whereas others seem to be blocked on aarch64 where the same issue causes functionality breakages.

Comment 16 Michal Sekletar 2021-08-25 13:44:31 UTC
I've posted the patch upstream that changes under what conditions we mount efivarfs. Previously, we would attempt to mount the filesystem if we were compiled with EFI support and system was booted in EFI mode. However, on RHEL-9 we don't want to be compiled with EFI support (as we don't want to ship systemd-boot and bootctl) but we want to mount the efivarfs anwyway (provided that system is booted in EFI mode). First reaction of upstream to the patch was not positive but I will try to persuade the upstream developers to change their mind. Worst case we should be able to introduce this as a downstream change. 

https://github.com/systemd/systemd/pull/20532

Comment 17 Jeff Bastian 2021-08-25 17:40:32 UTC
What if you build systemd with EFI support enabled, but then simply remove the systemd-boot and bootctl binaries in the spec file so we don't ship them in the rpm?  That might be the simplest work around.

Pseudo-code:

%build
./configure
make

%install
make install
rm -f ${buildroot}/%{_sbindir}/systemd-boot
rm -f ${buildroot}/%{_sbindir}/bootctl
...


Other rpms do this, so there is precedent.  For example, from strace.spec:

%install
make DESTDIR=%{buildroot} install
...
# remove unpackaged files from the buildroot
rm -f %{buildroot}%{_bindir}/strace-graph
...

Comment 20 Plumber Bot 2021-09-21 07:51:57 UTC
fix merged to github rhel-9.0.0-beta branch -> https://github.com/redhat-plumbers/systemd-rhel9/pull/24

Comment 21 Plumber Bot 2021-09-21 07:52:22 UTC
fix merged to github main branch -> https://github.com/redhat-plumbers/systemd-rhel9/pull/23

Comment 22 Plumber Bot 2021-09-22 13:46:36 UTC
fix merged to github rhel-9.0.0-beta branch -> https://github.com/redhat-plumbers/systemd-rhel9/pull/31

Comment 23 Plumber Bot 2021-09-22 13:46:58 UTC
fix merged to github main branch -> https://github.com/redhat-plumbers/systemd-rhel9/pull/30