clean out old kernel versions?
Colin Law
clanlaw at gmail.com
Sun Mar 7 17:13:47 UTC 2021
On Sun, 7 Mar 2021 at 17:05, Dave Stevens <geek at uniserve.com> wrote:
>
> $ sudo apt autoremove
> [sudo] password for user:
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> user at user-Satellite-A100 /boot $
>
> /boot $ ls -l | wc
> 440 3953 31232
> user at user-Satellite-A100 /boot $
In that case presumably apt doesn't know about them. This is a script
that I used a little time ago when I got into a similar situation.
Apparently, if you call it with -s it will do a simulation so you can
check what is going to happen. You might want to be even more
cautious and replace the last line with an echo command initially just
to make sure it looks ok.
#!/bin/sh
# removes all except latest and current running kernels
# call with -s to simulate
( \
KERNEL_HIGHEST=$(dpkg -l 'linux-image-[0-9.]*-[0-9]*-[a-zA-Z0-9]*' |
grep ^ii | awk '{print $2}' | sort -V | tail -n 1 | sed
's/^linux-image-\([0-9.]*-[0-9]*\)-.*$/\1/') ; \
KERNEL_CURRENT=$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/") ; \
sudo apt-get purge $1 $(dpkg -l 'linux-*-[0-9-]*' | grep ^ii | awk
'{print $2}' | sed "/$KERNEL_CURRENT/d;/$KERNEL_HIGHEST/d" ) ; \
)
>
>
> d
>
>
> >
> > >
> > > I could find a use for that 4.4 GB of disk space.
> > >
> > > D
> > >
> >
>
>
>
> --
> In modern fantasy (literary or governmental), killing people is the
> usual solution to the so-called war between good and evil. My books are
> not conceived in terms of such a war, and offer no simple answers to
> simplistic questions.
>
> ----- Ursula Le Guin
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
More information about the ubuntu-users
mailing list