5

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?

Zanna
  • 70,465
Manny
  • 75
  • apt queues actions, which requires space to work. Use dpkg to remove a kernel or two, freeing the overhead apt needs. Then use apt to clean up. – user535733 Apr 29 '17 at 16:42
  • Please note that the output of 'uname -r' indicates that you are running on an older version of the kernel (4.4.0-21). After you have freed a little space on '/boot', you should boot into a newer kernel and use 'sudo apt autoclean && sudo apt autoremove' – Charles Green Apr 29 '17 at 17:04

2 Answers2

10

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 from byoby package if still remains any old kernel version (in addition to the current and previous version which are always kept as a safety precaution).
Zanna
  • 70,465
dgonzalez
  • 7,010
  • 6
  • 19
  • 28
  • Hey, wow, many thanks for your advice, all of you! – Manny Apr 30 '17 at 08:37
  • I am trying: apt autoclean && sudo apt autoremove

    It gives: link

    and /boot is still 100%

    Boyu won't install : link

    I stop moving from here, so that I avoid putting too much mess and you guys may suggest the next moves.

    Thanks

    – Manny Apr 30 '17 at 08:44
  • @Manny I updated my answer with some dirtier alternatives. Be careful and always remember to keep a backup of your important data. – dgonzalez Apr 30 '17 at 17:05
  • Tks. First command gives : https://pastebin.com/pL01FGDd Looks like bad news (?) – Manny Apr 30 '17 at 18:26
  • @Manny What's your sudo apt-get -f install output¿? – dgonzalez Apr 30 '17 at 19:43
  • Here it is : https://pastebin.com/1Msx9Qq2 – Manny May 01 '17 at 14:59
  • I think you are still booting from your older kernel version 4.4.0-21, try to boot from a newer kernel first, maybe 4.4.0-72 and try to start from there, if you have no luck, it may be worth doing a fresh install... – dgonzalez May 01 '17 at 15:31
  • Editing /boot/grub/grub.cfg ? File starts with '### BEGIN /etc/grub.d/00_header ### if [ -s $prefix/grubenv ]; then set have_grubenv=true load_env fi if [ "${next_entry}" ] ; then set default="${next_entry}" set next_entry= save_env next_entry set boot_once=true else set default="0" fi' I'm sorry but I do not see where to edit and how :/ – Manny May 01 '17 at 15:52
  • Ok I've tried removing mannualy one image in /boot and gor 96% space. Tks @user535733 Then I tried back dgonzalez approach, still failing but a bit better. https://pastebin.com/aD6EdRfK I'm using a console form my laptop, with ssh connexion, holding shift to choose the image from grub display does not work : no grub display appears... – Manny May 01 '17 at 17:34
  • 1
    Got it !

    I was most reluctant to removing content in /boot But you can (and in that case must) remove images that are not booted on.

    When this is done apt-get -f install and apt autoclean && apt autoremove perfectly do the job.

    Thanks again for helping, folks.

    – Manny May 05 '17 at 13:02
  • @Manny I'm glad to read that you could avoid doing a fresh install! Keep on rocking! – dgonzalez May 05 '17 at 19:20
  • 1
    Many many thanks, really. Precious are words when you are alone face to a machine :) – Manny May 08 '17 at 17:43
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.)

fkraiem
  • 12,555
  • 4
  • 35
  • 40