Debian – Fix Debian Update Fails on Building New Kernel

debiankernel-moduleslinux-kernelupgrade

my current version

$ cat /etc/*elease*
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

the exact command I run is

sudo aptitude update && sudo aptitude safe-upgrade"

here is the errors I get (I guess they are all linked between them)

/etc/kernel/header_postinst.d/dkms:
dkms: running auto installation service for kernel 6.1.0-9-amd64.
Sign command: /usr/lib/linux-kbuild-6.1/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub

Building module:
Cleaning build area...
'make' -j8 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=6.1.0-9-amd64 IGNORE_CC_MISMATCH='' modules.....(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.1.0-9-amd64 (x86_64)
Consult /var/lib/dkms/nvidia/418.113/build/make.log for more information.
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
dkms: autoinstall for kernel: 6.1.0-9-amd64 failed!
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 11
Failed to process /etc/kernel/header_postinst.d at /var/lib/dpkg/info/linux-headers-6.1.0-9-amd64.postinst line 11.
dpkg: error processing package linux-headers-6.1.0-9-amd64 (--configure):
 installed linux-headers-6.1.0-9-amd64 package post-installation script subprocess returned error exit status 1
Setting up libgnuradio-audio3.10.5:amd64 (3.10.5.1-3) ...
Setting up gcc-11 (11.3.0-14) ...
Setting up libgnuradio-zeromq3.10.5:amd64 (3.10.5.1-3) ...
Setting up console-setup-linux (1.220) ...
Setting up libgnuradio-qtgui3.10.5:amd64 (3.10.5.1-3) ...
Setting up console-setup (1.220) ...
Setting up libncurses-dev:amd64 (6.4-4) ...
dpkg: dependency problems prevent configuration of linux-headers-amd64:
 linux-headers-amd64 depends on linux-headers-6.1.0-9-amd64 (= 6.1.27-1); however:
  Package linux-headers-6.1.0-9-amd64 is not configured yet.

dpkg: error processing package linux-headers-amd64 (--configure):
 dependency problems - leaving unconfigured
Setting up libgnuradio-dtv3.10.5:amd64 (3.10.5.1-3) ...
Setting up libgnuradio-analog3.10.5:amd64 (3.10.5.1-3) ...
Setting up libgnuradio-digital3.10.5:amd64 (3.10.5.1-3) ...
Setting up libstdc++-11-dev:amd64 (11.3.0-14) ...
Setting up libgnuradio-channels3.10.5:amd64 (3.10.5.1-3) ...
Setting up libtinfo-dev:amd64 (6.4-4) ...
Setting up g++-11 (11.3.0-14) ...
Setting up gnuradio (3.10.5.1-3) ...
Setting up gnuradio-dev (3.10.5.1-3) ...
Processing triggers for shared-mime-info (2.2-1) ...
Processing triggers for mailcap (3.70+nmu1) ...
Processing triggers for desktop-file-utils (0.26-1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for gnome-menus (3.36.0-1.1) ...
Processing triggers for libglib2.0-0:amd64 (2.74.6-2) ...
Processing triggers for libglib2.0-0:i386 (2.74.6-2) ...
Processing triggers for libc-bin (2.36-9) ...
Processing triggers for man-db (2.11.2-2) ...
Errors were encountered while processing:
 linux-image-6.1.0-8-amd64
 linux-image-6.1.0-9-amd64
 linux-image-amd64
 linux-headers-6.1.0-8-amd64
 linux-headers-6.1.0-9-amd64
 linux-headers-amd64
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
Setting up linux-headers-6.1.0-8-amd64 (6.1.25-1) ...
/etc/kernel/header_postinst.d/dkms:
dkms: running auto installation service for kernel 6.1.0-8-amd64.
/usr/sbin/dkms: line 2497: echo: write error: Broken pipe
Sign command: /usr/lib/linux-kbuild-6.1/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub

Building module:
Cleaning build area...
'make' -j8 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=6.1.0-8-amd64 IGNORE_CC_MISMATCH='' modules.....(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.1.0-8-amd64 (x86_64)
Consult /var/lib/dkms/nvidia/418.113/build/make.log for more information.
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
dkms: autoinstall for kernel: 6.1.0-8-amd64 failed!
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 11
Failed to process /etc/kernel/header_postinst.d at /var/lib/dpkg/info/linux-headers-6.1.0-8-amd64.postinst line 11.
dpkg: error processing package linux-headers-6.1.0-8-amd64 (--configure):
 installed linux-headers-6.1.0-8-amd64 package post-installation script subprocess returned error exit status 1
Setting up linux-image-6.1.0-8-amd64 (6.1.25-1) ...
I: /initrd.img.old is now a symlink to boot/initrd.img-6.1.0-8-amd64
/etc/kernel/postinst.d/dkms:
dkms: running auto installation service for kernel 6.1.0-8-amd64.
/usr/sbin/dkms: line 2497: echo: write error: Broken pipe
Sign command: /usr/lib/linux-kbuild-6.1/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub

Building module:
Cleaning build area...
'make' -j8 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=6.1.0-8-amd64 IGNORE_CC_MISMATCH='' modules.....(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.1.0-8-amd64 (x86_64)
Consult /var/lib/dkms/nvidia/418.113/build/make.log for more information.
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
dkms: autoinstall for kernel: 6.1.0-8-amd64 failed!
run-parts: /etc/kernel/postinst.d/dkms exited with return code 11
dpkg: error processing package linux-image-6.1.0-8-amd64 (--configure):
 installed linux-image-6.1.0-8-amd64 package post-installation script subprocess returned error exit status 1
Setting up linux-image-6.1.0-9-amd64 (6.1.27-1) ...
I: /initrd.img is now a symlink to boot/initrd.img-6.1.0-9-amd64
/etc/kernel/postinst.d/dkms:
dkms: running auto installation service for kernel 6.1.0-9-amd64.
/usr/sbin/dkms: line 2497: echo: write error: Broken pipe
Sign command: /usr/lib/linux-kbuild-6.1/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub

Building module:
Cleaning build area...
'make' -j8 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=6.1.0-9-amd64 IGNORE_CC_MISMATCH='' modules.....(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.1.0-9-amd64 (x86_64)
Consult /var/lib/dkms/nvidia/418.113/build/make.log for more information.
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
dkms: autoinstall for kernel: 6.1.0-9-amd64 failed!
run-parts: /etc/kernel/postinst.d/dkms exited with return code 11
dpkg: error processing package linux-image-6.1.0-9-amd64 (--configure):
 installed linux-image-6.1.0-9-amd64 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of linux-image-amd64:
 linux-image-amd64 depends on linux-image-6.1.0-9-amd64 (= 6.1.27-1); however:
  Package linux-image-6.1.0-9-amd64 is not configured yet.

dpkg: error processing package linux-image-amd64 (--configure):
 dependency problems - leaving unconfigured
Setting up linux-headers-6.1.0-9-amd64 (6.1.27-1) ...
/etc/kernel/header_postinst.d/dkms:
dkms: running auto installation service for kernel 6.1.0-9-amd64.
/usr/sbin/dkms: line 2497: echo: write error: Broken pipe
Sign command: /usr/lib/linux-kbuild-6.1/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub

Building module:
Cleaning build area...
'make' -j8 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=6.1.0-9-amd64 IGNORE_CC_MISMATCH='' modules.....(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.1.0-9-amd64 (x86_64)
Consult /var/lib/dkms/nvidia/418.113/build/make.log for more information.
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
dkms: autoinstall for kernel: 6.1.0-9-amd64 failed!
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 11
Failed to process /etc/kernel/header_postinst.d at /var/lib/dpkg/info/linux-headers-6.1.0-9-amd64.postinst line 11.
dpkg: error processing package linux-headers-6.1.0-9-amd64 (--configure):
 installed linux-headers-6.1.0-9-amd64 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of linux-headers-amd64:
 linux-headers-amd64 depends on linux-headers-6.1.0-9-amd64 (= 6.1.27-1); however:
  Package linux-headers-6.1.0-9-amd64 is not configured yet.

dpkg: error processing package linux-headers-amd64 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-headers-6.1.0-8-amd64
 linux-image-6.1.0-8-amd64
 linux-image-6.1.0-9-amd64
 linux-image-amd64
 linux-headers-6.1.0-9-amd64
 linux-headers-amd64
                                         
Current status: 1 (-88) upgradable.```

Do I have to *(re)*install missing modules and if so how can I get their list ; or this is not at all the solution so then can you provide a procedure ?

Best Answer

OP states using the nouveau driver and not the nvidia driver. But it appears there's an old nvidia DKMS package from around 2020-04-26 still around, which is not compatible with the newer kernels and makes their installation fail because its build fails.

For such case:

apt-get -f purge nvidia-kernel-dkms

should fix the problem. If the package is actually not present anymore but DKMS still handles some remnants of it, then with the help of:

dkms status

one should be able to remove nvidia entries still managed by DKMS using dkms remove etc.

Should this non-free driver be actually needed, then the non-free (plus possibly contrib) repository should be added to the Debian sources list if not present and this package upgraded to bookworm's version (as of today 525.105.17). More information at Debian's wiki for Nvidia Graphics Drivers.

Related Topic