Can't clean a full /boot because of unmet dependencies
Solution 1
In such case I would use the dpkg
tool to force the removal of some kernel packages.
This is not suggested for common use and is a bit dangerous, but in such case with unmet dependencies might help.
First of all locate the kernel in which the system is booted. The one that is currently loaded. Open a terminal (CTRL+ALT+T) and issue the following command
uname -r
It will show you the loaded kernel, you should NOT try to remove this one.
Then issue the command
ls /boot
it will return all the installed images. Pick one or two and try to remove them. Try to force remove/purge them. For example
sudo dpkg --force-all -P linux-image-3.13.0-32-generic
You can do the same for other images, in order to free up some space.
Then you can try to install the missing packages, or
sudo apt-get install -f
to try resolve the dependencies.
Finally, issue the "cleanup old kernels" command
sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")
Above command will remove ALL the kernels except the one that is currently loaded.
Because you have a separate /boot partition, keep in mind you will need to track its space and cleaning up often (the frequency depends on the space of /boot)
Solution 2
This is what worked for me on Ubuntu 16.04.
sudo apt autoremove --purge
sudo apt autoremove
sudo apt-get -f install
sudo apt-get upgrade
Solution 3
List all kernels:
dpkg --list 'linux-image*'
Display current kernel:
uname -r
List all kernels EXCEPT current one:
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'
Make sure your current kernel isn't on that list.
Remove all kernels EXCEPT current one:
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge
Clear other stuff:
sudo apt-get autoremove
If it stills throws any error then repeat following commands to remove unwanted kernels,
sudo dpkg --purge linux-image-X.X.X-XXX-generic linux-image-extra-X.X.X-XXX-generic linux-signed-image-X.X.X-XXX-generic
sudo dpkg --purge linux-image-Y.Y.Y-YYY-generic linux-image-extra-Y.Y.Y-YYY-generic linux-signed-image-Y.Y.Y-YYY-generic
sudo apt-get -f install
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge
Related videos on Youtube
Philip Howard
Updated on September 18, 2022Comments
-
Philip Howard over 1 year
I got an error message explaining my /boot is full. trying to clean up old image files always seems to fail because of disk full errors or dependency errors. Could someone explain where I’m going wrong.
$ sudo apt-get autoremove Reading package lists... Done Building dependency tree Reading state information... Done You might want to run ‘apt-get -f install’ to correct these. The following packages have unmet dependencies. linux-image-extra-3.13.0-44-generic : Depends: linux-image-3.13.0-44-generic but it is not installed linux-image-extra-3.13.0-45-generic : Depends: linux-image-3.13.0-45-generic but it is not installed linux-image-generic : Depends: linux-image-3.13.0-45-generic but it is not installed E: Unmet dependencies. Try using -f. $ ls /boot abi-3.13.0-32-generic initrd.img-3.13.0-43-generic abi-3.13.0-36-generic lost+found abi-3.13.0-37-generic memtest86+.bin abi-3.13.0-39-generic memtest86+.elf abi-3.13.0-40-generic memtest86+_multiboot.bin abi-3.13.0-43-generic System.map-3.13.0-32-generic config-3.13.0-32-generic System.map-3.13.0-36-generic config-3.13.0-36-generic System.map-3.13.0-37-generic config-3.13.0-37-generic System.map-3.13.0-39-generic config-3.13.0-39-generic System.map-3.13.0-40-generic config-3.13.0-40-generic System.map-3.13.0-43-generic config-3.13.0-43-generic vmlinuz-3.13.0-32-generic grub vmlinuz-3.13.0-36-generic initrd.img-3.13.0-32-generic vmlinuz-3.13.0-37-generic initrd.img-3.13.0-36-generic vmlinuz-3.13.0-39-generic initrd.img-3.13.0-37-generic vmlinuz-3.13.0-40-generic initrd.img-3.13.0-39-generic vmlinuz-3.13.0-43-generic initrd.img-3.13.0-40-generic
I used
kernelver=$(uname -r | sed -r 's/-[a-z]+//') dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver
to get
linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic linux-headers-3.13.0-36 linux-headers-3.13.0-36-generic linux-headers-3.13.0-37 linux-headers-3.13.0-37-generic linux-headers-3.13.0-39 linux-headers-3.13.0-39-generic linux-headers-3.13.0-40 linux-headers-3.13.0-40-generic linux-headers-3.13.0-44 linux-headers-3.13.0-44-generic linux-headers-3.13.0-45 linux-headers-3.13.0-45-generic linux-image-3.13.0-32-generic linux-image-3.13.0-36-generic linux-image-3.13.0-37-generic linux-image-3.13.0-39-generic linux-image-3.13.0-40-generic
Then picking the first image to remove
$ sudo apt-get purge linux-image-3.13.0-32-generic Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies. linux-image-extra-3.13.0-32-generic : Depends: linux-image-3.13.0-32-generic but it is not going to be installed linux-image-extra-3.13.0-44-generic : Depends: linux-image-3.13.0-44-generic but it is not going to be installed linux-image-extra-3.13.0-45-generic : Depends: linux-image-3.13.0-45-generic but it is not going to be installed linux-image-generic : Depends: linux-image-3.13.0-45-generic but it is not going to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
-
muru about 9 yearsPlease edit your question and the output of
sudo apt-get autoremove
andls /boot
. -
muru about 9 yearsTry Phrog's answer. Use the
uname -r
command to find out your current kernel version, and try removing a kernel other than that.
-
-
Philip Howard about 9 yearsHi when I try to remove them I get an error sudo dpkg --force-all -P abi-3.13.0-32-generic dpkg: warning: ignoring request to remove abi-3.13.0-32-generic which isn't installed
-
NickTux about 9 yearsI edited the answer, because of a typo. You need to remove the package. The abi-3.13.0-32-generic is not the package name. Instead use
linux-image-3.13.0-32-generic
. Use the same naming for other images. -
mdunsmuir over 7 yearsThis worked for me, with one modification: after removing kernel images with
dpkg
, I had to runsudo apt-get -f autoremove
to getapt-get
to stop complaining about unmet dependencies. Otherwise,sudo apt-get -f install
apparently kept trying to re-install all the kernel images I'd removed withdpkg
, which obviously just filled up/boot
again. -
NKijak over 6 yearsAfter force purging and the
apt-get -f autoremove
in @mdunsmuir comment above, it still wants to install all the old kernels during any of the clean up operations above. Is there a way to just tell it to ignore unrelated dependencies and remove a single, complete old kernel? -
Ghostkeeper about 6 yearsI'd like to add that I also had to uninstall the extras with
sudo dpkg --force-all -P linux-image-extra-3.13.0-32-generic
. Otherwise these extras still depend on the actual image and the-f
flag would cause the image to be reinstalled and then running out of disk space. -
Hemant Thorat almost 6 yearsIf it still gives you boot disk space error for installing/uninstalling files then directly remove one of old image from /boot directory, ls -lh /boot/*-3.13.0-119*; rm /boot/*-3.13.0-119*; NOTE: Please review current kernel image again before deleting any image.
-
Lonnie Best over 5 yearsThis is stupid. When ubuntu auto-updates these kernels, it should always delete everything except the last two kernels automatically. Otherwise, if you leave a sever alone for too long, it will fill up with this garbage and even after you remove a kernel it reinstalls during autoremove (due to unmet dependencies)! Totally stupid defaults.
-
Franklin Yu over 5 years@LonnieBest I agree. In contrast, Arch Linux keeps only one fallback. Neither does Fedora seem to have this issue.
-
Bok over 5 yearsThis method worked for me.
-
Matiss almost 5 yearsStill complains that it have unmet dependancies