Writing GRUB to boot device failed

Bug #1904263 reported by Mikel Ward on 2020-11-14
46
This bug affects 9 people
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Undecided
Unassigned

Bug Description

Running apt-get update; apt-get upgrade for the first time in a few months, I get an error

```
Writing GRUB to boot device failed - continue
GRUB failed to install to the following devices:

 [*] /dev/nvme1n1p1 (104 MB; /boot/efi) 1000204 MB WDC WDS100T2B0C-00PXH0
```

Retrying fails.

Running

```
$ sudo dpkg-reconfigure --force grub-efi-amd64
```

Gives the following output:

```
Installing grub to /boot/efi.
Installing for x86_64-efi platform.
grub-install: warning: Internal error.
grub-install: error: failed to register the EFI boot entry: Operation not permitted.
Installing grub to /boot/efi.
Installing for x86_64-efi platform.
grub-install: warning: Internal error.
grub-install: error: failed to register the EFI boot entry: Operation not permitted.
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-53-generic
Found initrd image: /boot/initrd.img-5.4.0-53-generic
Found linux image: /boot/vmlinuz-5.4.0-52-generic
Found initrd image: /boot/initrd.img-5.4.0-52-generic
Found Windows Boot Manager on /dev/nvme1n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings
done
```

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: grub-efi-amd64 2.04-1ubuntu26.6
ProcVersionSignature: Ubuntu 5.4.0-52.57-generic 5.4.65
Uname: Linux 5.4.0-52-generic x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportVersion: 2.20.11-0ubuntu27.12
Architecture: amd64
CasperMD5CheckResult: skip
Date: Fri Nov 13 21:38:56 2020
InstallationDate: Installed on 2020-05-23 (175 days ago)
InstallationMedia: Xubuntu 19.10 "Eoan Ermine" - Release amd64 (20191017)
SourcePackage: grub2
UpgradeStatus: Upgraded to focal on 2020-05-29 (169 days ago)

Mikel Ward (mikelward) wrote :
Mikel Ward (mikelward) wrote :

Likely the same as https://bugs.launchpad.net/ubuntu/+source/grub2-signed/+bug/1872212.

Note that:
1) drive uses gpt, not mbr
2) EFI partition is not logical partition AFAICS
3) there are no dump files as described in $ root parted /dev/nvme1n1
GNU Parted 3.3
Using /dev/nvme1n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: WDC WDS100T2B0C-00PXH0 (nvme)
Disk /dev/nvme1n1: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
 1 1049kB 106MB 105MB fat32 EFI system partition boot, esp
 2 106MB 123MB 16.8MB Microsoft reserved partition msftres
 3 123MB 1000GB 1000GB ntfs Basic data partition msftdata
 4 1000GB 1000GB 530MB ntfs hidden, diag

```
$ root parted /dev/nvme1n1
GNU Parted 3.3
Using /dev/nvme1n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: WDC WDS100T2B0C-00PXH0 (nvme)
Disk /dev/nvme1n1: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
 1 1049kB 106MB 105MB fat32 EFI system partition boot, esp
 2 106MB 123MB 16.8MB Microsoft reserved partition msftres
 3 123MB 1000GB 1000GB ntfs Basic data partition msftdata
 4 1000GB 1000GB 530MB ntfs hidden, diag
```

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in grub2 (Ubuntu):
status: New → Confirmed
Lau (lgautier) wrote :

I am experiencing the same with grub-efi-amd64 2.04-1ubuntu26.7.

```
Setting up grub-efi-amd64-signed (1.142.9+2.04-1ubuntu26.7) ...
Trying to migrate /boot/efi into esp config
Installing grub to /boot/efi.
Installing for x86_64-efi platform.
grub-install: warning: Internal error.
grub-install: error: failed to register the EFI boot entry: Operation not permitted.
```

I also happen to have nvidia-drivers.

Untrusted Source (vc95cfrous) wrote :
Download full text (3.6 KiB)

Just ran an apt update/upgrade today on my home desktop and had the same issue.

----
The following NEW packages will be installed
  libapparmor1:i386
The following packages will be upgraded:
  alsa-ucm-conf grub-common grub-efi-amd64-bin grub-efi-amd64-signed grub-pc grub-pc-bin grub2-common libasound2 libasound2:i386 libasound2-data libasound2-dev
  libatopology2 libpulse-dev libpulse-mainloop-glib0 libpulse0 libpulse0:i386 libpulsedsp pulseaudio pulseaudio-module-bluetooth pulseaudio-utils
  yaru-theme-gnome-shell yaru-theme-gtk yaru-theme-icon yaru-theme-sound
24 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.

...
Preparing to unpack .../15-grub-pc_2.04-1ubuntu26.7_amd64.deb ...
Unpacking grub-pc (2.04-1ubuntu26.7) over (2.04-1ubuntu26.6) ...
Preparing to unpack .../16-grub2-common_2.04-1ubuntu26.7_amd64.deb ...
Unpacking grub2-common (2.04-1ubuntu26.7) over (2.04-1ubuntu26.6) ...
Preparing to unpack .../17-grub-pc-bin_2.04-1ubuntu26.7_amd64.deb ...
Unpacking grub-pc-bin (2.04-1ubuntu26.7) over (2.04-1ubuntu26.6) ...
Preparing to unpack .../18-grub-efi-amd64-signed_1.142.9+2.04-1ubuntu26.7_amd64.deb ...
Unpacking grub-efi-amd64-signed (1.142.9+2.04-1ubuntu26.7) over (1.142.8+2.04-1ubuntu26.6) ...
Preparing to unpack .../19-grub-efi-amd64-bin_2.04-1ubuntu26.7_amd64.deb ...
Unpacking grub-efi-amd64-bin (2.04-1ubuntu26.7) over (2.04-1ubuntu26.6) ...
Preparing to unpack .../20-grub-common_2.04-1ubuntu26.7_amd64.deb ...
Unpacking grub-common (2.04-1ubuntu26.7) over (2.04-1ubuntu26.6) ...

...
grub-install: warning: Internal error.
grub-install: error: failed to register the EFI boot entry: Operation not permitted.
Processing triggers for systemd (245.4-4ubuntu3.3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for dbus (1.12.16-2ubuntu2.1) ...
Processing triggers for install-info (6.7.0.dfsg.2-5) ...
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...

EFI Partition is also pretty big, for what it is.
------
Model: ATA Samsung SSD 840 (scsi)
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
 1 1049kB 538MB 537MB fat32 EFI System Partition boot, esp
 2 538MB 250GB 250GB ext4
-----

Tried removing and reinstalling. No specific failures noted from running grub-update outside the script. Files got updated

root@pinhead:/boot/grub/x86_64-efi# ls -l /boot/efi/EFI/BOOT/
total 4088
-rwx------ 1 root root 1681280 Nov 23 18:58 BOOTX64.EFI
-rwx------ 1 root root 1222800 Nov 23 18:21 fbx64.efi
-rwx------ 1 root root 1277024 Nov 23 18:21 mmx64.efi

root@pinhead:/boot/grub/x86_64-efi# cat /boot/efi/EFI/ubuntu/grub.cfg
search.fs_uuid 48221d77-53ec-48c0-ab30-bffb0b0129ec root hd0,gpt2
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

root@shodan-pin:/boot/grub/x86_64-efi# cat /boot/efi/EFI/ubuntu/BOOTX64.CSV
shimx64.efi,ubuntu,,This is the boot entry for ubuntu

root@pinhead:/boot/grub/x86_64-efi# ls -l /boot/efi/EFI/ubuntu/
total 4212
-rwx------ 1 root root 108 Nov 23 18:21 BOOTX64.CSV
-rwx------ 1 root root 126 Nov 23 18:58 grub.cfg
-rwx------ 1 ro...

Read more...

Julian Andres Klode (juliank) wrote :

We think this is not a bug in grub. It might be a bug in the kernel, but it's also likely to be a bug in the firmware implementation. Probably in the reference EDK2, given that it happens across various machines, whether real or virtual.

LinuxBreaksEasy (pleasehelpme) wrote :

Hi there,

I just did the same thing, routine update using update manager and now I'm stuck in an install loop.

I really don't want to destroy my system do to a simple update. It's critical the computer still boots. I've attached a screen shot. Should I 'Continue without installing Grub'? in order to have the computer function as normal still?

Kinds regards,
Goodman

Untrusted Source (vc95cfrous) wrote :

Since all the files I looked at are present and updated, I rebooted and it works as expected.

Also linking in adding --no-nvram to grub from this thread: -
https://bugs.launchpad.net/ubuntu/+source/grub2-signed/+bug/1872212

I ran the install line - boot drive is /dev/sda and efi (/dev/sda1) is mounted /boot/efi

root@pinhead:# grub-install --efi-directory=/boot/efi --target=x86_64-efi --no-nvram /dev/sda
Installing for x86_64-efi platform.
Installation finished. No error reported.

....compelted without error and reboots ok, so moving toward something in that area.

LinuxBreaksEasy (pleasehelpme) wrote :

Hi There,

I took a snapshot, then I went ahead and clicked 'Continued without installing Grub' and let the computer restart after the update. Everything restarted and came back up just fine, so it was okay to just continue in my case. Everything seems happy now. Not sure what the actual underlying issue is/was but the system is running stable.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers