Announcement

Collapse
No announcement yet.

Numerous linux hangovers?

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

    [SOLVED] Numerous linux hangovers?

    oshunluvr posted this code:
    Code:
    dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | grep google-chrome-stable
    to check the installed size of software.

    I modified it to grep for "linux":
    Code:
    dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | grep -i linux
    Code:
    18	linux-generic
    18	linux-headers-generic
    18	linux-image-generic
    57	linux-base
    69	linux-sound-base
    101	syslinux-legacy
    114	pptp-linux
    202	libselinux1
    354	syslinux
    1766	console-setup-linux
    3625	syslinux-common
    4538	util-linux
    11419	linux-image-5.4.0-42-generic
    11427	linux-image-5.4.0-47-generic
    11435	linux-image-5.4.0-48-generic
    11436	linux-image-5.4.0-51-generic
    11436	linux-image-5.4.0-52-generic
    11436	linux-image-5.4.0-53-generic
    11436	linux-image-5.4.0-54-generic
    11440	linux-image-5.4.0-56-generic
    11440	linux-image-5.4.0-58-generic
    11444	linux-image-5.4.0-59-generic
    11444	linux-image-5.4.0-60-generic
    11444	linux-image-5.4.0-62-generic
    11444	linux-image-5.4.0-64-generic
    11444	linux-image-5.4.0-65-generic
    11448	linux-image-5.4.0-66-generic
    14143	linux-headers-5.4.0-65-generic
    14166	linux-headers-5.4.0-66-generic
    69256	linux-headers-5.4.0-65
    69285	linux-headers-5.4.0-66
    71364	linux-modules-5.4.0-42-generic
    71474	linux-modules-5.4.0-47-generic
    71520	linux-modules-5.4.0-48-generic
    71560	linux-modules-5.4.0-51-generic
    71587	linux-modules-5.4.0-52-generic
    71587	linux-modules-5.4.0-53-generic
    71587	linux-modules-5.4.0-54-generic
    71667	linux-modules-5.4.0-56-generic
    71667	linux-modules-5.4.0-58-generic
    71702	linux-modules-5.4.0-59-generic
    71702	linux-modules-5.4.0-60-generic
    71703	linux-modules-5.4.0-62-generic
    71703	linux-modules-5.4.0-64-generic
    71721	linux-modules-5.4.0-65-generic
    71777	linux-modules-5.4.0-66-generic
    185187	linux-modules-extra-5.4.0-42-generic
    185265	linux-modules-extra-5.4.0-47-generic
    185296	linux-modules-extra-5.4.0-48-generic
    185396	linux-modules-extra-5.4.0-52-generic
    185397	linux-modules-extra-5.4.0-54-generic
    185398	linux-modules-extra-5.4.0-51-generic
    185398	linux-modules-extra-5.4.0-53-generic
    185455	linux-modules-extra-5.4.0-56-generic
    185458	linux-modules-extra-5.4.0-58-generic
    185481	linux-modules-extra-5.4.0-59-generic
    185482	linux-modules-extra-5.4.0-60-generic
    185483	linux-modules-extra-5.4.0-62-generic
    185483	linux-modules-extra-5.4.0-64-generic
    185483	linux-modules-extra-5.4.0-65-generic
    185524	linux-modules-extra-5.4.0-66-generic
    544206	linux-firmware
    I routinely run sudo apt autoremove whenever prompted, usually after a kernel update, and the system removes approximately 300+MB of "old" kernel stuff.

    So I don't know why I have so many linux-image* and linux-module* entries. AFAIK, I've not done anything out of the ordinary. By that, I mean I just use sudo apt update, sudo apt full-upgrade, and sudo apt autoremove when prompted. No messing directly with dpkg, pinning/holding packages, etc.

    I don't have dkms installed. For VMs, I use qemu/kvm.

    Questions:
    • Do others see something similar on a clean install (not upgrade) of Kubuntu 20.04?
    • Is it safe to remove carefully (no wildcards or globs) linux-image* and linux-modules* older than "5.4.0-59" (for now)?


    I don't think I'm running out of space at all! sda4 is what has Kubuntu 20.04 (root and home included).
    sda3 has Ubuntu 18.04 (preinstalled by Dell).

    Code:
    $ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            3.8G     0  3.8G   0% /dev
    tmpfs           781M  1.7M  780M   1% /run
    /dev/sda4       814G   36G  737G   5% /
    tmpfs           3.9G   56M  3.8G   2% /dev/shm
    tmpfs           5.0M  4.0K  5.0M   1% /run/lock
    tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
    /dev/sda1       846M   37M  810M   5% /boot/efi
    tmpfs           781M   16K  781M   1% /run/user/1000
    $ sudo fdisk -l
    [sudo] password for chimak: 
    Disk /dev/sda: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
    Disk model: TOSHIBA MQ04ABF1
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: gpt
    Disk identifier: CB1FDE7F-2029-4FFA-891B-302EE6EDBBFB
    
    Device         Start        End    Sectors   Size Type
    /dev/sda1       2048    1742847    1740800   850M EFI System
    /dev/sda2    1742848   12228607   10485760     5G Microsoft reserved
    /dev/sda3   12228608  218867711  206639104  98.5G Linux filesystem
    /dev/sda4  218867712 1953523711 1734656000 827.2G Linux filesystem
    $
    Last edited by chimak111; Mar 04, 2021, 12:30 AM.
    Kubuntu 20.04

    #2
    IME autoremove doesn't always work. (I wait till after a restart before running it.) When I was having various adventures with dkms it would throw autoremove off sometimes.

    Then, using muon to remove stuff usually worked, but I do recall one kernel that had large parts, one or two hundred MB, that I ended up manually deleting.
    Regards, John Little

    Comment


      #3
      Originally posted by jlittle View Post
      IME autoremove doesn't always work. (I wait till after a restart before running it.) When I was having various adventures with dkms it would throw autoremove off sometimes.

      Then, using muon to remove stuff usually worked, but I do recall one kernel that had large parts, one or two hundred MB, that I ended up manually deleting.
      Thanks! I guess I've mostly run sudo apt autoremove without waiting for a restart. And no dkms on my system. (I don't use VBox, just qemu/kvm).
      Kubuntu 20.04

      Comment


        #4
        I ran that dpkg-query command on my system and got the same list. That didn't make sense because I have only the 65 and 66 kernels installed, which a cursory inspection of /boot revealed. I suspected that the command was querying the apt archive directory, "/var/cache/apt/archives/". So, I ran "sudo apt-get clean" followed by "sudo apt-get autoclean", That emptied the archive but re-running the dpkg-query command gave the same listing.

        I ran "sudo updatedb" to renew my "locate" command database and ran "locate linux-modules-extra" and saw that essentially the same list was in "/var/lib/dpkg/info/" as well, which contains package lists, information, md5sums, etc, but no deb packages. Probably 10Mb in total. One could empty it of everything except the packages that are still installed, but there is more information in that directory than just Linux kernel stuff.

        If you are tight on disk space emptying the apt package cache will help out, but otherwise I wouldn't mess with it.
        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
        – John F. Kennedy, February 26, 1962.

        Comment


          #5
          @gg, thanks for looking into this! Please try

          Code:
          dpkg-query -Wf '${Status}\t${Package}\n' | grep -i linux
          Here's my output from the same system:
          Code:
          install ok installed	console-setup-linux
          install ok installed	libselinux1
          install ok installed	linux-base
          install ok installed	linux-firmware
          install ok installed	linux-generic
          install ok installed	linux-headers-5.4.0-65
          install ok installed	linux-headers-5.4.0-65-generic
          install ok installed	linux-headers-5.4.0-66
          install ok installed	linux-headers-5.4.0-66-generic
          install ok installed	linux-headers-generic
          deinstall ok config-files	linux-image-5.4.0-42-generic
          deinstall ok config-files	linux-image-5.4.0-47-generic
          deinstall ok config-files	linux-image-5.4.0-48-generic
          deinstall ok config-files	linux-image-5.4.0-51-generic
          deinstall ok config-files	linux-image-5.4.0-52-generic
          deinstall ok config-files	linux-image-5.4.0-53-generic
          deinstall ok config-files	linux-image-5.4.0-54-generic
          deinstall ok config-files	linux-image-5.4.0-56-generic
          deinstall ok config-files	linux-image-5.4.0-58-generic
          deinstall ok config-files	linux-image-5.4.0-59-generic
          deinstall ok config-files	linux-image-5.4.0-60-generic
          deinstall ok config-files	linux-image-5.4.0-62-generic
          deinstall ok config-files	linux-image-5.4.0-64-generic
          install ok installed	linux-image-5.4.0-65-generic
          install ok installed	linux-image-5.4.0-66-generic
          install ok installed	linux-image-generic
          deinstall ok config-files	linux-modules-5.4.0-42-generic
          deinstall ok config-files	linux-modules-5.4.0-47-generic
          deinstall ok config-files	linux-modules-5.4.0-48-generic
          deinstall ok config-files	linux-modules-5.4.0-51-generic
          deinstall ok config-files	linux-modules-5.4.0-52-generic
          deinstall ok config-files	linux-modules-5.4.0-53-generic
          deinstall ok config-files	linux-modules-5.4.0-54-generic
          deinstall ok config-files	linux-modules-5.4.0-56-generic
          deinstall ok config-files	linux-modules-5.4.0-58-generic
          deinstall ok config-files	linux-modules-5.4.0-59-generic
          deinstall ok config-files	linux-modules-5.4.0-60-generic
          deinstall ok config-files	linux-modules-5.4.0-62-generic
          deinstall ok config-files	linux-modules-5.4.0-64-generic
          install ok installed	linux-modules-5.4.0-65-generic
          install ok installed	linux-modules-5.4.0-66-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-42-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-47-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-48-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-51-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-52-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-53-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-54-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-56-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-58-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-59-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-60-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-62-generic
          deinstall ok config-files	linux-modules-extra-5.4.0-64-generic
          install ok installed	linux-modules-extra-5.4.0-65-generic
          install ok installed	linux-modules-extra-5.4.0-66-generic
          install ok installed	linux-sound-base
          install ok installed	pptp-linux
          install ok installed	syslinux
          install ok installed	syslinux-common
          install ok installed	syslinux-legacy
          install ok installed	util-linux
          Re. the files in "/var/lib/dpkg/info", there was a time I used to run "sudo apt purge" on the kernel packages suggested by "sudo apt autoremove" instead of executing "sudo apt autoremove" to clean out extra kernels. Purge would take care of the pesky leftovers in "/var/lib/dpkg/info". I've gotten lazy now.
          Last edited by chimak111; Mar 04, 2021, 10:01 PM. Reason: changed code & output!
          Kubuntu 20.04

          Comment


            #6
            Originally posted by chimak111 View Post
            Re. the files in "/var/lib/dpkg/info", there was a time I used to run "sudo apt purge" on the kernel packages suggested by "sudo apt autoremove" instead of executing "sudo apt autoremove" to clean out extra kernels. Purge would take care of the pesky leftovers in "/var/lib/dpkg/info". I've gotten lazy now.
            I'd recommend using "sudo apt --purge autoremove" when autoremoving, that will also remove the config files when autoremoving.

            To remove residual config files for "partly" uninstalled packages, you can use a script, for example (/usr/local/bin/purgerc):
            Code:
            [FONT=monospace]#!/bin/sh
            
            PCKGS=$(COLUMNS=200 dpkg -l | grep "^rc" | tr -s ' ' | cut -d ' ' -f 2)
            
            echo ${PCKGS}
            
            if [ "x${PCKGS}" != "x" ]; then
              echo "The above packages have been uninstalled, but have residual config files still on disk."
              echo "Enter your password to purge them."
              sudo apt purge ${PCKGS}
            else
              echo "No residual configs"
            fi
            exit 0
            [/FONT]
            Originally posted by GreyGeek View Post
            So, I ran "sudo apt-get clean" followed by "sudo apt-get autoclean"
            'autoclean' does nothing if you already ran 'clean', it's just a "softer" version of 'clean' (see the man pages for details).
            Last edited by kubicle; Mar 04, 2021, 11:22 PM.

            Comment


              #7
              Originally posted by kubicle View Post
              I'd recommend using "sudo apt --purge autoremove" when autoremoving, that will also remove the config files when autoremoving.
              Thanks! Looking forward to the next kernel update

              Originally posted by kubicle View Post
              To remove residual config files for "partly" uninstalled packages, you can use a script, for example (/usr/local/bin/purgerc):
              Code:
              [FONT=monospace]#!/bin/sh
              
              PCKGS=$(COLUMNS=200 dpkg -l | grep "^rc" | tr -s ' ' | cut -d ' ' -f 2)
              
              echo ${PCKGS}
              
              if [ "x${PCKGS}" != "x" ]; then
               echo "The above packages have been uninstalled, but have residual config files still on disk."
               echo "Enter your password to purge them."
               sudo apt purge ${PCKGS}
              else
               echo "No residual configs"
              fi
              exit 0
              [/FONT]
              ...
              Is [ "x${PCKGS}" != "x" ] checking whether ${PCKGS} is not empty? Then why not use [ -n "${PCKGS}" ]?

              And, instead of "COLUMNS=200 dpkg -l | grep "^rc" | tr -s ' ' | cut -d ' ' -f 2" wouldn't "dpkg -l | awk '/^rc/ {print $2}'" work just as well?
              Last edited by chimak111; Jul 23, 2021, 07:47 AM. Reason: Left out single quote; now added
              Kubuntu 20.04

              Comment


                #8
                Also check out the /lib/modules folders. Unless you use purge successfully when removing a kernel, there's lots of left over folders and files in there.

                Please Read Me

                Comment


                  #9
                  After running Kubicle's script,

                  Code:
                  No residual configs
                  $ dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | grep -i linux
                  18      linux-generic
                  18      linux-headers-generic
                  18      linux-image-generic
                  57      linux-base
                  69      linux-sound-base
                  101     syslinux-legacy
                  114     pptp-linux
                  202     libselinux1
                  354     syslinux
                  1766    console-setup-linux
                  3625    syslinux-common
                  4538    util-linux
                  11444   linux-image-5.4.0-65-generic
                  11448   linux-image-5.4.0-66-generic
                  14143   linux-headers-5.4.0-65-generic
                  14166   linux-headers-5.4.0-66-generic
                  69256   linux-headers-5.4.0-65
                  69285   linux-headers-5.4.0-66
                  71721   linux-modules-5.4.0-65-generic
                  71777   linux-modules-5.4.0-66-generic
                  185483  linux-modules-extra-5.4.0-65-generic
                  185524  linux-modules-extra-5.4.0-66-generic
                  544206  linux-firmware
                  $
                  Kubuntu 20.04

                  Comment


                    #10
                    Originally posted by oshunluvr View Post
                    Also check out the /lib/modules folders. Unless you use purge successfully when removing a kernel, there's lots of left over folders and files in there.
                    Thanks! After running Kubicle's script there's just the two latest modules:
                    Code:
                    $ cd /lib/modules
                    /lib/modules $ ls
                    5.4.0-65-generic  5.4.0-66-generic
                    /lib/modules $
                    Kubuntu 20.04

                    Comment


                      #11
                      Also, I think there may be a misconception about what's being seen:
                      dpkg-query is a tool to show information about packages listed in the dpkg database.
                      The command I gave was to see package sizes when installed, not determine the installation status.

                      Code:
                      [FONT=monospace][COLOR=#54FF54][B]stuart@office[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#54FFFF][B]~[/B][/COLOR][COLOR=#000000]$ dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | grep -i linux[/COLOR]
                      ~~~
                      164293  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.18.0-20-generic[/COLOR]
                      164325  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.18.0-21-generic[/COLOR]
                      164326  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.18.0-22-generic[/COLOR]
                      164362  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.18.0-18-generic[/COLOR]
                      164388  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.18.0-16-generic[/COLOR]
                      164390  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.18.0-17-generic[/COLOR]
                      164398  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.18.0-24-generic[/COLOR]
                      164398  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.18.0-25-generic[/COLOR]
                      [B]164649  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.18.0-15-generic[/COLOR][/B]
                      167044  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.15.0-42-generic[/COLOR]
                      167064  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.15.0-44-generic[/COLOR]
                      167065  [COLOR=#FF5454][B]linux[/B][/COLOR][COLOR=#000000]-modules-extra-4.15.0-45-generic[/COLOR]
                      ~~~
                      [/FONT]
                      About 60 lines truncated in the above.

                      Code:
                      stuart@office:~$ dpkg-query -l linux-modules-extra-4.18.0-15-generic
                      Desired=Unknown/Install/Remove/Purge/Hold
                      | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
                      |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
                      ||/ Name                                  Version              Architecture Description
                      +++-=====================================-====================-============-===============================================================
                      [B]rc  linux-modules-extra-4.18.0-15-generic [/B]4.18.0-15.16~18.04.1 amd64        Linux kernel extra modules for version 4.18.0 on 64 bit x86 SMP
                      I believe "rc" means "Removed" along with "Config files"

                      If you want to see what kernels are install, use dpkg -l and grep to see what's installed. Something like:

                      dpkg -l |grep -E "^[^rc]" | awk '{print $2}'

                      Last edited by oshunluvr; Mar 05, 2021, 07:41 AM.

                      Please Read Me

                      Comment


                        #12
                        Originally posted by chimak111 View Post
                        Is [ "x${PCKGS}" != "x" ] checking whether ${PCKGS} is not empty? Then why not use [ -n "${PCKGS}" ]?
                        I tend to stay away from -n in scripts since it's often a tad ambigious, and can lead to unexpected results (when a variable might not be set against being empty etc.)...also, since this is not bash script (see the shebang "#!/bin/sh") using the x=x test is sort of bullet proof because it should work in any shell that might be running shell scripts. (see this, for example: https://unix.stackexchange.com/quest...a-shell-script )

                        Originally posted by chimak111 View Post
                        And, instead of "COLUMNS=200 dpkg -l | grep "^rc" | tr -s ' ' | cut -d ' ' -f 2" wouldn't "dpkg -l | awk '/^rc/ {print $2}" work just as well?
                        You can use awk if you prefer. As a general rule, grep is faster than awk, but considering the size of the input and the piping the difference is probably negligible, or could even be slower (didn't care enough to test).

                        Comment


                          #13
                          Originally posted by oshunluvr View Post
                          Also, I think there may be a misconception about what's being seen:
                          The command I gave was to see package sizes when installed, not determine the installation status.

                          ...
                          That's true and so I used
                          Code:
                          dpkg-query -Wf '${Status}\t${Package}\n' | grep -i linux
                          in post #5.
                          Kubuntu 20.04

                          Comment


                            #14
                            Originally posted by kubicle View Post
                            I tend to stay away from -n in scripts since it's often a tad ambigious, and can lead to unexpected results (when a variable might not be set against being empty etc.)...also, since this is not bash script (see the shebang "#!/bin/sh") using the x=x test is sort of bullet proof because it should work in any shell that might be running shell scripts. (see this, for example: https://unix.stackexchange.com/quest...a-shell-script )
                            ...
                            Okay, thanks for the clarification and the link. Time to mark this [SOLVED]!
                            Kubuntu 20.04

                            Comment


                              #15
                              Originally posted by oshunluvr View Post
                              I believe "rc" means "Removed" along with "Config files"
                              See https://askubuntu.com/questions/1880...ike-ii-rc-mean

                              rc means 'It's removed/uninstalled but it's configuration files are still there'
                              Using Kubuntu Linux since March 23, 2007
                              "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                              Comment

                              Working...
                              X