Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: List of kernels

  1. #1
    Join Date
    Dec 2020
    Beans
    42

    List of kernels

    Hi,

    I am quite confused regarding my installed kernels.
    I would like to know how many kernels Ubuntu has as a default number (3?).

    Code:
    dpkg --list | grep linux-image
    rc  linux-image-5.4.0-42-generic                5.4.0-42.46                          amd64        Signed kernel image generic
    rc  linux-image-5.4.0-58-generic                5.4.0-58.64                          amd64        Signed kernel image generic
    rc  linux-image-5.4.0-59-generic                5.4.0-59.65                          amd64        Signed kernel image generic
    rc  linux-image-5.8.0-34-generic                5.8.0-34.37~20.04.2                  amd64        Signed kernel image generic
    rc  linux-image-5.8.0-36-generic                5.8.0-36.40~20.04.1                  amd64        Signed kernel image generic
    rc  linux-image-5.8.0-38-generic                5.8.0-38.43~20.04.1                  amd64        Signed kernel image generic
    rc  linux-image-5.8.0-40-generic                5.8.0-40.45~20.04.1                  amd64        Signed kernel image generic
    rc  linux-image-5.8.0-41-generic                5.8.0-41.46~20.04.1                  amd64        Signed kernel image generic
    rc  linux-image-5.8.0-43-generic                5.8.0-43.49~20.04.1                  amd64        Signed kernel image generic
    rc  linux-image-5.8.0-44-generic                5.8.0-44.50~20.04.1                  amd64        Signed kernel image generic
    rc  linux-image-5.8.0-45-generic                5.8.0-45.51~20.04.1+1                amd64        Signed kernel image generic
    rc  linux-image-5.8.0-48-generic                5.8.0-48.54~20.04.1                  amd64        Signed kernel image generic
    ii  linux-image-5.8.0-49-generic                5.8.0-49.55~20.04.1                  amd64        Signed kernel image generic
    ii  linux-image-5.8.0-50-generic                5.8.0-50.56~20.04.1                  amd64        Signed kernel image generic
    ii  linux-image-generic-hwe-20.04               5.8.0.50.56~20.04.34                 amd64        Generic Linux kernel image
    Is this list of all my installed kernels (mean - take space of HDD)? If yes, than to me it looks too much.
    I guess, three would be enough.
    I do not have any problems with 5.8 ver, so one 5.4 and two 5.8 would do a thing, am I right?

    Also, I though that command "apt-get autoremove" does remove all of the kernels apart from last 3 (or 5?). But it did not. I ran a command couple of times and still the list looks like above.
    Anyone could help me with that mess?

  2. #2
    Join Date
    May 2008
    Beans
    3,983
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: List of kernels

    Have a close look at the beginning of each line of your output.

    rc= removed (some configuration files remain)
    ii = installed

    Here is another way to find installed kernels:-
    Code:
    ls /boot | grep vmlinuz-

  3. #3
    Join Date
    Apr 2011
    Location
    Mystletainn Kick!
    Beans
    13,615
    Distro
    Ubuntu

    Re: List of kernels

    The only installed kernels are the one listed as ii.
    All rc listings mean no kernel installed, however their are still leftover config files on the system.
    You can clear those out with a quick one-liner like this
    Code:
    dpkg -l | awk '/^rc/{print $2}' | xargs sudo apt purge -y
    The autoremove command works like the remove command, as it removes packages but doesn't remove config files.
    The alternative purge command does remove those so
    Code:
     sudo apt remove <package>
    removes the package but keeps configs,
    and
    Code:
    sudo apt purge <package>
    removes the package and removes all related configs.
    and
    Code:
    sudo apt autoremove
    removes just like remove does, and also leaves configs like remove does.
    but
    Code:
    sudo apt autoremove --purge
    will remove the packages and any leftover configs.

    hope that helps.
    Splat Double Splat Triple Splat
    Earn Your Keep
    Don't mind me, I'm only passing through.
    Once in a blue moon, I'm actually helpful
    .

  4. #4
    Join Date
    May 2008
    Beans
    3,983
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: List of kernels

    Quote Originally Posted by deadflowr View Post
    You can clear those out with a quick one-liner like this
    Code:
    dpkg -l | awk '/^rc/{print $2}' | xargs sudo apt purge -y
    I like this one - very succinct

  5. #5
    Join Date
    Apr 2011
    Location
    Mystletainn Kick!
    Beans
    13,615
    Distro
    Ubuntu

    Re: List of kernels

    Quote Originally Posted by tea for one View Post
    I like this one - very succinct
    I kind of modified it from what I learned from this: http://tuxtweaks.com/2010/10/remove-...h-one-command/
    I found I could drop specific package listings (like dpkg -l linux*) and just list everything with plain empty dpkg -l, and I could simply replace the ^ii with ^rc and cut out the running kernel section, more or less.

    For what it's worth there are plenty of ways to remove old kernels.
    autoremove is simply the easiest, most of the time.
    I ran the commands in the link once upon a time, before autoremove could remove kernels,; it hasn't always been the case.
    Then I discovered purge-old-kernels which was in the bikeshed package, but has since been moved into the byobu package.
    DougS also found another option he posted here about: https://ubuntuforums.org/showthread....4#post14003294.
    I think he posted a better more thorough description somewhere else, but I'm not gonna dig for it.

    Oh, and of course their is always the old standby of manually typing in the full names of each kernel to remove.
    (But who would ever need to do that, right?)
    Splat Double Splat Triple Splat
    Earn Your Keep
    Don't mind me, I'm only passing through.
    Once in a blue moon, I'm actually helpful
    .

  6. #6
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: List of kernels

    I have to admit that I prefer to do things in a more manual way because I prefer to keep a very close eye on all updates and upgrades, including kernels.

    I have also occasionally found that the autoremove command wants to remove a few packages that I have installed as they were needed by something I have installed from a source other than the standard repos, eg get-iplayer where the repository version did not work well, or didn't work at all.

    I use terminal to update with aliases in my ~/.bash_aliases of
    Code:
    alias ud='sudo apt update && apt list --upgradable'
    alias ug='sudo apt full-upgrade'
    The first checks repos and then lists every package that will be upgraded so I can quickly see if a new kernel is coming; the second carries out the upgrade.
    If a new kernel is coming I will run
    Code:
    sudo apt autoremove --purge -s
    This shows all packages that will be purged when I run it again without the -s option (simulate), allowing me to ensure that nothing I want to keep is to be removed.

    Finally if I need to remove a older unneeded kernel version I first check those installed with ls /boot | grep vmlinuz as shown by tea for one above and then remove the unwanted version of the three with, for example sudo apt purge *5.4.0-70* which will also remove the no longer needed header and tools packages of the same version.

    This may all sound complicated but I'm so used to doing it that it is much quicker than any other method that I have used in the past and it means I have full and total control of everything.

  7. #7
    Join Date
    Apr 2011
    Location
    Mystletainn Kick!
    Beans
    13,615
    Distro
    Ubuntu

    Re: List of kernels

    Then I discovered purge-old-kernels which was in the bikeshed package, but has since been moved into the byobu package.
    I guess purge-old-kernels has been deprecated in the latest releases: https://bugs.launchpad.net/ubuntu/+s...u/+bug/1686138

    As I posted lots of methods out there to fully remove old kernels.
    Some quick and easy and some long arduous and mildly annoying.

    FWIW,
    As far as autoremove wanting to remove other packages, you can set them with apt-mark manual <package-name> to prevent that from happening to them.
    Splat Double Splat Triple Splat
    Earn Your Keep
    Don't mind me, I'm only passing through.
    Once in a blue moon, I'm actually helpful
    .

  8. #8
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: List of kernels

    Quote Originally Posted by deadflowr View Post
    < SNIP >

    FWIW,
    As far as autoremove wanting to remove other packages, you can set them with apt-mark manual <package-name> to prevent that from happening to them.
    Oh boy!
    I have to say that is one of the uses of apt and autoremove that I had not caught up with; it will be extremely useful once I have noted something I want or need to keep installed.

    I should have known Linux would have a way to do something as simple(?) as that!! Many thanks deadflowr.

  9. #9
    Join Date
    Jun 2007
    Location
    Arizona U.S.A.
    Beans
    5,739

    Re: List of kernels

    If you use "unattended-upgrades" for your Security Updates, it automatically removes old kernel versions to keep 3.
    To see installed kernels, Synaptic Package Manager is helpful. You could also use Synaptic Package Manager to remove sets of old kernel packages. See this for outline of the removal method:
    https://ubuntuforums.org/showthread....4#post13853344
    Last edited by Dennis N; May 5th, 2021 at 06:08 PM. Reason: bad sentence structure.

  10. #10
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: List of kernels

    I always disable unattended upgrades as I much prefer to do things at my own time rather than the OS's choosing.

    I do use synaptic occasionally but generally only tpo search for and install packages, certainly not any more for updates and upgrades which are better done in terminal, in my opinion, using those aliases shown earlier.

    Perhaps I'm just an old fuddy-duddy (old certainly, fuddy-duddy I will leave to others to decide!) but where I can, I like to do things with as much control as is possible and not leave it all to the OS.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •