Announcement

Collapse
No announcement yet.

How to keep a few kernels for back up purposes?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    I'm not quite convinced. If you look at https://help.ubuntu.com/community/RemoveOldKernels you'll see that unattended-upgrades, which is installed by default, is going to purge old kernels for you, by default, but they must be marked as automatically installed.
    Incorrect. it IS installed, but needs to be configured manually to enable automatic pruning of old kernels..
    The second step is to edit old configuration file to enable automatic removal, or preferably create an overriding new configuration file where you need to write only options that you change from the default or from the values defined in the shipped one
    But yes, I agree with jglen something is amiss on your system.

    Comment


      #17
      Originally posted by claydoh View Post
      Incorrect. it IS installed, but needs to be configured manually to enable automatic pruning of old kernels..
      Again, from https://help.ubuntu.com/community/RemoveOldKernels:
      In Ubuntu 16.04 and later unattended-upgrades is enabled by default
      Version 1.1 that is also currently available for Ubuntu 16.04 adds yet another option called Unattended-Upgrade::Remove-Unused-Kernel-Packages. It removes unused kernel packages before installing new one (or even if nothing is installed). It is enabled by default, too.
      In fact, as I said, some kernels were removed from my system automatically, some other didn't.

      Originally posted by jglen490
      I do the sudo apt autoremove, and etc., sequence after a new kernel is installed. [...] I do not ever manually install kernels; they are only the result of the sudo apt update and sudo apt full-upgrade sequence.
      Indeed, this should work. What I see, however, is that if you install a kernel update through the Discover update manager, then those kernels are not removed, because they are marked as manually installed. This is inconvenient, because I often do an "update all" from Discover after receiving the update notification and checking for what is available.

      Comment


        #18
        Like I said, I only update/upgrade my system via apt.

        I DONOT use Discover for any purpose other than poking around and regretting going to that piece of junk, again. I'm sorry if a Discover dev runs across this post, nothing personal, I've never found Discover to be useful, beyond the fact that notices appear from time to time in the tray that updates are available. And, again, at that point I go to my open konsole and run the apt commands.
        The next brick house on the left
        Intel i7 11th Gen | 16GB | 1TB | KDE Plasma 5.27.11​| Kubuntu 24.04 | 6.8.0-31-generic



        Comment


          #19
          Originally posted by mauromol View Post
          My problem was that all the installed kernels where marked as MANUALLY INSTALLED:
          Code:
          [FONT=monospace][COLOR=#54ff54][B]mauro@hppb[/B][/COLOR][COLOR=#5454ff][B]~ $[/B][/COLOR][COLOR=#000000] apt-mark showauto 'linux-image-.*' [/COLOR]
          linux-image-generic 
          [COLOR=#54ff54][B]mauro@hppb[/B][/COLOR][COLOR=#5454ff][B]~ $[/B][/COLOR][COLOR=#000000] apt-mark showmanual 'linux-image-.*' [/COLOR]
          linux-image-5.4.0-54-generic 
          linux-image-5.4.0-56-generic 
          linux-image-5.4.0-58-generic 
          linux-image-5.4.0-59-generic 
          linux-image-5.4.0-62-generic 
          linux-image-5.4.0-64-generic 
          linux-image-5.4.0-65-generic
          [/FONT]
          That's interesting, as the same thing seemed to happen to me starting from the kernel image 5.4.0-54:

          Code:
          TRobo@desktop:~$ apt-mark showauto 'linux-image-.*'
          linux-image-generic
          TRobo@desktop:~$ apt-mark showmanual 'linux-image-.*'
          linux-image-5.4.0-54-generic
          linux-image-5.4.0-58-generic
          linux-image-5.4.0-59-generic
          linux-image-5.4.0-60-generic
          linux-image-5.4.0-62-generic
          linux-image-5.4.0-64-generic
          linux-image-5.4.0-65-generic
          Also, looking at
          Code:
          /etc/apt/apt.conf.d/01autoremove-kernels
          I had:

          Code:
          [FONT=monospace][COLOR=#000000]rc   linux-image-5.4.0-42-generic                                5.4.0-42.46                                  amd64        Signed kernel image  generic [/COLOR]
          rc  linux-image-5.4.0-48-generic                                 5.4.0-48.52                                 amd64        Signed kernel  image generic 
          rc  linux-image-5.4.0-51-generic                                 5.4.0-51.56                                 amd64        Signed kernel  image generic 
          rc  linux-image-5.4.0-52-generic                                 5.4.0-52.57                                 amd64        Signed kernel  image generic 
          rc  linux-image-5.4.0-53-generic                                 5.4.0-53.59                                 amd64        Signed kernel  image generic 
          rc  linux-image-5.4.0-60-generic                                 5.4.0-60.67                                 amd64        Signed kernel  image generic 
          ii  linux-image-5.4.0-62-generic                                 5.4.0-62.70                                 amd64        Signed kernel  image generic 
          ii  linux-image-5.4.0-64-generic                                 5.4.0-64.72                                 amd64        Signed kernel  image generic 
          iF  linux-image-5.4.0-65-generic                                 5.4.0-65.73                                 amd64        Signed kernel  image generic 
          ii  linux-image-generic                                          5.4.0.65.68                                 amd64        Generic Linux  kernel image
          [/FONT]
          So, some kernel versions were indeed automatically pruned in the past (those marked with "rc"), but other are missing there and indeed they were marked as "manually installed".
          Same for me, going right back to kernel image 4.18.0-10 (my system started as a Kubuntu 18.10 installation, but I stayed with 20.04 LTS once I got to that point). I do have one later kernel image 5.4.0-56) that has been removed since 5.4.0-54 was installed though (maybe I did the update to install that one via the command line):

          Code:
          [FONT=monospace][COLOR=#000000]rc   linux-image-5.3.0-62-generic                  5.3.0-62.56                                  amd64        Signed kernel image generic [/COLOR]
          rc  linux-image-5.4.0-40-generic                  5.4.0-40.44                                  amd64        Signed kernel image  generic 
          ii  linux-image-5.4.0-54-generic                  5.4.0-54.60                                  amd64        Signed kernel image generic 
          rc  linux-image-5.4.0-56-generic                  5.4.0-56.62                                  amd64        Signed kernel image generic 
          ii  linux-image-5.4.0-58-generic                  5.4.0-58.64                                  amd64        Signed kernel image generic 
          ii  linux-image-5.4.0-59-generic                  5.4.0-59.65                                  amd64        Signed kernel image generic 
          ii  linux-image-5.4.0-60-generic                  5.4.0-60.67                                  amd64        Signed kernel image generic 
          ii  linux-image-5.4.0-62-generic                  5.4.0-62.70                                  amd64        Signed kernel image generic 
          ii  linux-image-5.4.0-64-generic                  5.4.0-64.72                                  amd64        Signed kernel image generic 
          iF  linux-image-5.4.0-65-generic                  5.4.0-65.73                                  amd64        Signed kernel image generic 
          ii  linux-image-generic                           5.4.0.65.68                                  amd64        Generic Linux kernel image
          [/FONT]
          I'm pretty sure the problem lies here: some kernel version were automatically installed by unattended-upgrades (and these where automatically purged), some others were installed by me by hitting "update all" button in Discover, when it periodically notifies me about new updates.
          Most of mine have been installed via Discover. I had changed the "Automatic updates" setting under "Software Sources -> Updates" to "Only notify about available updates" since I didn't like unattended-upgrades doing updates in the background at times that were inconvenient to me.

          So, I suspect such a "bug" is still present in Kubuntu 20.04 Discover, which marks all kernels installed through it as "manually installed". Is this a known problem?
          I didn't seem to have an issue until that 5.4.0-54 image was pushed out, so I doubt that it was a longstanding bug with Discover, however perhaps something else also changed around that time. I tend to agree with your observation (and the advice on https://help.ubuntu.com/community/RemoveOldKernels) that if the installations were marked as having been "manually" installed then using "sudo apt autoremove --purge" won't remove them later unless they are marked as auto first. I haven't tried that yet as I will wait to see how the next kernel image update is marked if I do the update via the command line instead of using Discover. Thanks for pointing that out to me as I was wondering why those old kernel images could not be removed via "autoremove".

          Comment


            #20
            So don't use Discover to install kernels. It marks them as "manual", and autoremove does not remove kernels installed as "manual". The logic is inescapable.

            Now, you CAN argue that Discover is doing something wrong. I would not disagree with that. I don't use Discover for anything, except notifications; and notifications are not the same as Autoinstall.
            The next brick house on the left
            Intel i7 11th Gen | 16GB | 1TB | KDE Plasma 5.27.11​| Kubuntu 24.04 | 6.8.0-31-generic



            Comment


              #21
              Originally posted by TRobo View Post
              That's interesting, as the same thing seemed to happen to me starting from the kernel image 5.4.0-54:
              I just opened a dedicated bug report on Launchpad as well: https://bugs.launchpad.net/ubuntu/+s...r/+bug/1914932
              I would suggest you to watch it and add your feedback there as well.
              KDE developers redirected to PackageKit, so another report to watch is: https://github.com/hughsie/PackageKit/issues/450

              I hope we can get to this problem to be resolved in one way or the other.

              Comment


                #22
                Originally posted by TRobo View Post
                That's interesting, as the same thing seemed to happen to me starting from the kernel image 5.4.0-54:
                I've opened https://bugs.launchpad.net/ubuntu/+s...r/+bug/1914932
                I would suggest you to watch it and add your feedback.
                Also have a look at: https://github.com/hughsie/PackageKit/issues/450

                Comment


                  #23
                  Sorry if I posted a duplicate message, I can't go to page 3 of this thread any more... indeed, I have a lot of problems to post to this forum, a lot of database errors...

                  Comment


                    #24
                    Originally posted by mauromol View Post
                    I hope we can get to this problem to be resolved in one way or the other.
                    Thanks for the links to the bug reports. Just one question for you; did you use 'sudo apt-mark auto' in order to change the status of the linux kernel packages from manual to auto for those that were previously installed by Discover? If so, did using 'sudo apt autoremove --purge' then remove those old packages for you?

                    I tried doing this, but even once their status has been updated from manual to auto, using 'sudo apt autoremove --purge' still seems to have no effect:

                    Code:
                    [FONT=monospace][COLOR=#54ff54][B]TRobo@desktop[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ apt-mark showmanual 'linux-image-.*' [/COLOR]
                    [COLOR=#54ff54][B]TRobo@desktop[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ apt-mark showauto 'linux-image-.*'   [/COLOR]
                    linux-image-5.4.0-54-generic 
                    linux-image-5.4.0-58-generic 
                    linux-image-5.4.0-59-generic 
                    linux-image-5.4.0-60-generic 
                    linux-image-5.4.0-62-generic 
                    linux-image-5.4.0-64-generic 
                    linux-image-5.4.0-65-generic 
                    linux-image-5.4.0-66-generic 
                    linux-image-5.4.0-67-generic 
                    linux-image-generic 
                    [COLOR=#54ff54][B]TRobo@desktop[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ sudo apt autoremove --purge          [/COLOR]
                    Reading package lists... Done 
                    Building dependency tree        
                    Reading state information... Done 
                    0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
                    [/FONT]
                    It seems like there is some other flag or setting with apt (or perhaps dpkg) that means 'sudo apt autoremove --purge' still overlooks them.

                    Comment


                      #25
                      Worth noting that another tool exists, that has been mentioned here a few times here over the years - UKUU. Note that there's a free and paid version. The paid version is of course more automated, but the free one may suffice. This may be beneficial for those preferring a GUI. Lots of options, including:
                      • Keep 'X' number of kernels
                      • Use Mainline kernels only
                      • Use 'official' Ubuntu kernels only
                      • Use some combination of both
                      • Stay on the same series
                      • View kernel changelogs from within the app
                      • Automate everything


                      Normally I prefer CLI tools, but I've been using UKUU for many years now, and I'd never go back. A few bucks for the lifetime paid version is well worth it IMHO. I should point out that my personal preference is to use mainline kernels only, and start a new series only after it's been out for a few releases. I'd never go back.

                      Click image for larger version

Name:	ukuu-v19.01_369-1.png
Views:	1
Size:	35.3 KB
ID:	645098
                      ​"Keep it between the ditches"
                      K*Digest Blog
                      K*Digest on Twitter

                      Comment


                        #26
                        Originally posted by TRobo View Post
                        Just one question for you; did you use 'sudo apt-mark auto' in order to change the status of the linux kernel packages from manual to auto for those that were previously installed by Discover? If so, did using 'sudo apt autoremove --purge' then remove those old packages for you?

                        I tried doing this, but even once their status has been updated from manual to auto, using 'sudo apt autoremove --purge' still seems to have no effect:

                        <snip>

                        It seems like there is some other flag or setting with apt (or perhaps dpkg) that means 'sudo apt autoremove --purge' still overlooks them.
                        I realized the problem after reading this comment https://bugs.launchpad.net/ubuntu/+s...79/comments/38

                        Before reading that comment I had only changed the status of the linux-image* packages from manual to auto e.g. with 'sudo apt-mark auto
                        Code:
                        [FONT=monospace][COLOR=#54ff54][B]TRobo@desktop[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ sudo apt-mark auto 'linux-headers-5.4.0-54' [/COLOR]
                        linux-headers-5.4.0-54 set to automatically installed. 
                        [COLOR=#54ff54][B]TRobo@desktop[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ sudo apt-mark auto 'linux-headers-5.4.0-54-generic' [/COLOR]
                        linux-headers-5.4.0-54-generic set to automatically installed. 
                        [COLOR=#54ff54][B]TRobo@desktop[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ sudo apt-mark auto 'linux-modules-5.4.0-54-generic' [/COLOR]
                        linux-modules-5.4.0-54-generic set to automatically installed. 
                        [COLOR=#54ff54][B]TRobo@desktop[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ sudo apt-mark auto 'linux-modules-extra-5.4.0-54-generic' [/COLOR]
                        linux-modules-extra-5.4.0-54-generic set to automatically installed.
                        linux-image-5.4.0-54-generic',  but there are also other related packages that need to have their  status changed to auto as well before 'sudo apt autoremove --purge' will  remove any of them:
                        
                        
                        linux-image-5.4.0-66-generic and related packages were installed via the command line for me, so its status was already set to auto and I didn't need to change it:

                        Code:
                        [FONT=monospace][COLOR=#54ff54][B]TRobo@desktop[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ sudo apt autoremove --purge [/COLOR]
                        Reading package lists... Done 
                        Building dependency tree        
                        Reading state information... Done 
                        The following packages will be REMOVED: 
                         linux-headers-5.4.0-54* linux-headers-5.4.0-54-generic*  linux-headers-5.4.0-66* linux-headers-5.4.0-66-generic*  linux-image-5.4.0-54-generic* linux-image-5.4.0-66-generic*  linux-modules-5.4.0-54-generic* linux-modules-5.4.0-66-generic* 
                         linux-modules-extra-5.4.0-54-generic* linux-modules-extra-5.4.0-66-generic* 
                        0 to upgrade, 0 to newly install, 10 to remove and 0 not to upgrade. 
                        After this operation, 721 MB disk space will be freed. 
                        Do you want to continue? [Y/n]
                        [/FONT]
                        [/FONT]

                        Comment

                        Working...
                        X