Can't install kernel because it asks for grub, can't install grub because it asks for kernel

Hello,

I'm using a Linode with Ubuntu 18.04. Today I ran the usual apt upgrade and got the following error:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
linux-image-4.15.0-23-generic : Depends: linux-modules-4.15.0-23-generic but it is not going to be installed
Recommends: grub-pc or
grub-efi-amd64 or
grub-efi-ia32 or
grub but it is not installable or
lilo but it is not going to be installed
E: Broken packages

So I tried to reinstall grub2, but it won't let me:

Could not find /boot/grub/menu.lst file. Would you like /boot/grub/menu.lst generated for you? (y/N) /usr/sbin/update-grub-legacy-ec2: line 1101: read: read error: 0: Bad file descriptor
run-parts: /etc/kernel/postrm.d/x-grub-legacy-ec2 exited with return code 1
dpkg: error processing package linux-image-4.15.0-23-generic (--remove):
installed linux-image-4.15.0-23-generic package post-removal script subprocess returned error exit status 1
Removing linux-image-4.15.0-29-generic (4.15.0-29.31) …
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-29-generic
/etc/kernel/postrm.d/x-grub-legacy-ec2:
Searching for GRUB installation directory … found: /boot/grub
Searching for default file … found: /boot/grub/default
Testing for an existing GRUB menu.lst file …

Could not find /boot/grub/menu.lst file. Would you like /boot/grub/menu.lst generated for you? (y/N) /usr/sbin/update-grub-legacy-ec2: line 1101: read: read error: 0: Bad file descriptor
run-parts: /etc/kernel/postrm.d/x-grub-legacy-ec2 exited with return code 1
dpkg: error processing package linux-image-4.15.0-29-generic (--remove):
installed linux-image-4.15.0-29-generic package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-4.15.0-23-generic
linux-image-4.15.0-29-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried apt autoclean and apt autoremove, but the latter gives me this:

The following packages will be REMOVED:
linux-image-4.15.0-23-generic linux-image-4.15.0-29-generic
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
2 not fully installed or removed.

And then the same error above.

How do I fix that?

4 Replies

You should be able to fix this issue by installing the grub-pc package. You can do this by running:

$ sudo apt-get install grub-pc

If you get prompted about modifications to the /etc/grub/default file, you should choose to keep the locally installed version. See this community question for more details.

Hi there,

What specifically should we choose once we install grub-pc: The first screen is:

  The GRUB boot loader was previously installed to a disk that is no longer present, or whose unique identifier has changed for some reason. It is important to make sure that the installed GRUB core image stays in sync with GRUB modules
  and grub.cfg. Please check again to make sure that GRUB is written to the appropriate boot devices.

  If you're unsure which drive is designated as boot drive by your BIOS, it is often a good idea to install GRUB to all of them.

  Note: it is possible to install GRUB to partition boot records as well, and some appropriate partitions are offered here. However, this forces GRUB to use the blocklist mechanism, which makes it less reliable, and therefore is not
  recommended.

  GRUB install devices:

     [ ] /dev/sda (686657 MB; QEMU_HARDDISK)
     [ ] /dev/sdb (536 MB; QEMU_HARDDISK)
     [ ] /dev/sda (686657 MB; QEMU_HARDDISK)

(I'm assuming we should choose our largest disk on /dev/sda)


Is this likely to lead to issues in the future with unattended upgrades for security etc?

p.s. if I do choose the disk, I get the following messages:

installing for i386-pc platform. grub-install: warning: File system `ext2' doesn't support embedding. grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged.. Installation finished. No error reported. Installing for i386-pc platform. grub-install: warning: File system `ext2' doesn't support embedding. grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged.. Installation finished. No error reported.

which doesn't sound great! :)

@snowpool just a heads up looks like some other folks encountered this message as well.

@visualblind provides some insights here: https://www.linode.com/community/questions/17015/grub-default-settings

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct