0

I wanted to upgrade my Ubuntu 18.04 but could not do that because there is not enough space available in /boot.

The content of /boot is:

System.map-4.15.0-173-generic
System.map-4.15.0-204-generic
System.map-4.15.0-29-generic
abi-4.15.0-29-generic
config-4.15.0-173-generic
config-4.15.0-204-generic
config-4.15.0-29-generic
grub
initrd.img-4.15.0-204-generic
lost+found
retpoline-4.15.0-29-generic
vmlinuz-4.15.0-173-generic
vmlinuz-4.15.0-204-generic
vmlinuz-4.15.0-29-generic

Following How do I free up more space in /boot? I did `sudo apt purge -y linux-{image,headers}-VERSION for all VERSIONs other than the one loaded.

This indeed removed all those version, the command dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' shows:

linux-headers-4.15.0-204
linux-headers-4.15.0-204-generic
linux-image-4.15.0-204-generic

However, it did NOT remove any files from /boot - so the accepted answers for this problem did not work at all for me. Are there any alternatives?

UPDATE: the output of apt-mark showmanual | grep linux-'[g|h|m|i]' is

linux-generic
linux-headers-generic

Is it possible und safe to simple sudo rm ... the files that belong to unneded versions?

UPDATE: I started with trying sudo apt autoremove --purge which did not do anything at all.

UPDATE: output of dpkg -l | grep linux-'[g|h|i|m|e]' | cut -d ' ' -f 3 is

binutils-x86-64-linux-gnu
linux-generic
linux-headers-4.15.0-204
linux-headers-4.15.0-204-generic
linux-headers-generic
linux-image-4.15.0-204-generic
linux-image-generic
linux-image-unsigned-4.15.0-173-generic
linux-image-unsigned-4.15.0-29-generic
linux-modules-4.15.0-173-generic
linux-modules-4.15.0-204-generic
linux-modules-4.15.0-29-generic
linux-modules-extra-4.15.0-204-generic

UPDATE: output of for f in /boot/* ; do dpkg -S $f ; done | grep -v 204-generic | cut -f 1 -d ":" is :

linux-modules-4.15.0-173-generic
linux-modules-4.15.0-29-generic
linux-modules-4.15.0-29-generic
linux-modules-4.15.0-173-generic
linux-modules-4.15.0-29-generic
linux-modules-4.15.0-29-generic
linux-image-unsigned-4.15.0-173-generic
linux-image-unsigned-4.15.0-29-generic

Removing them all with for f in /boot/* ; do dpkg -S $f ; done | grep -v 204-generic | cut -f 1 -d ":" | xargs -n 1 sudo apt purge -y:

This indeed removed all the unnecessary files in /boot - thank you @user535733 who shared the relevant idea in the comments!

1

1 Answer 1

0

Solution based on the suggestion of user @user535733: remove all the packages whic still relate to the files in /boot, except those which contain the currect version string:

cur=`uname -r`
`for f in /boot/* ; do  dpkg -S $f ; done | grep -v $cur | cut -f 1 -d ":" | xargs -n 1 sudo apt purge -y` 
5
  • Not sure I do not "speak" bash, but should it not be cur='uname -r' ?
    – nobody
    Feb 19 at 10:43
  • Thanks I inserted the missing space. The quotes do indeed need to be backquotes though.
    – jpp1
    Feb 20 at 9:46
  • 1
    This is a harsh solution. In my system it would remove memtest86+ package
    – jarno
    Feb 20 at 11:27
  • @jarno - thank you for pointing this out, it could of course get prevented by filtering out anything one wants to keep using additional grep -v filters. In my case, removing it was not only not a problem, but actually necessary to free enough space to make the subsequent upgrade work.
    – jpp1
    Feb 20 at 12:27
  • Oh, I checked that memtest86+ occupies less than 1% compared to what a kernel occupies in /boot. I doubt that upgrade would have failed for that.
    – jarno
    Feb 20 at 12:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .