- Jan 14, 2015
- 1,761
There comes a time where you either made a mistake in upgrading the Kernel on your system and didn't keep the old ones or simply there is an issue with the current Kernel "Kernel Panic" (i.e Neptune OS on Virtual Box - At time of writing, Neptune OS developers had pushed a kernel update to address the issue that was visible in some machines hardware).
If the distribution you are using has a live disk, then it ain't all gone and you can easily fix the Kernel Panic by upgrading/downgrading the Kernel.
Note that I have only tested the below in Ubuntu based and Debian based distros. After purposely breaking the kernel for testing purposes, I chose not to use an external kernel, like the Liquorix kernel. You can still get the kernel using the wget command and install from there or manually editing the sources.list accordingly. These 2 methods will not be covered in this tutorial.
Important: Below steps will require you to boot from the live disk and have access to the internet.
1. Open the terminal and run this command to list your partitions:
The disk is usually /dev/sda
the partitions will be several, depending how you set up your partitions. Pay close attention to the partition that has the file system you have installed the OS.
If you only set 2 partitions, for example the main one and a linux-swap, its the other one you are looking for. For the following commands, I will assume you are using partition number 1 as the boot/main partition so it will be: /dev/sda1 and its the only one OS you have installed and want to repair it. Also remember the number of the /boot partition should you have one.
2. Still on the Terminal window (and you will remain here until the end of the tutorial), you will need to mount the / filesystem to /mnt and mount the /dev filesystem. Run the following commands (remember sda1 is as per above note):
If you happen to have a /boot partition, then also run the following command:
3. Now that the above is done, time to chroot and mount the remaining virtual filesystems along with some environment variables. Run the following commands:
4. Time to update the system and or kernel. Run the following commands:
The apt-cache search command will search all the available linux kernels available in your repositories.
5. Now that you know what kernel you want, time to install it. Simply run the following command:
If you want to update the system and a newer kernel is available, then run the following command instead of the apt-get -y install above mentioned:
6. There you go you have now upgraded/downgraded the kernel. Time to unmount some stuff.
Run the following commands in the same terminal window still (as chroot):
7. Restart the system and boot into the OS without the live disk on (DVD/USB). Everything should be fine now.
Note that the above was not tested fully on Arch/Fedora/OpenSuse main and based off distros.
Hope this helps anyone who needs it.
If the distribution you are using has a live disk, then it ain't all gone and you can easily fix the Kernel Panic by upgrading/downgrading the Kernel.
Note that I have only tested the below in Ubuntu based and Debian based distros. After purposely breaking the kernel for testing purposes, I chose not to use an external kernel, like the Liquorix kernel. You can still get the kernel using the wget command and install from there or manually editing the sources.list accordingly. These 2 methods will not be covered in this tutorial.
Important: Below steps will require you to boot from the live disk and have access to the internet.
1. Open the terminal and run this command to list your partitions:
This command will list the disk and the partition tables.sudo parted -l
The disk is usually /dev/sda
the partitions will be several, depending how you set up your partitions. Pay close attention to the partition that has the file system you have installed the OS.
If you only set 2 partitions, for example the main one and a linux-swap, its the other one you are looking for. For the following commands, I will assume you are using partition number 1 as the boot/main partition so it will be: /dev/sda1 and its the only one OS you have installed and want to repair it. Also remember the number of the /boot partition should you have one.
2. Still on the Terminal window (and you will remain here until the end of the tutorial), you will need to mount the / filesystem to /mnt and mount the /dev filesystem. Run the following commands (remember sda1 is as per above note):
sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
If you happen to have a /boot partition, then also run the following command:
Please ensure that you replace bootpartition text with the actual device name and number of the /boot partition you have (i.e /dev/sda3).sudo mount bootpartition /mnt/boot
3. Now that the above is done, time to chroot and mount the remaining virtual filesystems along with some environment variables. Run the following commands:
sudo chroot /mnt
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts
export HOME=/root
export LC_ALL=C
4. Time to update the system and or kernel. Run the following commands:
NOTE: replace KEYWORD for linux-apt-get update
apt-cache search KEYWORD
The apt-cache search command will search all the available linux kernels available in your repositories.
5. Now that you know what kernel you want, time to install it. Simply run the following command:
REMEMBER TO WRITE THE EXACT LINUX IMAGE AND LINUX HEADER IN THE ABOVE COMMAND.apt-get -y install linux-image linux-header
If you want to update the system and a newer kernel is available, then run the following command instead of the apt-get -y install above mentioned:
apt-get upgrade
6. There you go you have now upgraded/downgraded the kernel. Time to unmount some stuff.
Run the following commands in the same terminal window still (as chroot):
umount /proc || umount -lf /proc
umount /sys /dev/pts
exit
sudo umount /mnt/dev /mnt
7. Restart the system and boot into the OS without the live disk on (DVD/USB). Everything should be fine now.
Note that the above was not tested fully on Arch/Fedora/OpenSuse main and based off distros.
Hope this helps anyone who needs it.
Last edited: