Understanding the steps to fix boot error after upgrading Linux kernel
Published on 03 Jul 2021
Introduction Jump to heading
The other day I had a little bit of panic after upgrading the kernel. I wasn't able to boot into my operating system. All I see was a black screen with this error message.
[ 0.0000000] Initramfs unpacking failed: invalid magic at start of compressed archive
[ 0.0000000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block
[ 0.0000000] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 5.4.124-1-MANJARO #1
...
...
...
[ 0.0000000] --- [ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown block]
After looking around the forums, I found this.
Apparently, it is caused by a change in the compression algorithm so you had to uncomment the COMPRESSION="lz4"
line in /etc/mkinitcpio.conf
.
After replicating the steps, it is now working again.
But this post is not just on how to fix them but more to understanding why this fix works. So I will be breaking down each step.
Steps and explanation Jump to heading
Here were the steps:
-
Run live system
I had to boot into Windows to create a bootable USB for this. I downloaded the ISO image from Manjaro’s site and used Rufus to create the bootable USB.
Restart your computer and choose to boot from USB. From there, you have the option to boot with Open Source drivers or proprietary drivers. I went with proprietary since I’m using a Nvidia graphics driver. Wait for a while until you get to the next screen.
-
Start terminal
Open terminal by pressing Ctrl+Alt+T. Alternatively, you can open it from the start menu.
-
Run
su
to be rootThis command simply switches you into to root user.
-
Run
manjaro-chroot -a
From the archwiki page,
An operation that changes the apparent root directory for the current running process and their children. A program that is run in such a modified environment cannot access files and commands outside that environmental directory tree
You need to be in a
chroot
environment in order to mount the boot device.manjaro-chroot
provides a helper to scan any mounted devices with the use of the-a
flag. Otherwise, you would have to manually mount the boot device. You can read more about it here. -
Edit
etc/mkinitcpio.conf
as shown in the link#COMPRESSION="lz4"
COMPRESSION="lz4" -
Run
mkinitcpio -P
mkinitcpio
is a script to create aninitrd
(initial ramdisk) environment also known asinitramfs
.initrd
is responsible for loading the necessary files for initial startup. You can read more aboutmkinitcpio
here.When run with the
-P
flag, it will regenerate theinitramfs
images with the changes that we made in step 5. -
Exit
chroot
and reboot
Moral of the story Jump to heading
Remember, always keep a boot disk around just in case you come across this issue again.