0

I'm using Ubuntu Server 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 grub, 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
  • I don't have any of the files it's looking for in my /boot/grub Is this a vanilla install? Did you do anything "interesting" to your system before running this update? Jul 22, 2018 at 13:57
  • @Organic Marble it's a month old install. I just reinstalled grub once because during an update I accidentally selected to update the config file instead of keeping the local version. That was about a week ago.
    – otpabu
    Jul 22, 2018 at 13:59
  • I was going to suggest copying the menu.lst file from somewhere else like a live USB, but I don't have that file in my /boot/grub, so not sure what is going on. Jul 22, 2018 at 14:02
  • 1
    If you tried to install grub, that is grub legacy. As your error message said you need grub-pc for BIOS installs or grub-efi-amd64 for UEFI installs. And if gpt partitioned drive, you need an ESP for UEFI or bios_grub partition for BIOS installs. And must always install same version which usually depends on how you boot install media UEFI or BIOS. Or you must be consistent in Boot mode. If you have or can run desktop version, you can run this: Post the link to the Create BootInfo summary report. Is part of Boot-Repair: help.ubuntu.com/community/Boot-Info
    – oldfred
    Jul 22, 2018 at 15:17

0

You must log in to answer this question.

Browse other questions tagged .