The "run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1" error occurs during kernel updates when the initramfs-tools script fails. Common causes include insufficient disk space in /boot, corrupted packages, or missing dependencies. Most fixes involve regenerating the initramfs or freeing disk space.
This error happens during the post-installation phase of a kernel update on Debian/Ubuntu systems. The `run-parts` command executes scripts in the `/etc/kernel/postinst.d/` directory to set up the new kernel. When the `initramfs-tools` script (which generates the kernel's initial ramdisk) exits with a non-zero code, the entire kernel installation fails. The initramfs contains essential kernel modules and drivers needed to boot the system. When the script fails to generate it, your system cannot complete the kernel update, leaving you with an incomplete installation.
First, verify if /boot has enough free space. The initramfs images can be quite large.
df -h /bootIf /boot is nearly full (90%+ used), you need to free up space before retrying the kernel update. Typical requirement is at least 50-100MB free space.
If /boot is full, remove old kernel versions that are no longer needed:
sudo apt autoremove --purgeThis command removes old kernel packages automatically. You can also manually purge specific old kernels:
sudo apt purge linux-image-X.X.X-XX-generic linux-headers-X.X.X-XX-genericReplace X.X.X-XX with the actual kernel version number. Always keep at least one working kernel version.
Attempt to configure any broken packages and fix broken dependencies:
sudo dpkg --configure -a
sudo apt --fix-broken installThese commands will try to complete any pending package installations or repairs. Run them sequentially.
The initramfs-tools package itself may be corrupted. Reinstall it:
sudo apt install --reinstall initramfs-tools initramfs-tools-coreThis will restore the package from the repository and re-run its post-installation scripts.
If the above steps don't work, manually regenerate the initramfs for your current kernel:
sudo update-initramfs -u -k allThe -u flag updates existing initramfs images, and -k all applies to all kernels. This bypasses the post-installation hook and generates initramfs directly.
If the above steps don't resolve the issue, run the script directly to see the specific error:
sudo /etc/kernel/postinst.d/initramfs-tools $(uname -r) /boot/vmlinuz-$(uname -r)This will show you the exact failure message. Check for errors related to:
- Missing tools (gzip, cpio, lz4)
- Hook script failures in /usr/share/initramfs-tools/hooks/
- File system permission issues
Review detailed logs:
sudo journalctl -xe
dmesg | tail -50On systems with SELinux or AppArmor enabled, permission issues can prevent the postinst script from executing. Check your security module status with getenforce (SELinux) or aa-status (AppArmor) and temporarily disable if testing.
For Raspberry Pi systems running Debian, the error may involve raspi-firmware. If you see "raspi-firmware: missing /boot/firmware", remove the package with sudo apt autoremove --purge raspi-firmware.
If using dracut instead of initramfs-tools, ensure the /etc/kernel/postinst.d/initramfs-tools script is removed or the update-initramfs executable is available. These packages can conflict on some systems.
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Sub-process /usr/bin/dpkg returned an error code (2)
How to fix "Sub-process /usr/bin/dpkg returned an error code (2)" in APT
dpkg-divert: error: rename involves overwriting 'path' with different file
How to fix dpkg-divert rename conflicts in APT
E: Sub-process /usr/bin/dpkg returned an error code (1) during kernel installation
How to fix "dpkg returned an error code (1)" in APT kernel installation
dpkg: dependency problems prevent configuration of triggers
dpkg: dependency problems prevent configuration of triggers in apt