As shown in the figure above, there is an older kernel in the GRUB menu (2.6.32-21) although we have installed a newer version of kernel (2.6.32-22). To remove the old kernel, simply create a shell script as follow:
Copy the above script into your favorite text editor and save it. For example, I give "clean.sh" as filename of the script.
- #/bin/bash
- ls /boot/ | grep vmlinuz | sed 's@vmlinuz-@linux-image-@g' | grep -v `uname -r` > /tmp/kernelList
- for I in `cat /tmp/kernelList`
- do
- apt-get remove $I
- done
- rm -f /tmp/kernelList
- update-grub
Before executing the script you need to add "execute" permission to the file:
Now, whenever you want to remove old kernel, simply execute the script with root privileges:
- chmod +x clean.sh
For your information, you can also use Ubuntu Tweak to perform such a task. But, in any condition, you don't have Ubuntu Tweak installed on your system, you can use this simple script to remove old kernel.
- sudo ./clean.sh
0 comments:
Post a Comment