/boot is 100% full, apt-get purge linux-image-x.x.x.x-generic won't work
I have a /boot
overload.
Tried to follow /dev/sda1 /boot is full, but got stuck.
History:
df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 485360 0 485360 0% /dev
tmpfs 100744 10824 89920 11% /run
/dev/mapper/vg00-lv01 49011528 7513836 39300100 17% /
tmpfs 503716 0 503716 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 503716 0 503716 0% /sys/fs/cgroup
/dev/sda1 474730 466955 0 100% /boot
dpkg --list | grep linux-image
ii linux-image-4.4.0-21-generic 4.4.0-21.37 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-59-generic 4.4.0-59.80 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-62-generic 4.4.0-62.83 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-63-generic 4.4.0-63.84 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-64-generic 4.4.0-64.85 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-66-generic 4.4.0-66.87 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-67-generic 4.4.0-67.88 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-70-generic 4.4.0-70.91 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-71-generic 4.4.0-71.92 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-4.4.0-72-generic 4.4.0-72.93 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-21-generic 4.4.0-21.37 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-59-generic 4.4.0-59.80 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-62-generic 4.4.0-62.83 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-63-generic 4.4.0-63.84 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-64-generic 4.4.0-64.85 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-66-generic 4.4.0-66.87 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-67-generic 4.4.0-67.88 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-70-generic 4.4.0-70.91 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-71-generic 4.4.0-71.92 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iF linux-image-extra-4.4.0-72-generic 4.4.0-72.93 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU linux-image-extra-4.4.0-75-generic 4.4.0-75.96 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU linux-image-generic 4.4.0.75.81 amd64 Generic Linux kernel image
!!! wow, so much, how could this happen ?
And then:
uname -r
4.4.0-21-generic
Trials to purge unused images:
apt-get purge linux-image-4.4.0-59-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-4.4.0-59-generic : Depends: linux-image-4.4.0-59-generic but it is not going to be installed
linux-image-extra-4.4.0-75-generic : Depends: linux-image-4.4.0-75-generic but it is not going to be installed
linux-image-generic : Depends: linux-image-4.4.0-75-generic but it is not going to be installed
Recommends: thermald but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Anyone got an idea?
Solution 1:
Removing old kernels to free space in /boot
partition
If your system is running using an old kernel (usually the newest kernel boots by default) you should boot from the newest kernel installed, which seems to be linux-image-4.4.0-72-generic
in your case.
Select it from the GRUB menu (hold or repeatedly press Shift during boot if GRUB doesn't show at all).
When you have booted from your newest kernel, first run sudo apt-get -f install
, trying to fix the unmet dependencies issues, if it works go on with any of the first two method below; if it fails jump to manual package purge.
The apt way
Try to correctly manage the space issue with apt:
- Run
sudo apt autoclean && sudo apt autoremove
, apt should correctly manage removing all old-kernels and related packages if you haven't messed too much with it.
Using purge_old_kernels from byobu package
If the apt way doesn't work or it doesn't remove enough space:
- Install byobu running
sudo apt install byobu
. - Then run
sudo purge-old-kernels
, which should remove old kernels in a cleaner way than directly purging packages.
Manual package purge
If any oh the above worked:
- Purge the oldest (not running) kernel with
sudo apt-get purge linux-image-4.4.0-21-generic && sudo update-grub
. - Reboot and boot from the newest kernel available.
- Run
sudo apt-get -f install
. - Run
sudo apt update && sudo apt full-upgrade
. - Reboot using your newest kernel.
- Clean older kernels, via The apt way and/or _purge_old_kernels_.
The dpkg way
As a last resort, you can try to do it in the dpkg
way which isn't the safest.
-
Run from your terminal (running from your newest installed kernel):
echo $(dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p') $(dpkg --list | grep linux-headers | awk '{ print $2 }' | sort -V | sed -n '/'"$(uname -r | sed "s/\([0-9.-]*\)-\([^0-9]\+\)/\1/")"'/q;p') | xargs sudo apt-get -y purge
Borrowed from this response.
Reboot your system and run
sudo apt-get -f install
- Do a full upgrade with
sudo apt update && sudo apt full-upgrade
. - Reboot if needed (new kernel¿?) and go with the apt way:
sudo apt autoclean && sudo apt autoremove
. - Run
sudo purge_old_kernels
, command frombyoby
package if still remains any old kernel version (in addition to the current and previous version which are always kept as a safety precaution).
Solution 2:
If /boot
is so full that apt remove
doesn't work (No space left on device
), just rm
some files (vmlinuz
or initrd.img
) belonging to the kernels you want to remove to free up enough space so you can then properly apt remove
the packages. Of couse, as always when running rm
as root, be extra careful for typos, etc., but even if you accidentally rm
a file from a kernel you didn't want to remove, a simple apt install --reinstall
will fix it.
Contrary to a common misconception, there is absolutely no problem with doing that, as anybody could see if they actually tried it instead of just repeating things they have heard. (In particular, I often read that doing so would result in "broken packages". No, that's not what broken packages means.)