0

i have some broken packages, more specifically:

 linux-image-4.4.0-101-generic
 linux-image-extra-4.4.0-103-generic
 linux-image-4.4.0-103-generic
 linux-image-extra-4.4.0-104-generic
 linux-image-4.4.0-104-generic
 linux-image-extra-4.4.0-108-generic
 linux-image-4.4.0-108-generic
 linux-image-extra-4.4.0-109-generic
 linux-image-4.4.0-109-generic
 linux-image-extra-4.4.0-112-generic
 linux-image-4.4.0-112-generic
 linux-image-extra-4.4.0-116-generic
 linux-image-4.4.0-116-generic
 linux-image-extra-4.4.0-119-generic
 linux-image-4.4.0-119-generic
 linux-image-extra-4.4.0-127-generic
 linux-image-4.4.0-127-generic
 linux-image-extra-4.4.0-128-generic
 linux-image-4.4.0-128-generic
 linux-image-extra-4.4.0-130-generic
 linux-image-4.4.0-130-generic
 linux-image-extra-4.4.0-133-generic
 linux-image-4.4.0-133-generic
 linux-image-extra-4.4.0-134-generic
 linux-image-4.4.0-134-generic
 linux-image-extra-4.4.0-135-generic
 linux-image-4.4.0-135-generic
 linux-image-extra-4.4.0-139-generic
 linux-image-4.4.0-139-generic
 linux-image-extra-4.4.0-141-generic
 linux-image-4.4.0-141-generic
 linux-image-4.4.0-143-generic

When i tried to remove one of them, i got this error:

(Reading database ... 646975 files and directories currently installed.)
Removing linux-image-extra-4.4.0-101-generic (4.4.0-101.124) ...
depmod: FATAL: could not load /boot/System.map-4.4.0-101-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-101-generic /boot/vmlinuz-4.4.0-101-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.4.0-101-generic /boot/vmlinuz-4.4.0-101-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-101-generic /boot/vmlinuz-4.4.0-101-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-101-generic
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
depmod: WARNING: could not open /var/tmp/mkinitramfs_7UInLs/lib/modules/4.4.0-101-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_7UInLs/lib/modules/4.4.0-101-generic/modules.builtin: No such file or directory
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-101-generic /boot/vmlinuz-4.4.0-101-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-101-generic /boot/vmlinuz-4.4.0-101-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-101-generic /boot/vmlinuz-4.4.0-101-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-101-generic /boot/vmlinuz-4.4.0-101-generic
Searching for GRUB installation directory ... found: /boot/grub
/etc/default/grub: line 1: #: command not found
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-extra-4.4.0-101-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-4.4.0-101-generic

$ ls -al /boot
total 185785
drwxr-xr-x  5 root root     6144 Jul 11 13:39 .
drwxr-xr-x 24 root root     4096 May 20 11:39 ..
-rw-r--r--  1 root root  1249237 Oct 10  2017 abi-4.4.0-98-generic
-rw-r--r--  1 root root   190580 Mar 26 16:02 config-4.4.0-145-generic
-rw-r--r--  1 root root   190862 May  7 16:38 config-4.4.0-148-generic
-rw-r--r--  1 root root   190517 Oct 10  2017 config-4.4.0-98-generic
drwx------  4 root root     4096 Jan  1  1970 efi
drwxr-xr-x  5 root root     1024 Nov 12  2017 grub
-rw-r--r--  1 root root 14356810 Jul 11 13:39 initrd.img-4.4.0-101-generic
-rw-r--r--  1 root root 44454972 May 20 11:40 initrd.img-4.4.0-145-generic
-rw-r--r--  1 root root 44451845 May 20 11:40 initrd.img-4.4.0-148-generic
-rw-r--r--  1 root root 43512380 Nov 28  2018 initrd.img-4.4.0-98-generic
drwx------  2 root root    12288 Nov  4  2017 lost+found
-rw-r--r--  1 root root   182704 Jan 28  2016 memtest86+.bin
-rw-r--r--  1 root root   184380 Jan 28  2016 memtest86+.elf
-rw-r--r--  1 root root   184840 Jan 28  2016 memtest86+_multiboot.bin
-rw-------  1 root root  3906115 Mar 26 16:02 System.map-4.4.0-145-generic
-rw-------  1 root root  3907764 May  7 16:38 System.map-4.4.0-148-generic
-rw-------  1 root root  3887471 Oct 10  2017 System.map-4.4.0-98-generic
-rw-------  1 root root  7188984 Mar 27 12:03 vmlinuz-4.4.0-145-generic
-rw-------  1 root root  7196216 May 14 21:09 vmlinuz-4.4.0-148-generic
-rw-------  1 root root  7103856 Oct 10  2017 vmlinuz-4.4.0-98-generic
-rw-------  1 root root  7105784 Nov  5  2017 vmlinuz-4.4.0-98-generic.efi.signed

$ uname -a
Linux Server 4.4.0-98-generic #121-Ubuntu SMP Tue Oct 10 14:24:03 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

s$ lsb_release -r
Release:        16.04
  • Add to your question the output from ls -al /boot, uname -a, lsb_release -r. I think you might have this issue, but it's weird that you have "grub: line 1: #: command not found" as that line should be "# If you change this file, [...]" and any line with a # shouldn't be seen as a command ... strange. – pbhj Jul 11 '19 at 11:15
  • 1
    sudo apt autoremove will remove most of these packages automatically except for the 2 latest kernels (1 old kernel and the current kernel). If there are any kernels that autoremove doesn't remove then install Synaptic (sudo apt install synaptic) and select the Installed (local or obsolete) option in the left pane to show them. – karel Jul 11 '19 at 11:16

1 Answers1

0

In case everyone was wondering the fix was actually pretty simple, the grub file had a simple error on the first line, no idea how that got there, but if anybody else had this problem, hope this helps.