I was removing the old kernel files ( the image , initrd , modules ..
) after i upgraded to the latest kernel , and as i saw it is a manual
process where u have to delete a few files and then update the
bootloader ( mostly grub ) , ... so i wrote this simple script which
provided the kernel version removes all the concerned files from the
system , ... I have tested this only on Fedora and i am not sure on
how well this can work on other distributions ( as there can be minor
differences in how the kernel image is named or how the initrd image
is named ) :
#!/bin/bash
echo "Script for rempoing a particular kernel version from the system"
echo "NOTE: If the version being deleted is the latest kernel"
echo "on use in the system then you will have to automatically "
echo "update the soft links to /boot/vmlinuz and /boot/System.map"
echo " USE AT YOUR OWN RISK "
echo "send suggestions to <[EMAIL PROTECTED]>"
echo "Press any key to continue !! "
read
echo " "
echo " "
echo "Enter the kernel version to be removed : "
read version
if [ "$version" != "" ]; then
#echo "The given kernel version is installed "
echo "Cleaning up the files "
echo " "
echo "/boot/vmlinuz-$version"
if [ -e /boot/vmlinuz-$verison ]; then
echo "cleaning up vmlinuz "
rm /boot/vmlinuz-$version
else
echo "The kernel image was not found for the given version try
again"
exit
fi
if [ -e /boot/initrd-$version.img ]; then
echo "cleaning up initrd "
rm /boot/initrd-$version.img
else
echo "the file /boot/initrd-$version.img was not found
..ignoring !"
fi
if [ -e /boot/System.map-$version ]; then
echo "cleaning up System.map"
rm /boot/System.map-$version
else
echo "The file /boot/System.map-$version was not found ..
ignoring !"
fi
if [ -d /lib/modules/$version ]; then
echo "Deleting the module , do you really want to do this ?"
echo "Press any key to continue .... :"
echo " cleaning up the modules "
rm -r /lib/modules/$version/
else
echo "The modules directory seems to be missing ... "
echo "Could not find /lib/modules/$version ...ignoring !"
fi
echo "Updating grub ... running grubby.. removing options for
kernel-$version "
grubby --remove-kernel=/boot/vmlinuz-$version
clock
echo "Done ;-)"
else
echo "You have not entered anything , try again ! "
exit
fi
.. please let me know if this script works fine and whether it will be
or is useful (??) .... and also can it be improved , .. are we here
looking at something which is not fulfilled by any existing tool ??
the actual script can be downloaded from here :
http://satish.playdrupal.com/files/kernel_clean_up, and my explanation
here : http://satish.playdrupal.com/?q=node/68( I have given the same
explanation , so not very important ;-)).
Thanks
Satish
--
http://satish.playdrupal.com
_______________________________________________
To unsubscribe, email [EMAIL PROTECTED] with
"unsubscribe <password> <address>"
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc