1

This is not a duplicate as suggested above - for why, see the text below.

I have the strange situation that an "old" kernel is running (in fact it is the OLDEST): uname -r

> 4.13.0-43-generic

Using a command to show available kernels I only see NEWER kernels(!):

sudo dpkg --list 'linux-image*'|awk '{ if ($1=="ii") print $2}'|grep -v `uname -r`
linux-image-4.13.0-45-generic
linux-image-4.15.0-24-generic
linux-image-4.15.0-29-generic
linux-image-4.15.0-30-generic
linux-image-4.15.0-32-generic
linux-image-4.15.0-33-generic
linux-image-4.15.0-34-generic
linux-image-extra-4.13.0-45-generic

It looks as if the system never rebooted to "get to the new kernels" - I see for example that in the root dir:

ls -al

lrwxrwxrwx   1 root root    33 Sep 11 06:02 initrd.img -> boot/initrd.img-4.15.0-34-generic
lrwxrwxrwx   1 root root    33 Sep 11 06:02 initrd.img.old -> boot/initrd.img-4.15.0-33-generic
lrwxrwxrwx   1 root root    30 Sep 11 06:02 vmlinuz -> boot/vmlinuz-4.15.0-34-generic
lrwxrwxrwx   1 root root    30 Sep 11 06:02 vmlinuz.old -> boot/vmlinuz-4.15.0-33-generic

which kind of suggests this to me (I'm not an ubuntu guru)...

This is not a duplicate question but a new question because I have no old kernels to delete. Other answers detail deleting old kernels with version numbers less than the current kernel.

The running kernel is the oldest listed. I was worried about deleting kernels newer than the current kernel - between the current kernel and the newest and the kernel that was wanting to be installed - but blocked because of 100% full boot partition.

All answers using "apt" do not work when the boot partition is 100% full so please ignore them :)

From my original question: So I'm tempted to reboot the machine. But is this dangerous - since the boot partition is 100% full. "Normally" I'd delete old kernels etc. to free up space. What's the best/safest way to proceed here?

I ask because it seems I "should" make some space (see Will ubuntu boot if the /boot partition is full?)... but how in this particular case?


THIS IS HOW I SOLVED the problem:

In the end as apt autoremove etc. do not work in this situation I followed the hints given here:https://gist.github.com/ipbastola/2760cfc28be62a5ee10036851c654600 (See: "Case II: Can't Use apt i.e. /boot is 100% full")

In my case I deleted a newer kernel by hand to release space in /boot in order to be able to proceed:

cd /boot
ls *4.13.0-45*
rm -rf *4.13.0-45*
df -h
sudo apt-get -f install
sudo apt-get autoremove
sudo update-grub
more grub/grub.cfg
reboot

df -h shows boot no longer 100% full With more grub/grub.cfg you can check if the system is catering for the correct kernels (i.e. whether the update grub worked well)

1
  • Perhaps you could sudo apt autoremove which should remove older kernels, leave the current running kernel and the latest update. This will free space, but not fix the booting into the old kernel problem. Feb 12, 2019 at 16:36

1 Answer 1

0

Run these commands, in that order, one by one and check space every time.

sudo apt autoremove

then

sudo apt autoclean

and if not enough space yet run:

sudo apt clean

and

sudo update-grub

must work.

after reboot in new kernel confirm that the latest kernels are fully installed. by running:

uname -r

and

sudo update-initramfs -u -k all

then run

sudo apt purge $(dpkg -l|egrep 'linux-image-[0-9]|linux-headers-[0-9]'|awk '{print $3,$2}'|grep -v `uname -r|cut -f1,2 -d"-"`|sort -nr|tail -n +4|awk '{ print $2}')

this will remove all old kernels except the one you are using and the latest one.

Edit

Note: You can run sudo update-initramfs -u -k all to confirm that the latest kernels are fully installed, before all these commands.

3
  • I don't understand the purpose of the 'autoclean' step, since the following step ('clean') will delete all cached packages anyway.
    – user535733
    Feb 12, 2019 at 13:18
  • That's why I said run the commands and check. Maybe you don't need to run 'clean'.
    – Vijay
    Feb 12, 2019 at 14:08
  • 1
    Right. I think you should clarify that in the answer.
    – user535733
    Feb 12, 2019 at 14:09

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