1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Ubuntu /boot/ filling up, old kernels issue help

Discussion in 'Linux & Open Source' started by bledd, Oct 10, 2019.

  1. bledd

    Don

    Joined: Oct 21, 2002

    Posts: 46,495

    Location: Parts Unknown

    Hi,


    I have a Ubuntu 18.04.3 LTS install (which has been upgraded from around 12.04. /boot/ keeps filling up and shows old kernels

    dpkg -l | grep linux-image

    Shows..

    [​IMG]

    How do I go about fixing this? I assume I need to take out the grub entries, then remove the files.

    Cheers
     

    Attached Files:

  2. Steveocee

    Soldato

    Joined: Nov 5, 2011

    Posts: 5,152

    Location: Derbyshire

    apt autoremove ? Always did the trick for me in previous versions, no grub editing needed.
     
  3. SMN

    Wise Guy

    Joined: Nov 2, 2008

    Posts: 2,444

    Location: The ether

    I've found ubuntu generally does a rubbish job at cleaning up /boot, i regularly have to manually remove old kernels from /boot before running 'apt-get -f install' or the 'dpkg reconfigure' command (i forget the syntax).

    OP, if 'apt autoremove' fails, you can do an ls in /boot and find the old kernels and delete them all except the one your on now (uname -r) and potentially another, just for safety. Then run 'apt-get update' and follow the trail :)
     
  4. Bagnaj97

    Associate

    Joined: Sep 5, 2013

    Posts: 13

    This just prompted me to tidy up a couple of machines, here's what I came up with:

    Code:
    dpkg -l | grep 'ii  linux-image\|ii  linux-headers\|ii  linux-modules\|ii  linux-tools' | cut -d ' ' -f3 | grep -v `uname -r | cut -d '-' -f1-2` | grep '[0-9]' > oldKernels && sudo apt remove `cat oldKernels`
    List available packages (dpkg -l)
    Filter down to the target packages, that are also installed (grep 'ii linux-image\|ii linux-headers\|ii linux-modules\|ii linux-tools')
    Chop the line up and just get the package name (cut -d ' ' -f3)
    Filter out the packages for the currently running kernel (grep -v `uname -r | cut -d '-' -f1-2`)
    Filter down to packages containing numbers to exclude linux-image-generic etc (grep '[0-9]')

    Finally redirect the list of packages to a file and uninstall them.
    This worked for me, but check the list of packages carefully before pressing y!
     
  5. memyselfandi

    Sgarrista

    Joined: Oct 10, 2005

    Posts: 8,570

    Location: Nottingham

    apt autoremove works just fine for me on both Ubuntu 16.x and 18.x

    Or on CentOS something like package-cleanup assuming your max number of installed kernels is set higher than you actually want (fix that as well)
     
  6. uvarvu

    Mobster

    Joined: Apr 29, 2004

    Posts: 3,925

    Location: Bath

    I run dpkg --purge to make sure anything residual is removed.
     
  7. bledd

    Don

    Joined: Oct 21, 2002

    Posts: 46,495

    Location: Parts Unknown

    Was going around in circles.

    Ended up just doing this.