I've been having an error when updating or running any apt
command for a week or so.
Upgrading to LTS 18.04 hasn't resolved it, nor has removing all old kernels.
Space isn't an issue either.
Attempting to reinstall initramfs
doesn't work.
Error I get is:
Reading package lists...
Building dependency tree...
Reading state information...
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-4.15.0-47-generic (4.15.0-47.50) ...
Setting up initramfs-tools (0.130ubuntu3.7) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for linux-image-4.15.0-47-generic (4.15.0-47.50) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.15.0-47-generic
E: /usr/share/initramfs-tools/hooks/fsck failed with return 1.
update-initramfs: failed for /boot/initrd.img-4.15.0-47-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-4.15.0-47-generic (--configure):
installed linux-image-4.15.0-47-generic package post-installation script subprocess returned error exit status 1
Processing triggers for initramfs-tools (0.130ubuntu3.7) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-47-generic
E: /usr/share/initramfs-tools/hooks/fsck failed with return 1.
update-initramfs: failed for /boot/initrd.img-4.15.0-47-generic with 1.
dpkg: error processing package initramfs-tools (--configure):
installed initramfs-tools package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-4.15.0-47-generic
initramfs-tools
Anyone got any ideas as to what I can do?
Thanks.
Running auto-remove and clean worked for my situation.
apt-get auto-remove && apt-get clean && apt-get update && apt-get upgrade
Warning: do not do this if your hard drive is encrypted unless you know exactly what you're doing
For me, it was an issue with the initramfs-tools package
I just did:
Then I no longer received the error
@jameshibbard brought up an important point: if you use either full-drive encryption, or encrypt your initramfs output (squashfs vmlinuz pacakges in
/boot
) as is a new feature, please be careful as switching out versions of yourinitramfs-tools
seem likely to make your system unbootable.If you have no idea what that means, chances are your system is not encrypted, unless you remember selecting it during the install process. I've noticed some graphical installers are including it as an option these days, including Ubuntu if I'm remembering correctly.
Do your due diligence.
I had this error since more than a year. Now I found a solution.
Explanation: /boot is on a different partition with insufficient space to perform the operation. Solution: do the update on a drive where there is sufficient space and copy back the results.
As pointed out by Harald, the problem was insufficient space on the /boot partition.
His solution didn't work for me, but led me directly to what did:
cd /boot
, thenls
to look at the versions of the files already there. Thenrm
each of the files that have multiple versions, making sure to delete all but the newest, thensudo apt update
A similar question has this solution:
Additionally ensure this command:
returns this output:
This was the solution for me.
I had this issue on two separate machines today after doing an
apt update
andapt upgrade
except mine was for linux-image-4.15.0-48-generic. (Ubuntu 18.04.2)My fix was this (reproduced on both machines):
Then reinstall the package:
This will set the package to manually installed and will replace the *.postinst file.
I've just had a very similar issue when I did an
sudo apt autoremove
and it failed attempting to install kernel files for a kernel I don't have. Myuname -a
shows I'm using kernel version 5.0.0-20 and runningls -al /boot
shows only this and the 5.0.0-17 kernel are installed. However,apt
suddenly turned up errors and attempted to install files in my/boot
for old kernels including 5.0.0-15, 4.18.0-17, 4.13.0-45. Which is weird.So I figure that somehow they've altered the logic for
dkms
(or something related toinitramfs
) and it checks some other locations to see if kernels might be installed and then does updates on those kernels and replaces missing files.I'm not sure exactly what fixed it but I did:
Then I did:
Then I did:
I have problems with a very tight
/boot
folder for historical reasons and so removed old kernel files with:Finally I ran:
Which finished as expected and returned the system to the expected state without attempting to install extraneous kernels. I did not test as I went along so can not guarantee which part fixed it, but it was not harmful to clear those old files out AFAICT.
Aside, checking my
/var/log/apt/history.log
file, this appears to be the beginning of this particular error:But this may be a false flag as for me the limited /boot space can be the cause of the
error code (1)
.Try purging unused kernels. If problem persists then remove all 'initrd' images with
then generate new 'initrd' images for all current existing kernels
This was happening to me. Ended up being that /boot was full.
Check boot partition space with
df -h
Then free up some space with: How do I free up more space in /boot?