Hello, could this be reopened please? I believe this could be caused by
a race condition between grub-initrd-fallback.service and
grub2-common.service which both call grub-editenv. They seem run at the
same second and there is no lock between them.

I've seen both services fail on different servers. Here's one instance where 
grub2-common fails on Ubuntu 25.10:
# systemctl status grub-initrd-fallback.service grub2-common.service
○ grub-initrd-fallback.service - GRUB failed boot detection
     Loaded: loaded (/usr/lib/systemd/system/grub-initrd-fallback.service; 
enabled; preset: enabled)
     Active: inactive (dead) since Fri 2025-11-14 16:03:03 UTC; 3 days ago
 Invocation: b72e67abe1a24e6381b6e90741297042
    Process: 1486 ExecStart=/usr/bin/grub-editenv /boot/grub/grubenv unset 
initrdfail (code=exited, status=0/SUCCESS)
    Process: 1546 ExecStart=/usr/bin/grub-editenv /boot/grub/grubenv unset 
prev_entry (code=exited, status=0/SUCCESS)
   Main PID: 1546 (code=exited, status=0/SUCCESS)
   Mem peak: 2.2M
        CPU: 17ms

Nov 14 16:03:03 localhost systemd[1]: Starting grub-initrd-fallback.service - 
GRUB failed boot detection...
Nov 14 16:03:03 localhost systemd[1]: grub-initrd-fallback.service: Deactivated 
successfully.
Nov 14 16:03:03 localhost systemd[1]: Finished grub-initrd-fallback.service - 
GRUB failed boot detection.

× grub2-common.service - Record successful boot for GRUB
     Loaded: loaded (/usr/lib/systemd/system/grub2-common.service; enabled; 
preset: enabled)
     Active: failed (Result: exit-code) since Fri 2025-11-14 16:03:03 UTC; 3 
days ago
 Invocation: da29d1c42b1e4d50a27b8061f82273f2
    Process: 1487 ExecStartPre=/bin/sh -c [ -s /boot/grub/grubenv ] || rm -f 
/boot/grub/grubenv; mkdir -p /boot/grub (code=exited, status=0/SUCCESS)
    Process: 1547 ExecStart=grub-editenv /boot/grub/grubenv unset recordfail 
(code=exited, status=1/FAILURE)
   Main PID: 1547 (code=exited, status=1/FAILURE)
   Mem peak: 2.3M
        CPU: 19ms

Nov 14 16:03:03 localhost systemd[1]: Starting grub2-common.service - Record 
successful boot for GRUB...
Nov 14 16:03:03 localhost grub-editenv[1547]: grub-editenv: error: invalid 
environment block.
Nov 14 16:03:03 localhost systemd[1]: grub2-common.service: Main process 
exited, code=exited, status=1/FAILURE
Nov 14 16:03:03 localhost systemd[1]: grub2-common.service: Failed with result 
'exit-code'.
Nov 14 16:03:03 localhost systemd[1]: Failed to start grub2-common.service - 
Record successful boot for GRUB.
# 
# journalctl -u grub-initrd-fallback.service -u grub2-common.service -o 
short-iso-precise
2025-11-14T16:03:03.307633+00:00 localhost systemd[1]: Starting 
grub-initrd-fallback.service - GRUB failed boot detection...
2025-11-14T16:03:03.318421+00:00 localhost systemd[1]: Starting 
grub2-common.service - Record successful boot for GRUB...
2025-11-14T16:03:03.549363+00:00 localhost grub-editenv[1547]: grub-editenv: 
error: invalid environment block.
2025-11-14T16:03:03.557221+00:00 localhost systemd[1]: 
grub-initrd-fallback.service: Deactivated successfully.
2025-11-14T16:03:03.557494+00:00 localhost systemd[1]: Finished 
grub-initrd-fallback.service - GRUB failed boot detection.
2025-11-14T16:03:03.578089+00:00 localhost systemd[1]: grub2-common.service: 
Main process exited, code=exited, status=1/FAILURE
2025-11-14T16:03:03.578279+00:00 localhost systemd[1]: grub2-common.service: 
Failed with result 'exit-code'.
2025-11-14T16:03:03.578568+00:00 localhost systemd[1]: Failed to start 
grub2-common.service - Record successful boot for GRUB.


It's easy to make grub-editenv fail by running several instances at once:
# for i in {1..5}; do /usr/bin/grub-editenv /boot/grub/grubenv unset 
prev_entry& done
[1] 69641
[2] 69642
[3] 69643
[4] 69644
[5] 69645
# /usr/bin/grub-editenv: error: invalid environment block.
/usr/bin/grub-editenv: error: invalid environment block.
/usr/bin/grub-editenv: error: invalid environment block.

[1]   Done                    /usr/bin/grub-editenv /boot/grub/grubenv unset 
prev_entry
[2]   Done                    /usr/bin/grub-editenv /boot/grub/grubenv unset 
prev_entry
[3]   Exit 1                  /usr/bin/grub-editenv /boot/grub/grubenv unset 
prev_entry
[4]-  Exit 1                  /usr/bin/grub-editenv /boot/grub/grubenv unset 
prev_entry
[5]+  Exit 1                  /usr/bin/grub-editenv /boot/grub/grubenv unset 
prev_entry
#

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1919121

Title:
  /usr/bin/grub-editenv: error: invalid environment block.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1919121/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to