Eliminate previous versions of the kernel that we do not use

kernel_output

Today I bring you a little trick, which despite being quite easy, is useful to save disk space and avoid annoying updates what do we need. I recently made an update of my system to use the 3.5.0-X kernel, but the previous versions of the 3.2.0-X kernel were installed on my system and every time the system asked to update, it was updating the 3.2.0 branch -X from the kernel, which I wasn't using.

I gave myself to the task of remove these older versions, for this, first I saw which ones were installed on my system, using the command:

sudo dpkg -l | grep linux-image

This command returns the list of installed kernels, which in my case were enough for the 3.2.0-X branch, so I decided to remove all the packages from this branch and thus avoid new updates that I would not use. To perform this action use the command:

sudo apt-get remove --purge linux-image-X.X.X-X

The Xs must be replaced by the version we want to remove, in my case it is as follows:

sudo apt-get remove --purge linux-image-3.2.0-40-generic-pae

After carrying out this last operation, 113 MB of disk space was freed, when repeating it to eliminate all versions of this branch, it freed me 1GB. Hope you find this tip useful and help you save disk space.

Taken from humans.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

26 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   commentator said

    I find that some articles are very simple and are made just for posting something. The article is an explanation of how to remove an installed package, and that is best done in synaptic, it is also recommended not to remove all the kernels because later ...

    1.    elav said

      Some things may seem simple when you already have a level of knowledge ... but SinceLinux is not focused on Gurus ... but on new users.

      1.    Giskard said

        Excellent answer!

      2.    commentator said

        Hahaha You say guru because I recommend using a graphical tool instead of the terminal? for new users there is nothing better than graphical interfaces for managing your system; and that you cannot argue.

    2.    codelab said

      As elav says, I think the blog has a place for information of all kinds, from the simplest tips for those who recently started using a Linux distribution, to the more technical articles for people of a more advanced level, basically it is about learning, in one way or another, but learning.

      Greetings and good tip.

    3.    Gamlr said

      This article is intended for all new linux users to lose their fear of the terminal
      Excellent post

    4.    VM said

      Thank you very much, it is the fastest to use the Synaptic Package Manager. From the console you can also, but at least in Linux Mint you always have remnants of the previous kernel if you do it with the same commands from the tutorial or with these below, and you have to repeat them several times

      dpkg –list | grep linux-image -> list what kernels you have installed

      uname -r -> see which one you are using

      sudo apt-get purge linux-image-XXX-generic -> remove one

      sudo update-grub -> update grub

      sudo apt autoremove -> clean

      sudo apt autoclean -> clean

      as well as to update the system it is better from the console, than from the Update Manager, if you do it from here, in the terminal it will tell you that there are still packages to update

      sudo apt update -> update the list of packages available from the servers

      sudo apt upgrade -> install the packages and upgrade the system

      Example:

      user @ user ~ $ sudo apt upgrade
      Reading package list ... Done
      Creating dependency tree
      Reading the status information ... Done
      Calculating the update ... Done
      0 updated, 0 new will be installed, 0 to remove, and 0 not updated.

  2.   one of some said

    If you use fedora the steps would be:

    To find out which ones you have installed "rpm -q kernel" and so it will tell you which kernels you have and to remove it, just type "yum remove (the kernel you want to remove)"

  3.   Germán said

    that's a problem we don't have in arch

    1.    Volt said

      Very true!

    2.    Abraham said

      I was wondering how it was done in arch "Thanks for the TIP"

    3.    pandev92 said

      Of course you don't have it, simply because if the update puts a kernel that fucks your system, then you screwed up, neither more nor less xD

    4.    jony127 said

      Yes, but let me tell you that stability is an issue that Arch has and not Debian. If you haven't had any at the moment, time to time.

  4.   He passed through here said

    good tip when one is very short of space is very useful
    With aptitude (debian) you can also, (if you know well what you want to do, thinking that it is always advisable to have an extra kernel)
    more tending to the one liner
    dpkg -l | grep "linux- [im \ | he]" | grep -v "$ (uname -r)" | awk '{print $ 2}'
    purge replaces remove –purge or is unnecessary, according to this in apt.conf
    APT :: Get :: Purge;

  5.   platonov said

    I use a siduction package (derived from debian Sid) called kernel remover which works very well.

  6.   artefact said

    I do it from Ubuntu Tweak, from the Cleaner tab, it is very easy. In addition to deleting the versions of the Kernel that we do not use, we can do more things like delete the caches of some programs, unnecessary packages, etc.
    I always leave the last one, the previous one and delete the oldest ones.

  7.   shnkr3 said

    and in archlinux? :DC

    1.    kennatj said

      and in Chakra-Linux? :DC

  8.   Mephisto said

    Elav is also imposing to do the same procedure with the headers that remain installed

  9.   Cristianhcd said

    for fedora and centos

    his -
    yum remove -y $ (rpm -qa | grep -i kernel)

    this seeks to remove all kernels and skipping the running

    1.    David said

      Thanks friend it worked perfectly for me

  10.   Franklin Gomez said

    Sometimes the obvious things stop being obvious if they are not said.
    It is always useful, it will serve more than one for sure.
    Greetings.

  11.   Surfer said

    here I was looking for the linux mint community and this script appeared, this is the URL

    http://community.linuxmint.com/tutorial/view/373

  12.   laurok said

    Simply comment that the information presented here has been very useful to me, can I ask for more from a blog? salu2

  13.   Adrian said

    It really is something very simple, simple and useful.
    Working by console, for me is the best, definitely, it is simpler and with a command line you can do many things.

    Your post has been very useful.

    Greetings and thanks for sharing.

  14.   elkoko said

    Thank you very helpful!