How to fix initramfs error in Ubuntu command line. This tutorial explains how to exit and recover from initramfs in Ubuntu and its Derivatives.
Instead of loading normally, the “initramfs” error in Ubuntu typically indicates that your system is unable to find its root filesystem during the boot process.
The “initramfs” error in Ubuntu can happen due to a variety of reasons, including issues with disk partitioning, corrupted filesystems, or missing files.
What is BustBox and Initramfs?
BusyBox is a software suite that provides several Unix utilities in a single executable file. It includes a variety of common utilities such as, ls
(list directory contents), cp
(copy files and directories), mv
(move or rename files and directories), rm
(remove files or directories) and many more executable commands.
initramfs (initial RAM filesystem) is a temporary filesystem that is loaded into memory during the Linux boot process. It serves as the first filesystem used by the operating system right after the kernel has been loaded, providing a way for the system to access necessary drivers, modules, and scripts that are needed to mount the root filesystem.
Both BusyBox and initramfs play a crucial role in ensuring that a Linux system can boot successfully and efficiently, especially in scenarios where resources are limited.
How To Fix Initramfs Error In Ubuntu Command Line
- To solve initramfs error on Ubuntu Linux, you need to repair the filesystem in the corrupted partition using fsck command. First enter exit at the initramfs prompt by typing “exit” and after press the Enter key. After this, the following shall appears at the prompt.
(initramfs) exit
/dev/sda1 contains a file system with errors, check forced.
Inode 4326476 extent tree (at level 1) could be narrower, IGNORED.
/dev/sda1: Inode 4326843 extent tree (at level 1) could be narrower, IGNORED.
/dev/sda1: Inode 4327012 extent tree (at level 1) could be narrower, IGNORED.
/dev/sda1: Inode 4329004 extent tree (at level 1) could be narrower, IGNORED.
/dev/sda1: Inodes that were part of a corrupted orphan linked list found.
/dev/sda1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
(i.e., without -a or -p options)
fsck exited with status code 4.
The root filesystem on /dev/sda1 requires a manual fsck.
BusyBox v1.30.1 (Ubuntu 1:1.30.1-4ubuntu6.1) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs)
As you can see in the above output, the /dev/sda1 partition is corrupted. The file system in this partition has some errors.
Now use the fsck command with the file system path which you have noted in the above command.
fsck -y
Since our filesystem (which shows error) is /dev/sda1, we shall run the following command
(initramfs) fsck /dev/sda1 -y
Note: Note the path of the file system which shows the error. To execute the commands given in the next steps, sSimply replace /dev/sda1 with your partition name.
- Once you execute the fsck command, it will start to fix all bad blocks in the corresponding filesystem.
- Next, type reboot and press ENTER to restart the system. You will have to enter the reboot command at the (initramfs) command prompt.
(initramfs) reboot
If the reboot command doesn’t work, type exit and hit ENTER.
Even if after executing these commands, you cannot fix it, please boot into the rescue mode and try to repair the Ubuntu Linux filesystem.