How to really, truly remove old kernels? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite













This question already has an answer here:



  • Why are old initrd files of uninstalled kernels filling up /boot partition?

    1 answer



I've read many answers on this site answering this question. I'm on 16.04, so the following should take care of old kernels:



sudo apt-get autoremove



Failing that, I can remove old ones manually (keeping recent kernels as backup):



sudo apt-get remove linux-image-3.*
sudo apt-get remove linux-image-extras-3.*
sudo apt-get remove linux-headers-3.*
sudo apt-get remove linux-image-4.0.0-x*
sudo apt-get remove linux-image-extras-4.0.0-x*
sudo apt-get remove linux-headers-4.0.0-x*


where I performed the last three commands for x = 3, 4, 5, 6, 7, 8. This did result in disk space being cleared, up to ~500M in some cases. However, I still see many MB of disk space being used on these old kernels in /boot:



ls -lh /boot

...

-rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-33-generic.old-dkms
-rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-61-generic.old-dkms
-rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-64-generic.old-dkms
-rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-65-generic.old-dkms
-rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-66-generic.old-dkms
-rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-68-generic.old-dkms
-rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-74-generic.old-dkms
-rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-75-generic.old-dkms
-rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-77-generic.old-dkms
-rw-r--r-- 1 root root 39M Nov 28 09:41 initrd.img-4.4.0-101-generic
-rw-r--r-- 1 root root 15M Dec 17 2016 initrd.img-4.4.0-31-generic.old-dkms
-rw-r--r-- 1 root root 18M Aug 27 18:51 initrd.img-4.4.0-57-generic.old-dkms
-rw-r--r-- 1 root root 18M Aug 27 18:51 initrd.img-4.4.0-59-generic.old-dkms
-rw-r--r-- 1 root root 18M Aug 27 18:52 initrd.img-4.4.0-62-generic.old-dkms
-rw-r--r-- 1 root root 18M Aug 27 18:52 initrd.img-4.4.0-64-generic.old-dkms
-rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-71-generic.old-dkms
-rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-72-generic.old-dkms
-rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-75-generic.old-dkms
-rw-r--r-- 1 root root 18M Sep 23 11:33 initrd.img-4.4.0-78-generic.old-dkms
-rw-r--r-- 1 root root 39M Nov 4 17:00 initrd.img-4.4.0-98-generic

...


and also, the old kernels are still listed as large installed packages by dpkg:



dpkg-query -W --showformat='$Installed-Size $Packagen' | sort -nr | less

...

158659 linux-image-extra-4.4.0-47-generic
158555 linux-image-extra-4.4.0-36-generic
158443 linux-image-extra-4.4.0-34-generic
158201 linux-image-extra-4.4.0-31-generic
157559 linux-image-extra-4.4.0-53-generic
157559 linux-image-extra-4.4.0-51-generic
156386 linux-image-extra-3.19.0-77-generic
156386 linux-image-extra-3.19.0-75-generic
156385 linux-image-extra-3.19.0-74-generic
156384 linux-image-extra-3.19.0-68-generic
156384 linux-image-extra-3.19.0-66-generic
156384 linux-image-extra-3.19.0-65-generic
156383 linux-image-extra-3.19.0-64-generic
156380 linux-image-extra-3.19.0-61-generic
156178 linux-image-extra-3.19.0-33-generic
150341 linux-image-extra-4.4.0-57-generic
150205 linux-image-extra-4.4.0-62-generic
150198 linux-image-extra-4.4.0-59-generic
149214 linux-image-extra-4.4.0-101-generic
149191 linux-image-extra-4.4.0-98-generic
149156 linux-image-extra-4.4.0-96-generic
148953 linux-image-extra-4.4.0-72-generic
148953 linux-image-extra-4.4.0-71-generic
148940 linux-image-extra-4.4.0-64-generic
148663 linux-image-extra-4.4.0-87-generic
148621 linux-image-extra-4.4.0-78-generic
148598 linux-image-extra-4.4.0-75-generic

...


How can I fully clean my system of these old kernels?










share|improve this question













marked as duplicate by N0rbert, karel, Eric Carvalho, WinEunuuchs2Unix, Charles Green Feb 7 at 13:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















    up vote
    0
    down vote

    favorite













    This question already has an answer here:



    • Why are old initrd files of uninstalled kernels filling up /boot partition?

      1 answer



    I've read many answers on this site answering this question. I'm on 16.04, so the following should take care of old kernels:



    sudo apt-get autoremove



    Failing that, I can remove old ones manually (keeping recent kernels as backup):



    sudo apt-get remove linux-image-3.*
    sudo apt-get remove linux-image-extras-3.*
    sudo apt-get remove linux-headers-3.*
    sudo apt-get remove linux-image-4.0.0-x*
    sudo apt-get remove linux-image-extras-4.0.0-x*
    sudo apt-get remove linux-headers-4.0.0-x*


    where I performed the last three commands for x = 3, 4, 5, 6, 7, 8. This did result in disk space being cleared, up to ~500M in some cases. However, I still see many MB of disk space being used on these old kernels in /boot:



    ls -lh /boot

    ...

    -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-33-generic.old-dkms
    -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-61-generic.old-dkms
    -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-64-generic.old-dkms
    -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-65-generic.old-dkms
    -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-66-generic.old-dkms
    -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-68-generic.old-dkms
    -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-74-generic.old-dkms
    -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-75-generic.old-dkms
    -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-77-generic.old-dkms
    -rw-r--r-- 1 root root 39M Nov 28 09:41 initrd.img-4.4.0-101-generic
    -rw-r--r-- 1 root root 15M Dec 17 2016 initrd.img-4.4.0-31-generic.old-dkms
    -rw-r--r-- 1 root root 18M Aug 27 18:51 initrd.img-4.4.0-57-generic.old-dkms
    -rw-r--r-- 1 root root 18M Aug 27 18:51 initrd.img-4.4.0-59-generic.old-dkms
    -rw-r--r-- 1 root root 18M Aug 27 18:52 initrd.img-4.4.0-62-generic.old-dkms
    -rw-r--r-- 1 root root 18M Aug 27 18:52 initrd.img-4.4.0-64-generic.old-dkms
    -rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-71-generic.old-dkms
    -rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-72-generic.old-dkms
    -rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-75-generic.old-dkms
    -rw-r--r-- 1 root root 18M Sep 23 11:33 initrd.img-4.4.0-78-generic.old-dkms
    -rw-r--r-- 1 root root 39M Nov 4 17:00 initrd.img-4.4.0-98-generic

    ...


    and also, the old kernels are still listed as large installed packages by dpkg:



    dpkg-query -W --showformat='$Installed-Size $Packagen' | sort -nr | less

    ...

    158659 linux-image-extra-4.4.0-47-generic
    158555 linux-image-extra-4.4.0-36-generic
    158443 linux-image-extra-4.4.0-34-generic
    158201 linux-image-extra-4.4.0-31-generic
    157559 linux-image-extra-4.4.0-53-generic
    157559 linux-image-extra-4.4.0-51-generic
    156386 linux-image-extra-3.19.0-77-generic
    156386 linux-image-extra-3.19.0-75-generic
    156385 linux-image-extra-3.19.0-74-generic
    156384 linux-image-extra-3.19.0-68-generic
    156384 linux-image-extra-3.19.0-66-generic
    156384 linux-image-extra-3.19.0-65-generic
    156383 linux-image-extra-3.19.0-64-generic
    156380 linux-image-extra-3.19.0-61-generic
    156178 linux-image-extra-3.19.0-33-generic
    150341 linux-image-extra-4.4.0-57-generic
    150205 linux-image-extra-4.4.0-62-generic
    150198 linux-image-extra-4.4.0-59-generic
    149214 linux-image-extra-4.4.0-101-generic
    149191 linux-image-extra-4.4.0-98-generic
    149156 linux-image-extra-4.4.0-96-generic
    148953 linux-image-extra-4.4.0-72-generic
    148953 linux-image-extra-4.4.0-71-generic
    148940 linux-image-extra-4.4.0-64-generic
    148663 linux-image-extra-4.4.0-87-generic
    148621 linux-image-extra-4.4.0-78-generic
    148598 linux-image-extra-4.4.0-75-generic

    ...


    How can I fully clean my system of these old kernels?










    share|improve this question













    marked as duplicate by N0rbert, karel, Eric Carvalho, WinEunuuchs2Unix, Charles Green Feb 7 at 13:53


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite












      This question already has an answer here:



      • Why are old initrd files of uninstalled kernels filling up /boot partition?

        1 answer



      I've read many answers on this site answering this question. I'm on 16.04, so the following should take care of old kernels:



      sudo apt-get autoremove



      Failing that, I can remove old ones manually (keeping recent kernels as backup):



      sudo apt-get remove linux-image-3.*
      sudo apt-get remove linux-image-extras-3.*
      sudo apt-get remove linux-headers-3.*
      sudo apt-get remove linux-image-4.0.0-x*
      sudo apt-get remove linux-image-extras-4.0.0-x*
      sudo apt-get remove linux-headers-4.0.0-x*


      where I performed the last three commands for x = 3, 4, 5, 6, 7, 8. This did result in disk space being cleared, up to ~500M in some cases. However, I still see many MB of disk space being used on these old kernels in /boot:



      ls -lh /boot

      ...

      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-33-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-61-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-64-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-65-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-66-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-68-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-74-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-75-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-77-generic.old-dkms
      -rw-r--r-- 1 root root 39M Nov 28 09:41 initrd.img-4.4.0-101-generic
      -rw-r--r-- 1 root root 15M Dec 17 2016 initrd.img-4.4.0-31-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:51 initrd.img-4.4.0-57-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:51 initrd.img-4.4.0-59-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:52 initrd.img-4.4.0-62-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:52 initrd.img-4.4.0-64-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-71-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-72-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-75-generic.old-dkms
      -rw-r--r-- 1 root root 18M Sep 23 11:33 initrd.img-4.4.0-78-generic.old-dkms
      -rw-r--r-- 1 root root 39M Nov 4 17:00 initrd.img-4.4.0-98-generic

      ...


      and also, the old kernels are still listed as large installed packages by dpkg:



      dpkg-query -W --showformat='$Installed-Size $Packagen' | sort -nr | less

      ...

      158659 linux-image-extra-4.4.0-47-generic
      158555 linux-image-extra-4.4.0-36-generic
      158443 linux-image-extra-4.4.0-34-generic
      158201 linux-image-extra-4.4.0-31-generic
      157559 linux-image-extra-4.4.0-53-generic
      157559 linux-image-extra-4.4.0-51-generic
      156386 linux-image-extra-3.19.0-77-generic
      156386 linux-image-extra-3.19.0-75-generic
      156385 linux-image-extra-3.19.0-74-generic
      156384 linux-image-extra-3.19.0-68-generic
      156384 linux-image-extra-3.19.0-66-generic
      156384 linux-image-extra-3.19.0-65-generic
      156383 linux-image-extra-3.19.0-64-generic
      156380 linux-image-extra-3.19.0-61-generic
      156178 linux-image-extra-3.19.0-33-generic
      150341 linux-image-extra-4.4.0-57-generic
      150205 linux-image-extra-4.4.0-62-generic
      150198 linux-image-extra-4.4.0-59-generic
      149214 linux-image-extra-4.4.0-101-generic
      149191 linux-image-extra-4.4.0-98-generic
      149156 linux-image-extra-4.4.0-96-generic
      148953 linux-image-extra-4.4.0-72-generic
      148953 linux-image-extra-4.4.0-71-generic
      148940 linux-image-extra-4.4.0-64-generic
      148663 linux-image-extra-4.4.0-87-generic
      148621 linux-image-extra-4.4.0-78-generic
      148598 linux-image-extra-4.4.0-75-generic

      ...


      How can I fully clean my system of these old kernels?










      share|improve this question














      This question already has an answer here:



      • Why are old initrd files of uninstalled kernels filling up /boot partition?

        1 answer



      I've read many answers on this site answering this question. I'm on 16.04, so the following should take care of old kernels:



      sudo apt-get autoremove



      Failing that, I can remove old ones manually (keeping recent kernels as backup):



      sudo apt-get remove linux-image-3.*
      sudo apt-get remove linux-image-extras-3.*
      sudo apt-get remove linux-headers-3.*
      sudo apt-get remove linux-image-4.0.0-x*
      sudo apt-get remove linux-image-extras-4.0.0-x*
      sudo apt-get remove linux-headers-4.0.0-x*


      where I performed the last three commands for x = 3, 4, 5, 6, 7, 8. This did result in disk space being cleared, up to ~500M in some cases. However, I still see many MB of disk space being used on these old kernels in /boot:



      ls -lh /boot

      ...

      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-33-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-61-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-64-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-65-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-66-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-68-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-74-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-75-generic.old-dkms
      -rw-r--r-- 1 root root 14M Dec 17 2016 initrd.img-3.19.0-77-generic.old-dkms
      -rw-r--r-- 1 root root 39M Nov 28 09:41 initrd.img-4.4.0-101-generic
      -rw-r--r-- 1 root root 15M Dec 17 2016 initrd.img-4.4.0-31-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:51 initrd.img-4.4.0-57-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:51 initrd.img-4.4.0-59-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:52 initrd.img-4.4.0-62-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:52 initrd.img-4.4.0-64-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-71-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-72-generic.old-dkms
      -rw-r--r-- 1 root root 18M Aug 27 18:53 initrd.img-4.4.0-75-generic.old-dkms
      -rw-r--r-- 1 root root 18M Sep 23 11:33 initrd.img-4.4.0-78-generic.old-dkms
      -rw-r--r-- 1 root root 39M Nov 4 17:00 initrd.img-4.4.0-98-generic

      ...


      and also, the old kernels are still listed as large installed packages by dpkg:



      dpkg-query -W --showformat='$Installed-Size $Packagen' | sort -nr | less

      ...

      158659 linux-image-extra-4.4.0-47-generic
      158555 linux-image-extra-4.4.0-36-generic
      158443 linux-image-extra-4.4.0-34-generic
      158201 linux-image-extra-4.4.0-31-generic
      157559 linux-image-extra-4.4.0-53-generic
      157559 linux-image-extra-4.4.0-51-generic
      156386 linux-image-extra-3.19.0-77-generic
      156386 linux-image-extra-3.19.0-75-generic
      156385 linux-image-extra-3.19.0-74-generic
      156384 linux-image-extra-3.19.0-68-generic
      156384 linux-image-extra-3.19.0-66-generic
      156384 linux-image-extra-3.19.0-65-generic
      156383 linux-image-extra-3.19.0-64-generic
      156380 linux-image-extra-3.19.0-61-generic
      156178 linux-image-extra-3.19.0-33-generic
      150341 linux-image-extra-4.4.0-57-generic
      150205 linux-image-extra-4.4.0-62-generic
      150198 linux-image-extra-4.4.0-59-generic
      149214 linux-image-extra-4.4.0-101-generic
      149191 linux-image-extra-4.4.0-98-generic
      149156 linux-image-extra-4.4.0-96-generic
      148953 linux-image-extra-4.4.0-72-generic
      148953 linux-image-extra-4.4.0-71-generic
      148940 linux-image-extra-4.4.0-64-generic
      148663 linux-image-extra-4.4.0-87-generic
      148621 linux-image-extra-4.4.0-78-generic
      148598 linux-image-extra-4.4.0-75-generic

      ...


      How can I fully clean my system of these old kernels?





      This question already has an answer here:



      • Why are old initrd files of uninstalled kernels filling up /boot partition?

        1 answer







      16.04 apt kernel disk-usage disk-management






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 7 at 5:28









      Anonymous

      1013




      1013




      marked as duplicate by N0rbert, karel, Eric Carvalho, WinEunuuchs2Unix, Charles Green Feb 7 at 13:53


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by N0rbert, karel, Eric Carvalho, WinEunuuchs2Unix, Charles Green Feb 7 at 13:53


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          You need to purge the kernels instead of just remove.



          A handy tool is purge-old-kernels which is shipped with the byobu package on Ubuntu 16.04.






          share|improve this answer



























            up vote
            0
            down vote













            Get a list of all kernel-related packages with apt list --installed | grep linux, and apt remove those you don't want. It's that simple. You cab use --purge if you want, but it should not have any significant effect in that case.






            share|improve this answer



























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote













              You need to purge the kernels instead of just remove.



              A handy tool is purge-old-kernels which is shipped with the byobu package on Ubuntu 16.04.






              share|improve this answer
























                up vote
                2
                down vote













                You need to purge the kernels instead of just remove.



                A handy tool is purge-old-kernels which is shipped with the byobu package on Ubuntu 16.04.






                share|improve this answer






















                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  You need to purge the kernels instead of just remove.



                  A handy tool is purge-old-kernels which is shipped with the byobu package on Ubuntu 16.04.






                  share|improve this answer












                  You need to purge the kernels instead of just remove.



                  A handy tool is purge-old-kernels which is shipped with the byobu package on Ubuntu 16.04.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 7 at 8:41









                  marcolz

                  1214




                  1214






















                      up vote
                      0
                      down vote













                      Get a list of all kernel-related packages with apt list --installed | grep linux, and apt remove those you don't want. It's that simple. You cab use --purge if you want, but it should not have any significant effect in that case.






                      share|improve this answer
























                        up vote
                        0
                        down vote













                        Get a list of all kernel-related packages with apt list --installed | grep linux, and apt remove those you don't want. It's that simple. You cab use --purge if you want, but it should not have any significant effect in that case.






                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          Get a list of all kernel-related packages with apt list --installed | grep linux, and apt remove those you don't want. It's that simple. You cab use --purge if you want, but it should not have any significant effect in that case.






                          share|improve this answer












                          Get a list of all kernel-related packages with apt list --installed | grep linux, and apt remove those you don't want. It's that simple. You cab use --purge if you want, but it should not have any significant effect in that case.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Feb 7 at 9:16









                          fkraiem

                          8,49121727




                          8,49121727












                              Popular posts from this blog

                              Unable to upgrade pip

                              How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

                              Cutting all the characters after the last /