25

I did something silly with a build/modprobe/make while running on my latest installed kernel. Now that kernel will not boot. I am currently running on a previous kernel.

How can I clean this up? I would like to just get back to the "stock" latest kernel that is in the apt repo.

Edit: I should note.... I was trying to install flashcache (https://github.com/facebook/flashcache/)

I tried to do

sudo apt-get install --reinstall linux-image-generic linux-image

That didn't fix it; so I tried the "recovery mode" option and see a kernel panic around the loading of the flashcache module.... I must need to delete something, somewhere...

enter image description here

4 Answers4

21

I do not know if you have network access but if you have then do:

sudo apt-get install --reinstall linux-image-generic linux-image
d a i s y
  • 5,551
18

Simply boot to a previous kernel version and type the following, just replace ## with the kernel version you are trying to boot into.

sudo update-initramfs -u -k 3.2.0-##-generic-pae 

Just replace ## with the kernel version you are trying to boot into.

Follow that with a hello to Grub, and reboot.

sudo update-grub
sudo reboot now

Now you should no longer see a kernel panic when booting into the new kernel.

Knoxy
  • 181
  • 1
  • 4
1

I have a problem with VGA drivers, and the other solutions do not fix my problem

The main solution which does help, is to remove manually and install from the outset

// remove modules
sudo rm -rf /lib/modules/4.13.0-3*

remove headers sudo rm -rf /usr/src/linux-headers-4.13.0-3*

// clear boot sudo rm -rf /boot/initrd.img-4.13.0-3* sudo rm -rf /boot/vmlinuz-4.13.0-3* sudo rm -rf /boot/System.map-4.13.0-3* sudo rm -rf /boot/config-4.13.0-3*

// refresh grub. I reboot after update grub, but maybe is not important sudo update-grub

//check the lastes version of linux images sudo apt-cache search linux-image |grep 4.14

linux-image-4.14.0-1003-azure-edge - Linux kernel image for version 4.14.0 on 64 bit x86 SMP

linux-image-extra-4.14.0-1003-azure-edge - Linux kernel extra modules for version 4.14.0 on 64 bit x86 SMP

linux-image-4.14.0-1004-azure-edge - Linux kernel image for version 4.14.0 on 64 bit x86 SMP

linux-image-extra-4.14.0-1004-azure-edge - Linux kernel extra modules for version 4.14.0 on 64 bit x86 SMP

// install the lastes verion sudo apt-get install linux-image-4.14.0-1004-azure-edge linux-headers-4.14.0-1004-azure-edge linux-image-extra-4.14.0-1004-azure-edge

// restart pc sudo reboot now

1

To do this you need to list the latest ubuntu kernel and reinstall it. Here's a 1 liner

apt install --reinstall `dpkg -l|grep linux-image|grep -v image-generic|cut -d ' ' -f 3|sort -V|tail -1`

if that fails and you want diagnostics you can use this script

#!/bin/bash

Check if the script is run as root

if [ "$(id -u)" != "0" ]; then echo "This script must be run as root. Please use 'sudo' to execute it." exit 1 fi

Get the latest non-generic linux-image package name

latest_package=$(dpkg -l | grep linux-image | grep -v image-generic | cut -d ' ' -f 3 | sort -V | tail -1)

Check if a package name was found

if [ -z "$latest_package" ]; then echo "No valid linux-image package found for reinstallation." exit 1 fi

Reinstall the latest package

echo "Reinstalling the latest linux-image package: $latest_package" apt install --reinstall "$latest_package"

kkron
  • 151