Announcement

Collapse
No announcement yet.

Question about upgrade and autoremove in the terminal

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Question about upgrade and autoremove in the terminal

    I've always wondered about this but never got around to asking the question. So here goes...

    My example comes from Kubuntu 26.04. The behavior is the same in Kubuntu 26.10 and other versions I have tried recently to my memory.

    I update Kubuntu in the terminal 'sudo apt update' followed by 'sudo apt full-upgrade'

    The first time running 'sudo apt update' followed by 'sudo apt full-upgrade'.
    The kernel and modules are updated

    I reboot.

    The second time running 'sudo apt update' followed by 'sudo apt full-upgrade' the following are removed:
    REMOVING:
    linux-headers-7.0.0-38-generic linux-main-modules-zfs-7.0.0-38-generic linux-modules-nvidia-580-7.0.0-38-generic linux-signatures-nvidia-7.0.0-38-generic
    linux-image-7.0.0-38-generic linux-modules-7.0.0-38-generic linux-objects-nvidia-580-7.0.0-38-generic linux-tools-7.0.0-38-generic

    I reboot.

    When I run 'sudo apt autoremove', the following are removed:
    REMOVING:
    linux-headers-7.0.0-38 linux-tools-7.0.0-38

    Is there a reason why everything, kernel headers, image, ...etc. are not removed all at once the next time I run sudo apt full-upgrade or sudo apt autoremove?​
    OS: Kubuntu 26.04 LTS
    Desktop: Dell XPS 8900
    GPU: NVIDIA GeForce GTX 745

    #2
    Hmm... good question. Maybe the headers are needed to decompile something, a kernel module, perhaps?
    Try this: Manually uninstall the kernel, including the headers. What I mean is, when `autoremove` tries to remove the kernel but not the headers, run `apt remove` to remove the kernel and the headers together. Does the system allow that?
    If yes, it wouldn't make sense for the system to not remove the headers right away with the first autoremove.​

    Comment


      #3
      this is normal APT behaviour. It can happen because of package dependencies and the order in which packages become unused.
      The main kernel packages are removed during the next full-upgrade. Once those packages are gone, some related packages, such as:
      linux-headers-7.0.0-38
      linux-tools-7.0.0-38
      may then become orphaned — meaning nothing installed requires them anymore. They are consequently picked up the next time sudo apt autoremove is run.
      So APT isn't necessarily forgetting them. Removing one group of packages can make another group eligible for autoremove.​
      ▁ ▂ ▄ ▅ ▆ ▇ █ ᄂIПЦX FӨЯ ᄂIFΣ █ ▇ ▆ ▅ ▄ ▂ ▁

      Comment


        #4
        Ubuntu configures apt to keep 3 kernel versions, and uninstalls the extra when there is a new one. This is not an auto remove operation.

        I can't say why it isn't set to uninstall *all* the peripheral packages, but it may be that not everyone has all of these present, or they can be of use in some cases outside of actually running the associated kernel version.
        Self-built: Asus PRIME B550M-K/Ryzen 5600GT/32Gb/Intel ARC B580 12Gb/KDE neon
        HP Elitedesk 800 G3 Mini: i5-7500T(35w)/32Gb/Kubuntu LTS
        HP Chromebook 14: i5-1135G7/8Gb/512Gb SSD/KDE Linux​

        Comment


          #5
          Thankyou all for the replies. It makes sense to me now.

          I tried mixing up the order to see what I get.

          Here I tried autoremove right after updating the kernels and rebooting:
          Code:
          $ sudo apt autoremove
          [sudo: authenticate] Password:
          REMOVING:
          linux-headers-7.0.0-28 linux-image-7.0.0-28-generic linux-modules-7.0.0-28-generic linux-tools-7.0.0-28-generic
          linux-headers-7.0.0-28-generic linux-main-modules-zfs-7.0.0-28-generic linux-tools-7.0.0-28
          
          Summary:
          Upgrading: 0, Installing: 0, Removing: 7, Not Upgrading: 4
          Freed space: 319 MB
          
          Continue? [Y/n] n
          Abort.
          $
          Here I tried full-upgrade before autoremove immediately after updating the kernels and rebooting:
          Code:
          $ sudo apt full-upgrade
          The following packages were automatically installed and are no longer required:
          linux-headers-7.0.0-28 linux-tools-7.0.0-28
          Use 'sudo apt autoremove' to remove them.
          
          Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
          libtesseract5 libsrt1.5-gnutls libass9 libavdevice62 ffmpeg
          libopenexr-3-1-30 libavcodec62 gocryptfs libavfilter11 libavutil60
          libswscale9 libswresample6 libavformat62 tesseract-ocr libde265-0
          Learn more about Ubuntu Pro at https://ubuntu.com/pro
          Not upgrading yet due to phasing:
          drkonqi python3-software-properties software-properties-common software-properties-qt
          
          REMOVING:
          linux-headers-7.0.0-28-generic linux-image-7.0.0-28-generic linux-main-modules-zfs-7.0.0-28-generic linux-modules-7.0.0-28-generic linux-tools-7.0.0-28-generic
          
          Summary:
          Upgrading: 0, Installing: 0, Removing: 5, Not Upgrading: 4
          Freed space: 220 MB
          
          Continue? [Y/n] n
          Abort.
          $
          This all makes sense now.

          This is the list of installed kernels before the next update or autoremove after new kernels are installed:
          Code:
          $ apt list --installed | grep linux-image
          
          WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
          
          linux-image-7.0.0-28-generic/resolute-updates,resolute-security,now 7.0.0-28.28 amd64 [installed,auto-removable]
          linux-image-7.0.0-31-generic/resolute-updates,resolute-security,now 7.0.0-31.31 amd64 [installed,automatic]
          linux-image-7.0.0-43-generic/resolute-updates,now 7.0.0-43.43 amd64 [installed,automatic]
          linux-image-generic/resolute-updates,now 7.0.0-43.43 amd64 [installed,automatic]
          $
          This is the list of installed kernels after the next update or autoremove before new kernels are installed:
          Code:
          $ apt list --installed | grep linux-image
          
          WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
          
          linux-image-7.0.0-42-generic/resolute-updates,resolute-security,now 7.0.0-42.42 amd64 [installed,automatic]
          linux-image-7.0.0-43-generic/resolute-updates,now 7.0.0-43.43 amd64 [installed,automatic]
          linux-image-generic/resolute-updates,now 7.0.0-43.43 amd64 [installed,automatic]
          $
          Ubuntu keeps three kernels with the oldest marked [installed,auto-removable] if I don't run autoremove before the next update.

          ​
          OS: Kubuntu 26.04 LTS
          Desktop: Dell XPS 8900
          GPU: NVIDIA GeForce GTX 745

          Comment

          Users Viewing This Topic

          Collapse

          There are 0 users viewing this topic.

          Working...
          X