Autoremove linux-image-6.12.25-mnt-reform-arm64

I just ran sudo apt update and sudo apt full-upgrade. When I tried to run sudo apt autoremove, I ran into an error:

alex@subterraneobombus ~> sudo apt autoremove
REMOVING:                       
  linux-headers-6.12.25-common            linux-kbuild-6.12.25
  linux-headers-6.12.25-mnt-reform-arm64  reform-qcacld2-6.15.3-mnt-reform-arm64
  linux-image-6.12.25-mnt-reform-arm64

Summary:
  Upgrading: 0, Installing: 0, Removing: 5, Not Upgrading: 1
  Freed space: 225 MB

Continue? [Y/n] 
(Reading database ... 305178 files and directories currently installed.)
Removing linux-headers-6.12.25-mnt-reform-arm64 (6.12.25-1+reform20250503T130928Z) ...
Removing linux-headers-6.12.25-common (6.12.25-1+reform20250503T130928Z) ...
Removing linux-image-6.12.25-mnt-reform-arm64 (6.12.25-1+reform20250503T130928Z) ...
Usage: /usr/bin/linux-run-hooks image MAINT-SCRIPT KERNEL-VER IMAGE-PATH -- MAINT-PARAMS ...
       /usr/bin/linux-run-hooks headers MAINT-SCRIPT KERNEL-VER -- MAINT-PARAMS ...

This command is intended to be called from the maintainer scripts of
Linux kernel image and headers packages.  It executes hooks installed
in the appropriate subdirectories of /etc/kernel and
/usr/share/kernel.

The MAINT-SCRIPT argument must be the name of the maintainer script:
preinst, postinst, prerm, or postrm.

The KERNEL-VER argument must be the kernel version string as shown by
'uname -r' and used in filenames, not the package version.

The IMAGE-PATH argument must be the absolute filename of the kernel
image.

The MAINT-PARAMS arguments must be the parameters received by the
maintainer script.
dpkg: error processing package linux-image-6.12.25-mnt-reform-arm64 (--remove):
 installed linux-image-6.12.25-mnt-reform-arm64 package pre-removal script subprocess returned error exit status 2
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-image-6.12.25-mnt-reform-arm64
Processing was halted because there were too many errors.
Error: Sub-process /usr/bin/dpkg returned an error code (1)

Does running apt full-upgrade again fix the problem as pointed out here by @shigeru 20250624 sudo apt update; sudo apt full-upgrade error, no longer

Well, I can apt update, apt upgrade and apt full-upgrade without any errors. But that’s because linux-image-6.12.25-mnt-reform-arm64 is still installed.

apt list 'linux-image-6.*-mnt-reform-arm64'
linux-image-6.10.9-mnt-reform-arm64/now 6.10.9-1+reform20240916T143123Z arm64 [residual-config]
linux-image-6.11.10-mnt-reform-arm64/now 6.11.10-1+reform20241116T152555Z arm64 [residual-config]
linux-image-6.11.2-mnt-reform-arm64/now 6.11.2-1+reform20241016T122429Z arm64 [residual-config]
linux-image-6.11.4-mnt-reform-arm64/now 6.11.4-1+reform20241025T201754Z arm64 [residual-config]
linux-image-6.12.11-mnt-reform-arm64/now 6.12.11-1+reform20250130T110123Z arm64 [residual-config]
linux-image-6.12.17-mnt-reform-arm64/now 6.12.17-1+reform20250303T085515Z arm64 [residual-config]
linux-image-6.12.19-mnt-reform-arm64/now 6.12.19-1+reform20250323T000715Z arm64 [residual-config]
linux-image-6.12.22-mnt-reform-arm64/now 6.12.22-1+reform20250425T080214Z arm64 [residual-config]
linux-image-6.12.25-mnt-reform-arm64/now 6.12.25-1+reform20250503T130928Z arm64 [installed,local]
linux-image-6.12.6-mnt-reform-arm64/now 6.12.6-1+reform20241228T163100Z arm64 [residual-config]
linux-image-6.12.9-mnt-reform-arm64/now 6.12.9-1+reform20250110T183608Z arm64 [residual-config]
linux-image-6.15.3-mnt-reform-arm64/now 6.15.3-1~exp1+reform20250628T170930Z arm64 [installed,local]
linux-image-6.15.4-mnt-reform-arm64/reform,now 6.15.4-1~exp1+reform20250628T170930Z arm64 [installed,automatic]
linux-image-6.9.12-mnt-reform-arm64/now 6.9.12-1+reform20240803T055726Z arm64 [residual-config]

I’m not sure what this means. Two of them are installed and the one in question is no longer marked as autoremove? Can I just remove it as the newer one is shown as “automatic”?

apt remove linux-image-6.12.25-mnt-reform-arm64
REMOVING:                       
  linux-image-6.12.25-mnt-reform-arm64

Summary:
  Upgrading: 0, Installing: 0, Removing: 1, Not Upgrading: 0
  Freed space: 154 MB

Continue? [Y/n] 

Yes you can remove 6.12 because you have 6.15 installed.

Ah, this still doesn’t work:

root@subterraneobombus /h/alex [1]# apt-mark showmanual | grep linux-image
linux-image-6.12.25-mnt-reform-arm64
linux-image-mnt-reform-arm64
root@subterraneobombus /h/alex# apt-mark auto linux-image-6.12.25-mnt-reform-arm64 linux-image-mnt-reform-arm64
linux-image-6.12.25-mnt-reform-arm64 set to automatically installed.
linux-image-mnt-reform-arm64 set to automatically installed.
root@subterraneobombus /h/alex# apt autoremove
REMOVING:                       
  linux-image-6.12.25-mnt-reform-arm64  linux-image-mnt-reform-arm64

Summary:
  Upgrading: 0, Installing: 0, Removing: 2, Not Upgrading: 0
  Freed space: 154 MB

Continue? [Y/n] 
(Reading database ... 287393 files and directories currently installed.)
Removing linux-image-6.12.25-mnt-reform-arm64 (6.12.25-1+reform20250503T130928Z) ...
Usage: /usr/bin/linux-run-hooks image MAINT-SCRIPT KERNEL-VER IMAGE-PATH -- MAINT-PARAMS ...
       /usr/bin/linux-run-hooks headers MAINT-SCRIPT KERNEL-VER -- MAINT-PARAMS ...

This command is intended to be called from the maintainer scripts of
Linux kernel image and headers packages.  It executes hooks installed
in the appropriate subdirectories of /etc/kernel and
/usr/share/kernel.

The MAINT-SCRIPT argument must be the name of the maintainer script:
preinst, postinst, prerm, or postrm.

The KERNEL-VER argument must be the kernel version string as shown by
'uname -r' and used in filenames, not the package version.

The IMAGE-PATH argument must be the absolute filename of the kernel
image.

The MAINT-PARAMS arguments must be the parameters received by the
maintainer script.
dpkg: error processing package linux-image-6.12.25-mnt-reform-arm64 (--remove):
 installed linux-image-6.12.25-mnt-reform-arm64 package pre-removal script subprocess returned error exit status 2
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-image-6.12.25-mnt-reform-arm64
Processing was halted because there were too many errors.
Error: Sub-process /usr/bin/dpkg returned an error code (1)

Okay, i know what’s going on and it’s my fault. Sorry for that. Lets clean it up. How about this:

dpkg --purge --force-all linux-image-6.12.25-mnt-reform-arm64

If that does not work i guess you have to manually edit the failing maintainer script…

Yeah, the error persists. I’m guessing I need to change this the linux-run-hooks line in the postrm script based on the 6.15.4 model?

root@subterraneobombus /v/l/d/info# diff linux-image-6.12.25-mnt-reform-arm64.preinst*  linux-image-6.15.4-mnt-reform-arm64.preinst*
3c3
< version=6.12.25-mnt-reform-arm64
---
> version=6.15.4-mnt-reform-arm64
16c16
< linux-run-hooks preinst "$*" $version $image_path
---
> linux-run-hooks image preinst $version $image_path -- "$@"

Let me just add that I really really appreciate all the work you do. Thank you for all that.

1 Like

OK: This required two changes, in the prerm and postrm file.

linux-run-hooks image prerm $version $image_path -- "$@"

and:

    linux-run-hooks image postrm $version $image_path -- "$@"

And now:

# dpkg --purge linux-image-6.12.25-mnt-reform-arm64
(Reading database ... 280997 files and directories currently installed.)
Removing linux-image-6.12.25-mnt-reform-arm64 (6.12.25-1+reform20250503T130928Z) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-6.12.25-mnt-reform-arm64
/etc/kernel/postrm.d/zz-flash-kernel:
Using DTB: freescale/imx8mp-mnt-pocket-reform.dtb
flash-kernel: Kernel 6.12.25-mnt-reform-arm64 has been removed.
flash-kernel: A higher version (6.15.4-mnt-reform-arm64) is still installed, no reflashing required.
Purging configuration files for linux-image-6.12.25-mnt-reform-arm64 (6.12.25-1+reform20250503T130928Z) ...

Yes, this is the relevant change.

Thank you! I am aware that only those who do can make mistakes but I’d like to have all of you have a smooth experience with this Debian derivative. Thanks you for bearing with my bugs and helping me making this better. :heart:

I’m glad you managed to fix this issue!

2 Likes

I may be hitting this with 6.15.4 on my pocket – i can’t debug right now, but I’ll try this fix tomorrow.

The problem you have with 6.15.4 will not be this one. The problem here is that I introduced a change in how /usr/bin/linux-run-hooks is called a few months ago. So kernels built back then (6.12.25 for example) shipped with a maintainer script which called linux-run-hooks with different arguments than what the copy shipped in the linux-base package requires.

2 Likes

For everybody else finding this: if you are getting the following error message:

Removing linux-image-6.12.27-mnt-reform-arm64 (6.12.27-1+reform20250518T211405Z) ...
Usage: /usr/bin/linux-run-hooks image MAINT-SCRIPT KERNEL-VER IMAGE-PATH -- MAINT-PARAMS ...
       /usr/bin/linux-run-hooks headers MAINT-SCRIPT KERNEL-VER -- MAINT-PARAMS ...

This command is intended to be called from the maintainer scripts of
Linux kernel image and headers packages.  It executes hooks installed
in the appropriate subdirectories of /etc/kernel and
/usr/share/kernel.

The MAINT-SCRIPT argument must be the name of the maintainer script:
preinst, postinst, prerm, or postrm.

The KERNEL-VER argument must be the kernel version string as shown by
'uname -r' and used in filenames, not the package version.

The IMAGE-PATH argument must be the absolute filename of the kernel
image.

The MAINT-PARAMS arguments must be the parameters received by the
maintainer script.
dpkg: error processing package linux-image-6.12.27-mnt-reform-arm64 (--remove):
 installed linux-image-6.12.27-mnt-reform-arm64 package pre-removal script subprocess returned error exit status 2
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-image-6.12.27-mnt-reform-arm64

Then the hack to fix this and be able to remove the kernel is to edit the maintainer scripts with this sed command:

 sudo sed -i -n 's/\s*linux-run-hooks \(pre\|post\)rm "\$\*" \$version \$image_path$/linux-run-hooks image \1rm $version $image_path -- "$@"/' /var/lib/dpkg/info/linux-image-6.12.*-mnt-reform-arm64.*rm

Sorry for the mess and i hope this helps!

1 Like