Score:0

GRUB Error 'invalid environment block' on booting & updating Ubuntu Server 20.04

tr flag

When I boot my Ubuntu 20.04 server (virtualbox vdi, local dev), I get the following error:

Error: invalid environment block.
press any key to continue....

Now, when I run updates, everything installs correctly, except for grub, which throws this error:

dpkg: error processing package grub-common (--configure):
 installed grub-common package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of grub2-common:
 grub2-common depends on grub-common (= 2.04-1ubuntu26.17); however:
  Package grub-common is not configured yet.

dpkg: error processing package grub2-common (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of grub-pc-bin:
 grub-pc-bin depends on grub-common (= 2.04-1ubuntu26.17); however:
  Package grub-common is not configured yet.

dpkg: error processing package grub-pc-bin (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of grub-pc:
 grub-pc depends on grub-common (= 2.04-1ubuntu26.17); however:
  Package grub-common is not configured yet.
 grub-pc depends on grub2-common (= 2.04-1ubuntu26.17); however:
  Package grub2-common is not configured yet.
 grub-pc depends on grub-pc-bin (= 2.04-1ubuntu26.17); however:
  Package grub-pc-bin is not configured yet.

dpkg: error processing package grub-pc (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because MaxReports is reached already
Errors were encountered while processing:
 grub-common
 grub2-common
 grub-pc-bin
 grub-pc
E: Sub-process /usr/bin/dpkg returned an error code (1)

Solutions I've tried

  1. I booted the server from system disk and ran e2fsck /dev/sda2 -y as suggested in Error: invalid environment block. Press any key to continue (Ubuntu 20.04 ZFS), but no luck.

  2. Running

    sudo dpkg --configure -a && sudo apt --fix-broken install
    
  3. Running

    dpkg --purge --force-depends grub-common && apt-get -f install
    

Any tips?

Score:2
gt flag

There seems to be a corrupted /boot/grub/grubenv. A common source for this can be a hardware defect, or loose cable, or possibly turning off power while in grub.
Deleting the file and running sudo grub-editenv list while create an empty file, and allow you to continue.
related:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1946097
https://sarata.com/manpages/grub-editenv.1.html

nightwatch avatar
tr flag
short, sweet, effective... worked on first attempt... thanks for the helping hand. FYI I am workin virtualbox. The problem started after I used virtuabloox to compact my disk.
Score:0
ru flag

I don't have enough information, but common things you can always try is:

sudo dpkg --configure -a
sudo apt --fix-broken install

or this:

dpkg --purge --force-depends grub-common
apt-get -f install

or maybe simply this works:

apt update & apt-upgrade
nightwatch avatar
tr flag
swing and a miss... thx for trying... no effect... same errors
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.