apt/dpkg not working due to linux-image/firmware problems

I recently installed Debian 12. Apt was working, but was complaining about a not fully configured linux-image. I tried to remove the image and upgrade, but now I’m unable to us apt or dpkg to remove or install anything. It has issues with a "not fully installed or removed" package, runs into an error while attempting to resolve it, and aborts.

Summary of the problems I have run into (details below):

  • Can’t apt/dpkg remove, purge, install, or upgrade
  • dpkg post-removal script subprocess returned error
  • raspi-firmware complains /boot/firmware may not be mounted
  • I do have a 1K EXT4-fs partition that’s not mounting
  • raspi-firmware – Do I need this? Running a Panasonic Toughbook CF-31
  • initramfs-tools – Complains if I just remove raspi-firmware

I am using kernel 6.1.0-9-amd64, but am getting these problems due to linux-image-6.1.0-10-amd64. Following what I’ve found on the web, I have manually deleted all files associated with the latter package, but still get the error. (dpkg-query -L linux-image-6.1.0-10-amd64 varifies that the package indeed "does not contain any files")

This is an example of the output returned by apt when attempting to install or remove any package:

Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
The following packages will be REMOVED:
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 17.5 kB of archives.
After this operation, 408 MB disk space will be freed.
Do you want to continue? [Y/n]
Get:1 https://deb.debian.org/debian bookworm/main amd64 cmatrix amd64 2.0-3 [17.5 kB]
Fetched 17.5 kB in 1s (12.3 kB/s)
(Reading database ... 252302 files and directories currently installed.)
Removing linux-image-6.1.0-10-amd64 (6.1.37-1) ...
update-initramfs: Deleting /boot/initrd.img-6.1.0-10-amd64
raspi-firmware: missing /boot/firmware, did you forget to mount it?
run-parts: /etc/kernel/postrm.d/z50-raspi-firmware exited with return code 1
dpkg: error processing package linux-image-6.1.0-10-amd64 (--remove):
 installed linux-image-6.1.0-10-amd64 package post-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

Following what it says takes me to line 35 of /etc/kernel/postinst.d/z50-raspi-firmware, where my error is thrown when the following condition holds true:

! mountpoint -q /boot/firmware

I’m not familiar with what -q means in this context. I am not running dpkg from chroot or a virtual machine. I do have the directory /boot/firmware in my root partition. In case it’s related, I do have an unmounted 1K Ext4-fs partition sda2 which fails to mount with dmesg reporting: "unable to read superblock".

Since I’m not running a Rasberry Pi, I attempted removing these files and running apt autoremove,

  • /etc/initramfs/post-update.d/z50-raspi-firmware
  • /etc/kernel/postrm.d/z50-raspi-firmware

but apt said:

Removing linux-image-6.1.0-10-amd64 (6.1.37-1) ...
update-initramfs: Deleting /boot/initrd.img-6.1.0-10-amd64
/etc/kernel/postrm.d/z50-raspi-firmware: 2: exec: /etc/kernel/postins
t.d/z50-raspi-firmware: not found
run-parts: /etc/kernel/postrm.d/z50-raspi-firmware exited with return
 code 127

It seems something is telling initramfs-tools to expect to find the raspi-firmware. I saw dpkg-query -L includes /usr/share/initramfs-tools/hooks/raspi-firmware-fsck and experimented with removing that too, but it made no difference.

I saw a similar question, but the solution there was not enough in my case. I’m new to stack exchange, and I’m not sure how or if this question should be appended to that.
dpkg: error processing package linux-image-amd64 (–configure): dependency problems – leaving unconfigured

Asked By: Frail Rearranger


For the solution in the linked question to work, postinst.d/z50-raspi-formware must first be reinstated.

Create /etc/kernel/postinst.d/z50-raspi-firmware consisting of two lines:


Make it executable:

chmod a=rx /etc/kernel/postinst.d/z50-raspi-firmware

Then purging should work:

apt purge raspi-firmware

After doing this I was able to run apt autoremove, install, and so forth without errors.

Answered By: Frail Rearranger
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.