“Initramfs unpacking failed: invalid magic at start of compressed archive” error (SOLVED)
November 28, 2022
This article will show you how to fix the Linux won't boot error. In this case, the solution is shown using Kali Linux as an example, but the steps are also applicable to Debian, Ubuntu, Linux Mint, and derivative distributions.
An error occurred while booting Linux:
Initramfs unpacking failed: invalid magic at start of compressed archive Kernel panic — not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
The bottom line is that it was not possible to unpack the Initramfs due to archive corruption. Without this, the loading and operation of the operating system is impossible.
However, you can try to solve this problem without booting from a rescue disk (for example, a Live CD image).
First, try booting into Recovery Mode/Root Access on your current kernel.
To do this, select “Advanced options” in the bootloader.
Then select the item with “recovery mode” – usually the second line.
If you managed to do this, then run the following command:
sudo update-initramfs -c -k $(uname -r)
In my case, the error message changed, but the system was never booted.
If it was not possible to boot into recovery mode, then boot with a previous version of the kernel.
My system booted successfully with the previous version:
Now we need to recreate the ramdisk file. This can be done with a special command, but you need to know the kernel version number. Also, the ramdisk file is recreated each time a Linux kernel package is installed. Let's consider both options.
1. Reinstalling the Linux kernel
To reinstall the kernel, run the command:
sudo apt install linux-image-amd64
This command is suitable for 64-bit systems, if you have a 32-bit or ARM computer, then use the appropriate kernel package name linux-image-*
The previous command didn't work, and I got an error:
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
To fix the error, it is recommended to run the following command:
sudo dpkg --configure -a
It also didn't work and generated an error:
dpkg: error: fgets gave an empty string from ‘/var/lib/dpkg/triggers/Unincorp’
To fix it:
sudo rm /var/lib/dpkg/triggers/Unincorp sudo touch /var/lib/dpkg/triggers/Unincorp
Then the command to fix problems with packages was successfully executed:
sudo dpkg --configure -a
During its execution, the ramdisk file was re-created (as a step in setting up one of the packages), that is, reinstalling the Linux kernel was not required. After that I rebooted Linux and the operating system booted up as usual.
2. Generate ramdisk file
To generate an initramfs (ramdisk), you need to run a command like:
sudo update-initramfs -c -k VERSION
Instead of NUMBER, you need to specify the latest version of the Linux kernel installed on your system. That is, this is the version that causes problems.
You can view the available kernels with the command:
ls -al /boot
итого 149988 drwxr-xr-x 4 root root 4096 ноя 27 06:02 . drwxr-xr-x 20 root root 4096 ноя 15 03:40 .. -rw-r--r-- 1 root root 254811 окт 10 16:05 config-5.19.0-kali2-amd64 -rw-r--r-- 1 root root 257010 ноя 7 16:51 config-6.0.0-kali3-amd64 drwx------ 3 root root 4096 янв 1 1970 efi drwxr-xr-x 6 root root 4096 ноя 27 06:00 grub -rw-r--r-- 1 root root 67132798 ноя 9 03:32 initrd.img-5.19.0-kali2-amd64 -rw-r--r-- 1 root root 70411394 ноя 27 06:02 initrd.img-6.0.0-kali3-amd64 -rw-r--r-- 1 root root 83 окт 10 16:05 System.map-5.19.0-kali2-amd64 -rw-r--r-- 1 root root 83 ноя 7 16:51 System.map-6.0.0-kali3-amd64 -rw-r--r-- 1 root root 7703168 окт 10 16:05 vmlinuz-5.19.0-kali2-amd64 -rw-r--r-- 1 root root 7788992 ноя 7 16:51 vmlinuz-6.0.0-kali3-amd64
The kernel version is numbers followed by words. For example, on this system, the latest kernel version is “6.0.0-kali3-amd64”. Then the command to create a new initramfs file is:
sudo update-initramfs -c -k 6.0.0-kali3-amd64
After that restart your computer:
- Error “Cannot open access to console, the root account is locked” (SOLVED) (100%)
- How to determine why Linux boots into Emergency mode (100%)
- How to repair an LVM disk using fsck (100%)
- dpkg: error: fgets gave an empty string from '/var/lib/dpkg/triggers/Unincorp' (SOLVED) (83.9%)
- UEFI does not see installed Linux (SOLVED) (67.8%)
- phpMyAdmin error “Error: Undefined constant "SODIUM_CRYPTO_SECRETBOX_KEYBYTES"” (SOLVED) (RANDOM - 51.7%)