| Chess | Tools | Data | Blog | Poetry | Why? | Wiki | Admin | Logout |

Download


#!/bin/sh
# $Revision: 0.1 $
# $Date: 2010-02-05 11:15 EST $
# Luis Mondesi <lemsx1@gmail.com>
#
# DESCRIPTION: removes all kernels but the current version
# USAGE: $0 [--I-know-what-I-am-doing]
# LICENSE: GPL

DOACTION="--I-know-what-I-am-doing"
CURRENT=`uname -r`
KERNELPKG="linux-image" # Ubuntu standard

echo To remove kernels run with $DOACTION
for i in /boot/vmlinuz*; do
    #echo "d: $i"
    if ! echo $i | grep -q $CURRENT; then
        if [ "x$1" = "x$DOACTION" ]; then
            name=`basename $i|sed s/vmlinuz/$KERNELPKG/`
            #echo $name
            sudo apt-get --purge -y remove $name
        else
            echo $i
        fi
    else
        : Skip from current kernel on
        break
    fi
done

Advertisement