1

The production server I'm using has a /boot partition of 400MB. And every once in a while if I want to install something from repositories, it tells me that it cannot do that because there is No space left on device

I cannot change the server configuration, because I'm not the owner.

I have seen some tutorials (like this one) on how to delete the old kernel packages. However, they all seem sketchy. I don't want to endup having a non-bootable system.

uname -r shows me:

4.15.0-30-generic

and dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' shows me:

linux-headers-4.13.0-36 linux-headers-4.13.0-36-generic
linux-headers-4.13.0-39 linux-headers-4.13.0-39-generic
linux-headers-4.13.0-41 linux-headers-4.13.0-41-generic
linux-headers-4.13.0-43 linux-headers-4.13.0-43-generic
linux-headers-4.13.0-45 linux-headers-4.13.0-45-generic
linux-headers-4.15.0-24 linux-headers-4.15.0-24-generic
linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic
linux-headers-4.15.0-65 linux-headers-4.15.0-65-generic
linux-headers-generic-hwe-16.04 linux-image-4.13.0-36-generic
linux-image-4.13.0-39-generic linux-image-4.13.0-41-generic
linux-image-4.13.0-43-generic linux-image-4.13.0-45-generic
linux-image-4.15.0-24-generic linux-image-4.15.0-29-generic
linux-image-extra-4.13.0-36-generic
linux-image-extra-4.13.0-39-generic
linux-image-extra-4.13.0-41-generic
linux-image-extra-4.13.0-43-generic
linux-image-extra-4.13.0-45-generic linux-libc-dev:amd64
linux-modules-4.15.0-24-generic linux-modules-4.15.0-29-generic

What is the best way to delete old kernel packages to free up /boot space?

Later edit:

  • Any apt-get will NOT work. It will report the same error
machineaddict
  • 123
  • 1
  • 10
  • 2
    sudo apt autoremove ? – Soren A Oct 03 '19 at 10:24
  • Most software installed from repositories goes in / and not /boot (unless you're loading additional kernels, grub-legacy etc). Are you running short of space in / as well? – guiverc Oct 03 '19 at 10:32
  • @guiverc only /boot has no space. ubuntu does fill up the /boot every ~3 months with kernels. – machineaddict Oct 04 '19 at 07:56
  • @MadMike I'm unable to run any apt or apt-get commands successfully. It's definitely not a duplicate question. Check my edit. – machineaddict Oct 04 '19 at 07:58
  • A properly setup system should have only the current & prior two kernels, however this can be overridden if holds were placed so more are kept. Check you or another admin hasn't put holds (apt-mark showhold) so old kernels aren't removed; or check changes to your setup. The best tool is sudo apt autoremove from comment 1 but it cannot override holds. – guiverc Oct 04 '19 at 07:59
  • @guiverc the apt-mark showhold shows nothing. the server is from Hetzner and this is their default setup. – machineaddict Oct 04 '19 at 08:11
  • 1
    4.13 kernels are from 17.10 (or 16.04 with HWE) so it's been left un-maintained a long time... and this is the problem. Refer https://help.ubuntu.com/community/RemoveOldKernels (the duplicate link is correct in my opinion unless left too late which I think is your problem; the Ubuntu wiki provided does have solutions for that) – guiverc Oct 04 '19 at 08:19

0 Answers0