On one of my machines dpkg is unable to finish installing/configuring grub, only giving the error message:subprocess installed post-installation script returned error exit status 255Full output:# dpkg --configure grub-pcSetting up grub-pc (1.99-27+deb7u3) ...device node not founddevice node not founddevice node not founddevice node not foundInstallation finished. No error reported.Installation finished. No error reported.dpkg: error processing grub-pc (--configure): subprocess installed post-installation script returned error exit status 255Errors were encountered while processing: grub-pcThere is nothing in the log files that would shed any more light.Running dpkg with some debug options reveals a little more:# dpkg -D10113 --configure grub-pcSetting up grub-pc (1.99-27+deb7u3) ...D000002: fork/exec /var/lib/dpkg/info/grub-pc.postinst ( configure  )device node not founddevice node not founddevice node not founddevice node not foundInstallation finished. No error reported.Installation finished. No error reported.dpkg: error processing grub-pc (--configure): subprocess installed post-installation script returned error exit status 255D010000: trigproc_run_deferredErrors were encountered while processing: grub-pcNow I know the problem is someplace in /var/lib/dpkg/info/grub-pc.postinst configure, but that script doesn't seem to have any verbosity or debug options and is just to large to read through with nearly 700 lines. The script also doesn't have any exit 255 calls, so I tend to believe the problem isn't even in there but in some other script that is called.The configure task also fails for the kernel processes:# dpkg --configure linux-image-3.16.0-0.bpo.4-amd64Setting up linux-image-3.16.0-0.bpo.4-amd64 (3.16.39-1+deb8u1~bpo70+1) ...vmlinuz(/boot/vmlinuz-3.16.0-0.bpo.4-amd64) points to /boot/vmlinuz-3.16.0-0.bpo.4-amd64 (/boot/vmlinuz-3.16.0-0.bpo.4-amd64) -- doing nothing at /var/lib/dpkg/info/linux-image-3.16.0-0.bpo.4-amd64.postinst line 263.initrd.img(/boot/initrd.img-3.16.0-0.bpo.4-amd64) points to /boot/initrd.img-3.16.0-0.bpo.4-amd64 (/boot/initrd.img-3.16.0-0.bpo.4-amd64) -- doing nothing at /var/lib/dpkg/info/linux-image-3.16.0-0.bpo.4-amd64.postinst line 263./etc/kernel/postinst.d/initramfs-tools:update-initramfs: Generating /boot/initrd.img-3.16.0-0.bpo.4-amd64run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 255Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.16.0-0.bpo.4-amd64.postinst line 634.dpkg: error processing linux-image-3.16.0-0.bpo.4-amd64 (--configure): subprocess installed post-installation script returned error exit status 1Errors were encountered while processing: linux-image-3.16.0-0.bpo.4-amd64Line 634 in /var/lib/dpkg/info/linux-image-3.16.0-0.bpo.4-amd64.postinst boils down to this command:run-parts --report --exit-on-error --arg=3.16.0-0.bpo.4-amd64 --arg=/boot/vmlinuz-3.16.0-0.bpo.4-amd64 /etc/kernel/postinst.dRunning this command manually results in:run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 255This script is, as far as I can tell, only a wrapper that does a check and then calls update-grub, which works without error.update-grub just runs grub-mkconfig, so I ran this command and checked the return value:# grub-mkconfig -o /boot/grub/grub.cfgGenerating grub.cfg ...Found linux image: /boot/vmlinuz-3.16.0-0.bpo.4-amd64Found initrd image: /boot/initrd.img-3.16.0-0.bpo.4-amd64Found linux image: /boot/vmlinuz-3.2.0-4-amd64Found initrd image: /boot/initrd.img-3.2.0-4-amd64# echo $?255This seems to be the culprit. The script works, finds all kernels, generates a valid grub config (saves it as /boot/grub/grub.cfg.new though) and then exits with return code 255. And of course it doesn't have any debug options.How can I go on debugging the problem?Additional information that might or might not be helpful:the system is running debian wheezyGRUB is version 1.99-27+deb7u3the system has an mdraidthe system has been running for years, it's not a new installation. The error appeared only recentlynot quite sure, but I believe the error started to appear after a faulty hard drive was replacedthe configure task only fails for grub and the kernel packages. All other packages can be installed without errorMore information from questions that came up laterzulu668:~# cat /proc/mdstatPersonalities : [raid1]md2 : active raid1 sda4[2] sdb4[1]      1456504640 blocks super 1.2 [2/2] [UU]md1 : active raid1 sda3[2] sdb3[1]      7996352 blocks super 1.2 [2/2] [UU]md0 : active raid1 sda2[2] sdb2[1]      499392 blocks super 1.2 [2/2] [UU]unused devices: <none>zulu668:~# sudo mdadm --detail /dev/md0/dev/md0:        Version : 1.2  Creation Time : Wed Oct 29 12:40:33 2014     Raid Level : raid1     Array Size : 499392 (487.77 MiB 511.38 MB)  Used Dev Size : 499392 (487.77 MiB 511.38 MB)   Raid Devices : 2  Total Devices : 2    Persistence : Superblock is persistent    Update Time : Wed Mar 15 14:51:01 2017          State : clean Active Devices : 2Working Devices : 2 Failed Devices : 0  Spare Devices : 0           Name : zulu668:0  (local to host zulu668)           UUID : 22e14818:7754cf01:67287402:c31a3328         Events : 217    Number   Major   Minor   RaidDevice State       2       8        2        0      active sync   /dev/sda2       1       8       18        1      active sync   /dev/sdb2
Debugging dpkg configure failure with grub
grub2;dpkg