How can I remove compiled kernel?

I installed 14.10 on my laptop Lenovo E455.

And compiled kernel 3.19 with following order

since it seemed that 14.10 doesn't want to work with mine.(I saw slow motions)

Downloaded current kernel from http://www.kernel.org/

make oldconfig
make
sudo make install

Finally, failed to boot with new kernel.

How can I remove the compiled kernel from grub and get recovered?


Solution 1:

If compiled and installed via make install, you will need to manually remove the following entries:

/boot/vmlinuz*KERNEL-VERSION*
/boot/initrd*KERNEL-VERSION*
/boot/System-map*KERNEL-VERSION*
/boot/config-*KERNEL-VERSION*
/lib/modules/*KERNEL-VERSION*/
/var/lib/initramfs/*KERNEL-VERSION*/

Then update the grub configuration:

sudo update-grub2

If compiled via the debian method, you can see the installed kernel with the following:

dpkg --list | grep kernel-image

And then uninstall the desired kernel package with apt-get:

sudo apt-get remove kernel-image-your-kernel-image

Solution 2:

Thanks to jarno's question here I worked out a way of implementing Mudit Kapil's answer that requires very little typing and catches any extra bits lying around

Since all that is needed to remove the kernel is to delete all its files & directories, and all those files and directories will have the kernel release string in their paths, we can use locate to find all the files with the kernel release string and delete them to remove the kernel.

(First check uname -r to find the name of the currently running kernel & be sure not to delete it)

Say you want to remove a kernel called 4.4.6-my-kernel. You can find all its existing files & directories (without listing the files in all the named directories) with locate -b -e 4.4.6-my-kernel. Appending rm -r to this with xargs allows you to delete the files too. I add -p to make xargs display targets and ask for confirmation before executing

locate -b -e 4.4.6-my-kernel | xargs -p sudo rm -r

then type y to execute rm -r on the targets shown. It will complain that files that are not directories don't exist because you're trying to delete them recursively (-r) but that's OK, they will still be removed along with the directories and their contents. When done, just run

sudo update-grub

et voila.