Page 1 of 4 123 ... LastLast
Results 1 to 10 of 33

Thread: Keeping track of kernels and keeping only two.

  1. #1
    Join Date
    Aug 2009
    Beans
    3,089
    Distro
    Ubuntu Development Release

    Keeping track of kernels and keeping only two.

    Not sure where I got this but, I think it is a handy way to keep track of your kernels.
    When I get a new kernel install I copy it from the terminal and past it to a gedit file. I name the file kernel cmds for Raring (or whatever version I am on). So I can find it easily in

    When I enter sudo apt-get update && sudo apt-get upgrade and see files that will be installed and also see this:

    Code:
    The following packages have been kept back:
      linux-generic linux-headers-generic linux-image-generic
    After I install the updates I enter sudo apt-get dist-upgrade to install the kernel but before I press "Y" to install it I first copy the file names (in red) and paste them to the gedit file.

    Code:
    The following NEW packages will be installed:
      linux-headers-3.8.0-18 linux-headers-3.8.0-18-generic linux-image-3.8.0-18-generic linux-image-extra-3.8.0-18-generic
    The following packages will be upgraded:
      linux-generic linux-headers-generic linux-image-generic
    3 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
    Need to get 56.4 MB of archives.
    After this operation, 235 MB of additional disk space will be used.
    Do you want to continue [Y/n]?
    While pasting the file names into the gedit text file I put "sudo apt-get purge" before each line for later use.
    So then I delete any I have besides the last 2 kernels.

    Here is what my text file looks like for Raring:
    Code:
    sudo apt-get purge linux-headers-3.8.0-9 linux-headers-3.8.0-9-generic linux-image-3.8.0-9-generic linux-image-extra-3.8.0-9-generic        - deleted.
    
    sudo apt-get purge linux-headers-3.8.0-10 linux-headers-3.8.0-10-generic linux-image-3.8.0-10-generic linux-image-extra-3.8.0-10-generic    - deleted.
    
    sudo apt-get purge linux-headers-3.8.0-11 linux-headers-3.8.0-11-generic linux-image-3.8.0-11-generic linux-image-extra-3.8.0-11-generic    - deleted.
    
    sudo apt-get purge linux-headers-3.8.0-12 linux-headers-3.8.0-12-generic linux-image-3.8.0-12-generic linux-image-extra-3.8.0-12-generic    - deleted.
    
    sudo apt-get purge linux-headers-3.8.0-13 linux-headers-3.8.0-13-generic linux-image-3.8.0-13-generic linux-image-extra-3.8.0-13-generic    - deleted.
    
    sudo apt-get purge linux-headers-3.8.0-14 linux-headers-3.8.0-14-generic linux-image-3.8.0-14-generic linux-image-extra-3.8.0-14-generic    - deleted.
    
    sudo apt-get purge linux-headers-3.8.0-15 linux-headers-3.8.0-15-generic linux-image-3.8.0-15-generic linux-image-extra-3.8.0-15-generic    - deleted.
    
    sudo apt-get purge linux-headers-3.8.0-16 linux-headers-3.8.0-16-generic linux-image-3.8.0-16-generic linux-image-extra-3.8.0-16-generic
    
    sudo apt-get purge linux-headers-3.8.0-17 linux-headers-3.8.0-17-generic linux-image-3.8.0-17-generic linux-image-extra-3.8.0-17-generic
    
    sudo apt-get purge linux-headers-3.8.0-18 linux-headers-3.8.0-18-generic linux-image-3.8.0-18-generic linux-image-extra-3.8.0-18-generic
    
    linux-image-generic linux-generic linux-headers-generic
    (The last 2 files are just part of the kernel but, I don't touch them unless I have deleted the last kernel and need to reinstall it which I do not recommend)

    So, I have just installed the 3.8.0-18 kernel and will reboot. Then I will come back and delete the 3.8.0-16 kernel with the above line and copy and paste the - deleted part and save it.

    Then to make it even simpler I have these aliases that do the above commands called ud and ud2. Someone in this forum told me how to do this:

    gksu gedit ~/.bashrc

    Then copy the blue lines after the others (the others are around line 87).

    Code:
    # some more ls aliases
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    
    # update aliases
    alias ud='sudo apt-get update && sudo apt-get upgrade && sudo apt-get clean'
    alias ud2='sudo apt-get dist-upgrade'


    Then all you have to do is enter ud and your password in terminal to get your updates and if anything is held back enter ud2.
    Doing it this way you never have to worry about partial upgrades because if it is not ready to install it will still say The following packages have been kept back:

    Here is what my text file looks like for Quantal:
    Code:
    sudo apt-get purge linux-headers-3.5.0-25 linux-headers-3.5.0-25-generic linux-image-3.5.0-25-generic linux-image-extra-3.5.0-25-generic    - deleted.
    
    sudo apt-get purge linux-headers-3.5.0-26 linux-headers-3.5.0-26-generic linux-image-3.5.0-26-generic linux-image-extra-3.5.0-26-generic
    
    sudo apt-get purge linux-headers-3.5.0-27 linux-headers-3.5.0-27-generic linux-image-3.5.0-27-generic linux-image-extra-3.5.0-27-generic
    Here is what my text file looks like for Precise (notice there are only 3 kernel files for Precise):
    Code:
    sudo apt-get purge linux-headers-3.2.0-37 linux-headers-3.2.0-37-generic linux-image-3.2.0-37-generic    - purged.
    
    sudo apt-get purge linux-headers-3.2.0-38 linux-headers-3.2.0-38-generic linux-image-3.2.0-38-generic    - purged.
    
    sudo apt-get purge linux-headers-3.2.0-39 linux-headers-3.2.0-39-generic linux-image-3.2.0-39-generic
    
    sudo apt-get purge linux-headers-3.2.0-40 linux-headers-3.2.0-40-generic linux-image-3.2.0-40-generic
    Here is my Mint 14 Nadia kernel file which is identical to the Quantal one, which Mint 14 is based on:
    Code:
    sudo apt-get purge linux-headers-3.5.0-26 linux-headers-3.5.0-26-generic linux-image-3.5.0-26-generic linux-image-extra-3.5.0-26-generic
    
    sudo apt-get purge linux-headers-3.5.0-27 linux-headers-3.5.0-27-generic linux-image-3.5.0-27-generic linux-image-extra-3.5.0-27-generic
    PS: Thank you forum auto save feature!!! I clicked the top close button to close the text file and since my Raring is finicky about the buttons when maximized, it closed Firefox.
    I thought I lost everything but, then I remembered how it auto saved the data periodically.
    I found "start a new thread" in my history and clicked on it but it was empty. then I seen at the bottom "restore autosaved data" or something similar and viola it all came back.
    Last edited by QIII; May 2nd, 2013 at 06:44 PM. Reason: Added Quantal, Precise and Mint 14 file contents
    Check Java Version | Install Java via WEB UPD8 PPA
    Creating a Custom Maintenance Free GRUB2 Screen Community Wiki
    Ubuntu 12.04 | 14.04 | 14.10 | Mint 13 | Mint 17 | Windows 7 | All 64 bit

  2. #2
    Join Date
    Mar 2012
    Beans
    303

    Re: Keeping track of kernels and keeping only two.

    Starting with Ubuntu 13.04 (Raring), there is actually no need for this, because apt-get marks older kernel packages as "for autoremoval" and only keeps the two latest ones. Simply run this command once in a while:
    Code:
    sudo apt-get autoremove --purge
    GNU/Linux

  3. #3
    Join Date
    Feb 2008
    Location
    Planet earth, for now.
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: Keeping track of kernels and keeping only two.

    I use Grub Customizer myself to keep the menu list at boot in order. You can rename the kernels, reorder them and remove them from the list.

    http://ubuntuforums.org/showthread.php?t=1664134

  4. #4
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Keeping track of kernels and keeping only two.

    I usually do it with a shell script like this:
    Code:
    #!/bin/sh
    cur=$(uname -r)
    prev=$(readlink -f /vmlinuz.old) && prev=${prev#*-} || prev=@
    keepkernels="^linux-(headers|image|image-extra)-($cur|$prev)"
    allkernels='^linux-(headers|image|image-extra)-[0-9]'
    exec sudo apt-get --only-upgrade purge "$allkernels" "$keepkernels"+
    But solution suggested by brainwash above is a lot simpler.
    Last edited by schragge; May 1st, 2013 at 02:34 PM.

  5. #5
    Join Date
    Aug 2009
    Beans
    3,089
    Distro
    Ubuntu Development Release

    Re: Keeping track of kernels and keeping only two.

    Thanks for the posts but, I was just trying to give people a simple way to manage their kernels.

    You can't get much simpler than this and I trust those commands more than I trust anything else.
    I am purging 4 files by name and this way I know exactly what to expect: that those 4 files will be purged.

    I prefer to keep it simple so I know exactly what is going to happen, which is what I posted above.

    I also stay away from Grub Customizer because I already have a way to customize my Grub menu (the green link in my signature).
    Check Java Version | Install Java via WEB UPD8 PPA
    Creating a Custom Maintenance Free GRUB2 Screen Community Wiki
    Ubuntu 12.04 | 14.04 | 14.10 | Mint 13 | Mint 17 | Windows 7 | All 64 bit

  6. #6
    Join Date
    Aug 2009
    Beans
    3,089
    Distro
    Ubuntu Development Release

    Re: Keeping track of kernels and keeping only two.

    Anyone else find this an easy way to keep track of your kernels? Since they say you should always keep two kernels,
    once I found the file names I made the text file and have been doing it this way for about 4 years. I found it easiest to copy the file names from the terminal just before intstallation.
    Check Java Version | Install Java via WEB UPD8 PPA
    Creating a Custom Maintenance Free GRUB2 Screen Community Wiki
    Ubuntu 12.04 | 14.04 | 14.10 | Mint 13 | Mint 17 | Windows 7 | All 64 bit

  7. #7
    Join Date
    Aug 2006
    Location
    S.F. Bay Area
    Beans
    239
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Keeping track of kernels and keeping only two.

    Quote Originally Posted by brainwash View Post
    Starting with Ubuntu 13.04 (Raring), there is actually no need for this, because apt-get marks older kernel packages as "for autoremoval" and only keeps the two latest ones. Simply run this command once in a while:
    Code:
    sudo apt-get autoremove --purge
    So, I upgraded to Ubuntu 13.04 today and noticed 6 2.6.x kernels were left behind. I ran the command you mention and the 2.6.x kernels were not removed.

    Am I missing something here or must something else be done to clean up the old 2.6.x kernels?

    Thanks!

    Peace...

  8. #8
    Join Date
    Sep 2012
    Location
    Gnome12o4/LXQt14o4
    Beans
    Hidden!

    Re: Keeping track of kernels and keeping only two.

    I just use synaptic package manager

    Code:
    sudo apt-get install synaptic


  9. #9
    Join Date
    Aug 2009
    Beans
    3,089
    Distro
    Ubuntu Development Release

    Re: Keeping track of kernels and keeping only two.

    Quote Originally Posted by tomdkat View Post
    So, I upgraded to Ubuntu 13.04 today and noticed 6 2.6.x kernels were left behind. I ran the command you mention and the 2.6.x kernels were not removed.

    Am I missing something here or must something else be done to clean up the old 2.6.x kernels?

    Thanks!

    Peace...
    If you are refering to
    Code:
    sudo apt-get autoremove --purge
    I cannot help you. That is not what this thread is about.

    Quote Originally Posted by ibjsb4 View Post
    I just use synaptic package manager.

    Code:
    sudo apt-get install synaptic

    Sure you can use SPM to remove them after finding them which can sometimes take a bit of looking.
    Whether you use SPM or the command:

    Code:
    sudo apt-get purge linux-headers-blah.blah-blah linux-headers-blah.blah-blah-generic linux-image-blah.blah-blah-generic linux-image-extra-blah.blah-blah-generic
    will pretty much accomplish the same thing as long as you do not delete the wrong files or not all of them using SPM.

    As I stated in post #1 (which this thread is about):
    When updating kernels I copied the names of the components of the kernel and pasted them into a text (gedit) file thus keeping track of the kernels as they are installed.

    Code:
    The following NEW packages will be installed:
      linux-headers-3.8.0-18 linux-headers-3.8.0-18-generic linux-image-3.8.0-18-generic linux-image-extra-3.8.0-18-generic
    The following packages will be upgraded:
      linux-generic linux-headers-generic linux-image-generic
    3 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
    Need to get 56.4 MB of archives.
    After this operation, 235 MB of additional disk space will be used.
    Do you want to continue [Y/n]?
    I am merely suggesting my method of copying these kernel file names from the commands above and pasting them into a text file to log them if you will.
    Then subsequently deleting the 3rd one back and leaving 2 kernels.
    You can do it however you see fit.
    Last edited by Cavsfan; April 30th, 2013 at 09:08 PM.
    Check Java Version | Install Java via WEB UPD8 PPA
    Creating a Custom Maintenance Free GRUB2 Screen Community Wiki
    Ubuntu 12.04 | 14.04 | 14.10 | Mint 13 | Mint 17 | Windows 7 | All 64 bit

  10. #10
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Keeping track of kernels and keeping only two.

    Quote Originally Posted by tomdkat View Post
    So, I upgraded to Ubuntu 13.04 today and noticed 6 2.6.x kernels were left behind. I ran the command you mention and the 2.6.x kernels were not removed.
    I'm not sure what brainwash was referring to (I don't use Ubuntu myself). But obviously for that to work, kernel packages should be marked as auto-installed, and some installed packages should depend only on the last two of them. AFAICS, the dependency tree in raring looks like
    Code:
    linux -> linux-generic -> linux-headers-generic -> linux-headers-3.8.0-19-generic
                  +-> linux-image-generic -> linux-image-3.8.0-19-generic
                           +-> linux-image-extra-3.8.0-19-generic
                           +-> linux-firmware
    If all those packages but linux are marked as auto-installed then upgrading linux could clear previously installed versions of linux-image-* and linux-image-extra-* for autoremoval. But I still don't see how it could keep two kernels as linux-image-generic only depends on one.

    To manually mark packages as auto-installed, run apt-mark
    Code:
    sudo apt-mark manual linux
    sudo apt-mark auto ^linux-
    Last edited by schragge; April 28th, 2013 at 05:37 PM.

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •