Monday, January 10, 2011

Is there a way to remove/hide old kernel versions?

Every time I install a new linux kernel, it gets left in the grub config, making the boot menu longer each time. I know I can manually search through the installed packages and remove them, but does ubuntu provide any easier way to clean them up or keep them from showing in the boot list?

  • Personally i like using Synaptics, makes me feel more secure about whats going on. The only app I've used that has an option to remove old kernels is Ubuntu Tweak.

    EDIT: How to remove the kernels you are not using

    • Open UbuntuTweak
    • Click on 'Package Cleaner' under 'Applications' in the left-hand pane
    • On the right side of the 'cleaning view' press 'Clean Kernels'
    • Select all kernels - I think the one in use is not listed but just in case check running uname -a in a terminal
    Ken Simon : Ubuntu Tweak is never a good answer to any question, unless that question is "how can I adjust things in Ubuntu without learning a single thing?"
    From Alan FL
  • Computer Janitor can clean up old kernels and I believe is installed by default in Ubuntu (but not Kubuntu).

    GRUB 1, if you're using that, has an option in /boot/grub/menu.lst to specify how many kernels it should show at a maximum. GRUB 2, as far as I can tell, does not.

    JanC : Actually, that's a feature of the respective update-grub scripts in Ubuntu, not a GRUB1 vs. GRUB2 feature per se. The way to implement this for GRUB2 would be to modify `/etc/grub.d/10_linux` to respect a variable that you can set in `/etc/default/grub`. (Looks like that would be no more than a 1-3 line change actually.)
    maco : Seems stupid to me to disable use of a variable. Will need to mention this to Colin...
    From maco
  • I believe that I have removed old kernels with the "apt-get autoclean" or "apt-get autoremove" command, but I'm not certain.

  • In order to remove older linux image kernels first boot in the kernel u want to keep.

    Also u can check the kernel version using command uname -r so that by mistake u don't remove the desired one.

    Now go to synaptic package manager and search for linux-image and remove the older versions except the one shown by upper command. Generally i prefer to go with the latest one.

    Now when u boot u'll see a more clean grub menu. :)

    Broam : This is probably the most basic method that will for users who have installs w/o Computer Janitor.
    From Anurag
  • ailurus has the feature of removing old kernels as well as unused configurations. I personally remove it manually from synaptic. You can install ailurus from getdeb as well as ppa

  • Purely commandline, this will remove all but the current and second most current (via the "-2" in the head command below):

    OLD=$(ls -tr /boot/vmlinuz-* | head -n -2 | cut -d- -f2- | \
        awk '"'"'{print "linux-image-" $0}'"'"' )
    if [ -n "$OLD" ]; then
        apt-get -qy remove --purge $OLD
    fi
    apt-get -qy autoremove --purge
    
    ImaginaryRobots : I don't think that counts as "easier", and isn't provided by ubuntu.
    From Kees Cook

0 comments:

Post a Comment