[Bug 1919121] Re: /usr/bin/grub-editenv: error: invalid environment block.

Louis Sautier 1919121 at bugs.launchpad.net
Mon Nov 17 19:36:54 UTC 2025


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
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/1919121

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

Status in grub2 package in Ubuntu:
  Expired

Bug description:
  Upgrading GRUB on a ppc64le machine (8335-GCA (IBM Power System
  S822LC))

      2021-03-15 08:20:23 upgrade grub-common:ppc64el 2.04-1ubuntu26.8
  2.04-1ubuntu26.11

  `grub-initrd-fallback.service` failed to restart.

  ```
  $ sudo journalctl -xe
  […]
  Mar 15 08:20:30 s822lc grub-editenv[2481630]: /usr/bin/grub-editenv: error: invalid environment block.
  Mar 15 08:20:30 s822lc systemd[1]: grub-initrd-fallback.service: Main process exited, code=exited, status=1/FAILURE
  -- Subject: Unit process exited
  -- Defined-By: systemd
  -- Support: http://www.ubuntu.com/support
  -- 
  -- An ExecStart= process belonging to unit grub-initrd-fallback.service has exited.
  -- 
  -- The process' exit code is 'exited' and its exit status is 1.
  Mar 15 08:20:30 s822lc systemd[1]: grub-initrd-fallback.service: Failed with result 'exit-code'.
  -- Subject: Unit failed
  -- Defined-By: systemd
  -- Support: http://www.ubuntu.com/support
  -- 
  -- The unit grub-initrd-fallback.service has entered the 'failed' state with result 'exit-code'.
  Mar 15 08:20:30 s822lc systemd[1]: Failed to start GRUB failed boot detection.
  -- Subject: A start job for unit grub-initrd-fallback.service has failed
  ```

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




More information about the foundations-bugs mailing list