January 26, 2022

How To Fix Initramfs Error On Ubuntu

 

This brief guide explains how to fix Busybox Initramfs error on Ubuntu Linux. I use Ubuntu 20.04 LTS as my daily driver on my Dell Inspiron laptop. Today I turned it on and the boot process dropped to the BusyBox shell and I ended up at the initramfs prompt.

As far as I can remember, I did nothing wrong. I didn't forcibly power off it. It was working just fine yesterday! When I switched it on today, I landed in the BusyBox shell:

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)

I can't get past this screen. Also it doesn't show what exactly the problem is. All I see is just a blank busybox shell.

I wasn't sure what to do at this point. So I simply passed the exit command to see what happens.

And then I saw the actual error:

(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)
Busybox Initramfs Error On Ubuntu
Busybox Initramfs Error On Ubuntu

As you can see in the above output, the /dev/sda1 partition is corrupted. The file system in this partition has some errors. If you ever encountered with this type of problem, you need to check and repair the problematic Linux filesystems with fsck command.

Please note that sometimes you don't see any errors after typing the exit command. In that case, try to run fsck on all filesystems.

For those wondering, BusyBox is software suite that provides many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc.

Initramfs is an initial ram file system based on tmpfs. It contains the tools and scripts required to mount the file systems before the init binary on the real root file system is called.

Fix Busybox Initramfs Error On Ubuntu Linux

1. To solve initramfs error on Ubuntu Linux, you need to repair the filesystem in the corrupted partition using fsck command like below:

(initramfs) fsck /dev/sda1 -y

Replace /dev/sda1 with your partition name. In your system, it could be /dev/sdb1, /dev/sdc1 etc. You can use cat /proc/partitions or blkid commands to get your Linux partition details in Busybox.

2. Now the fsck command will start to fix all bad blocks automatically in the filesystem.

After a couple minutes, you will see an output like below:

/dev/sda1: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda1: 497733/30531584 files (1.5% non-contiguous), ........

3. Next, type reboot and hit ENTER to restart your system!

(initramfs) reboot
Fix Busybox Initramfs Error On Ubuntu Linux
Fix Busybox Initramfs Error On Ubuntu Linux

If the reboot command doesn't work, type exit and hit ENTER.

Cross your fingers and wait for the system to reboot! If all went well, your system will boot normally without any problem.

These steps helped me and many others (see the comment section below) to solve Busybox Initramfs error on Ubuntu Linux operating system. If you are stuck in initramfs prompt, this guide will definitely help.

Heads Up: If you keep getting this error often, probably your hard disk is getting weaker. In that case, it is recommended to backup the data and replace the hard disk as soon as possible.



If your Ubuntu system is crashed due to power failure or network connectivity issue in the middle of the upgrade process, you might end up with broken Ubuntu. In that case, you can easily fix broken Ubuntu without reinstalling it as described in the following guide.
How To Fix Broken Ubuntu OS Without Reinstalling It



Source: https://ostechnix.com/how-to-fix-busybox-initramfs-error-on-ubuntu/