How to fix run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1 in APT
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.
Quick fix
Fixes run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
df -h /boot- Check available disk space in /boot
- Remove old kernel images to free space (if needed)
- Fix broken package configuration
- Reinstall initramfs-tools package
df -h /bootrun-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
What this error means
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.
Typical symptoms
- Kernel update fails with 'exit code 1' message
- System boots but new kernel version doesn't install
- apt commands show package configuration errors after kernel install attempt
- /boot partition shows as full or running out of space
Common causes
- Insufficient disk space in the /boot partition (most common)
- Corrupted initramfs-tools package or conflicting packages
- Missing or broken dependencies required by initramfs-tools
- Failing hook scripts in /usr/share/initramfs-tools/hooks/
- SELinux or AppArmor restrictions preventing script execution
How to fix "run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1"
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 -50Advanced notes
On 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.
Frequently asked questions
- What does "run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return c" mean?
- This error happens during the post-installation phase of a kernel update on Debian/Ubuntu systems. 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.
- How do I fix "run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return c"?
- 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.
- What causes "run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return c"?
- Insufficient disk space in the /boot partition (most common) Corrupted initramfs-tools package or conflicting packages Missing or broken dependencies required by initramfs-tools
- Is the "run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return c" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.