Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: Removing old kernels

  1. #1
    Join Date
    Oct 2009
    Beans
    4
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Removing old kernels

    I'm dual booting Ubuntu and Windows, with limited free space on my Ubuntu partition. I noticed the large number of kernels piling up in my grub boot menu and decided that would be a good place to free up some hard drive space. I opened Synaptic, searched for linux-image, and found two old kernels and deleted them. I still, however, have 4 more kernel entries in my boot.lst (plus the recovery mode for each), but I can't seem to find these to delete them. My boot.lst is being regenerated, so somewhere in that script, it is finding evidence of these kernels, but synaptic can't find them.

    Any ideas how to find and delete these?

    Chris

  2. #2
    Join Date
    May 2006
    Location
    Amsterdam
    Beans
    1,731
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Removing old kernels

    Which Ubuntu version are you using?
    Upgrade Ubuntu | Upgrade unsupported Ubuntu versions | Always backup | Howto upgrade flash
    Minimal CD install | Remove old kernels | My blog | Linux user #462801 | Conscience doth make cowards of us all. -- Shakespeare

  3. #3
    Join Date
    Oct 2009
    Beans
    4
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Removing old kernels

    I'm using Jaunty, my current kernel version is 2.6.28-15-generic, but also showing up are 2.6.22-16-generic,2.6.22-15-generic, 2.6.22-14-generic, and 2.6.20-16-generic

  4. #4
    Join Date
    May 2006
    Location
    Amsterdam
    Beans
    1,731
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Removing old kernels

    Code:
    rmkernel () {
            local cur_kernel=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
            local kernel_pkg="linux-(image|headers|ubuntu-modules|restricted-modules)"
            local meta_pkg="${kernel_pkg}-(generic|i386|server|common|rt|xen|ec2)"
            sudo aptitude purge $(dpkg -l | egrep $kernel_pkg | egrep -v "${cur_kernel}|${meta_pkg}" | awk '{print $2}')
    }
    Put this in your .bashrc file, then source .bashrc (or run bash) and then rmkernel. It will remove all your kernels except your running kernel.
    Upgrade Ubuntu | Upgrade unsupported Ubuntu versions | Always backup | Howto upgrade flash
    Minimal CD install | Remove old kernels | My blog | Linux user #462801 | Conscience doth make cowards of us all. -- Shakespeare

  5. #5
    Join Date
    Nov 2008
    Beans
    479
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Removing old kernels

    Which kernels are installed (find out via Synaptic or by running dpkg -l | grep linux-image)?
    5127d464-4548-4993-a138-f546f2fd2a33

  6. #6
    Join Date
    Oct 2009
    Beans
    4
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Removing old kernels

    slakkie - when running that script, it rewrites the grub menu, and I'm getting this output:

    Found kernel: /boot/vmlinuz-2.6.28-15-generic
    Found kernel: /boot/vmlinuz-2.6.22-16-generic
    Found kernel: /boot/vmlinuz-2.6.22-15-generic
    Found kernel: /boot/vmlinuz-2.6.22-14-generic
    Found kernel: /boot/vmlinuz-2.6.20-16-generic
    Found kernel: /boot/memtest86+.bin

    So I'm guessing that those are still there. Can I just go to /boot and delete the listed files(with the exception on the first one, of course)


    arrange - I only get linux-image-2.6.28-15-generic, and linux-image-generic from that command, which is why Synaptic isn't able to do anything with it



  7. #7
    Join Date
    May 2006
    Location
    Amsterdam
    Beans
    1,731
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Removing old kernels

    Yeah, should be save to remove them. They come from a different releases..


    2.6.20.x is from 7.04
    2.6.22.x is from 7.10

    See also http://en.wikipedia.org/wiki/List_of...ommon_programs
    Upgrade Ubuntu | Upgrade unsupported Ubuntu versions | Always backup | Howto upgrade flash
    Minimal CD install | Remove old kernels | My blog | Linux user #462801 | Conscience doth make cowards of us all. -- Shakespeare

  8. #8
    scouser73's Avatar
    scouser73 is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Mar 2008
    Location
    Liverpool, United Kingdom
    Beans
    1,664
    Distro
    Ubuntu 14.04 Trusty Tahr

    Wink Re: Removing old kernels

    Every time Ubuntu installs a new Linux kernel, the old one is left behind. This means that if you are regularly updating an Ubuntu system the Grub boot menu becomes longer and longer with kernels you don’t need anymore.

    The old kernels are deliberately left installed and on the menu so you can boot a previous kernel if you have trouble with a new one. But if the new one works, you can safely uninstall the old kernel, which will also result in the Grub menu being cleaned up.

    Follow these steps to identify and remove any old kernels.

    1 - Go to Terminal and paste the following command: uname -r
    It will print the version of the Linux kernel you are running, this is the one you want to keep. It should look something like this: 2.6.20-16-generic

    2 - Go to Synaptic Package Manager via the System > Administration menus

    3 - Paste this: linux-image-2 into the search box of Synaptic Package Manager

    4 - Once you have located the old kernels, hightlight them and right-click then select Mark For Complete Removal then click Mark and then click Apply

    The results should show every available and installed kernel. A green box on the left indicates that the package is installed. The only linux-image you want installed is the latest one.

    Be careful of what you remove. Ensure that you don’t remove your current kernel, or anything that is not a linux-image. It is possible to break Ubuntu if you remove the wrong kernel.

    Your computer and Grub menu should now be free of old kernels.

  9. #9
    Join Date
    Jun 2006
    Beans
    226

    Re: Removing old kernels

    Quote Originally Posted by scouser73 View Post
    Every time Ubuntu installs a new Linux kernel, the old one is left behind. This means that if you are regularly updating an Ubuntu system the Grub boot menu becomes longer and longer with kernels you don’t need anymore.

    The old kernels are deliberately left installed and on the menu so you can boot a previous kernel if you have trouble with a new one. But if the new one works, you can safely uninstall the old kernel, which will also result in the Grub menu being cleaned up.

    Follow these steps to identify and remove any old kernels.

    1 - Go to Terminal and paste the following command: uname -r
    It will print the version of the Linux kernel you are running, this is the one you want to keep. It should look something like this: 2.6.20-16-generic

    2 - Go to Synaptic Package Manager via the System > Administration menus

    3 - Paste this: linux-image-2 into the search box of Synaptic Package Manager

    4 - Once you have located the old kernels, hightlight them and right-click then select Mark For Complete Removal then click Mark and then click Apply

    The results should show every available and installed kernel. A green box on the left indicates that the package is installed. The only linux-image you want installed is the latest one.

    Be careful of what you remove. Ensure that you don’t remove your current kernel, or anything that is not a linux-image. It is possible to break Ubuntu if you remove the wrong kernel.

    Your computer and Grub menu should now be free of old kernels.


    Thank you!
    Arch Linux

  10. #10
    Join Date
    Dec 2007
    Beans
    214
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Removing old kernels

    forgive me if i'm wrong, but won't
    Code:
    apt-get autoremove
    delete old kernels?

Page 1 of 3 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
  •