How to resolve dpkg dependencies for linux kernel? (Debian)

6,378

Solution 1

You don't have a dependency problem. You have a package configuration problem.

The relevant part of the transcript is:

/etc/kernel/postinst.d/zz-update-grub:
/usr/sbin/grub-mkconfig: 1: /etc/default/grub: ]#: not found
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127

Everything after that is a consequence of this problem: a kernel post-installation script failed, so the package linux-image-4.9.0-3-amd64 is not installed properly (it is not configured, in Debian terminology), and so packages that depend on it aren't properly installed either.

Evidently there is a typo in /etc/default/grub (stray ] at the beginning of a line, it seems). Fix that, then finish the ongoing installations with

apt-get -f install

Solution 2

Turns out it has nothing to do with dependencies. Something gets broken during an update and GRUB gets messed up. To reinstall GRUB, call:

sudo apt-get update
sudo apt-get install --reinstall grub
sudo apt-get dist-upgrade
sudo apt-get upgrade
sudo apt autoremove

Then reboot and try running apt-get dist-upgrade again, the issue should be resolved.

Share:
6,378
JohnJohn
Author by

JohnJohn

Updated on September 18, 2022

Comments

  • JohnJohn
    JohnJohn over 1 year

    How would you resolve this error when you run sudo apt-get dist-upgrade?

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Calculating upgrade... Done
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    2 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Setting up linux-image-4.9.0-3-amd64 (4.9.30-2+deb9u2) ...
    /etc/kernel/postinst.d/initramfs-tools:
    update-initramfs: Generating /boot/initrd.img-4.9.0-3-amd64
    /etc/kernel/postinst.d/zz-update-grub:
    /usr/sbin/grub-mkconfig: 1: /etc/default/grub: ]#: not found
    run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
    dpkg: error processing package linux-image-4.9.0-3-amd64 (--configure):
     subprocess installed post-installation script returned error exit status 1
    dpkg: dependency problems prevent configuration of linux-image-amd64:
     linux-image-amd64 depends on linux-image-4.9.0-3-amd64; however:
      Package linux-image-4.9.0-3-amd64 is not configured yet.
    
    dpkg: error processing package linux-image-amd64 (--configure):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
     linux-image-4.9.0-3-amd64
     linux-image-amd64
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    I'm on Debian 9 (stretch) and the latest version of the kernel is actually the one that I currently have (linux-image-4.9.0-3-amd64) When I run sudo dpkg --configure -a I get the following message:

    sudo dpkg --configure -a
    dpkg: dependency problems prevent configuration of linux-image-amd64:
     linux-image-amd64 depends on linux-image-4.9.0-3-amd64; however:
      Package linux-image-4.9.0-3-amd64 is not configured yet.
    
    dpkg: error processing package linux-image-amd64 (--configure):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
     linux-image-amd64
    

    I've tried running these commands to no avail:

    sudo apt-get autoclean
    sudo apt-get clean
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get dist-upgrade
    sudo apt-get -f install
    

    And if I run the sudo dkpg --purge linux-image-4.9.0-3-amd64 and just update and reinstall the kernel, I get this dependency error:

    dpkg: dependency problems prevent removal of linux-image-4.9.0-3-amd64:
     linux-image-amd64 depends on linux-image-4.9.0-3-amd64.
    
    dpkg: error processing package linux-image-4.9.0-3-amd64 (--purge):
     dependency problems - not removing
    Errors were encountered while processing:
     linux-image-4.9.0-3-amd64
    

    Thanks in advance.