Skip to content
Snell Rojas

Programming

Fixing the initramfs Error When Booting Ubuntu

Ubuntu boots to an (initramfs) prompt? Find the root partition, repair the disk with fsck, power off, and know what the error is telling you about your drive.

Snell RojasPublished 3 min read

I wrote this post in Spanish in 2023 and adapted it to English in 2026.

If you turn on your Linux/Ubuntu computer and get a message like this:

text
(initramfs)

Take a deep breath and use the commands I'm about to give you to repair the disk errors that are keeping Linux/Ubuntu from booting properly.

1. Get the list of connected sda devices #

First, you need to know the number of the sdaX partition that's affected, so you can swap that "X" for the right number. For that, use this command:

bash
lsblk -a

You're looking for the root partition, meaning the one mounted at /. It will look like the sda4 line near the bottom of this output:

text
(initramfs) lsblk -a

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0         0 loop
loop1    7:1    0         0 loop
loop2    7:2    0         0 loop
loop3    7:3    0         0 loop
loop4    7:4    0         0 loop
loop5    7:5    0         0 loop
loop6    7:6    0         0 loop
loop7    7:7    0         0 loop
sda      8:0    0 223,6G  0 disk
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda3   8:3    0  19,6G  0 part [SWAP]
└─sda4   8:4    0 203,5G  0 part /
sr0     11:0    1  1024M  0 rom

Now that we know the sda partition number, we can use the command that fixes the disk errors.

2. Repair the disk errors from initramfs #

Use the following command to repair the disk errors:

bash
fsck -f /dev/sda4

From here on, press Y every time initramfs asks whether you want to repair a section of the disk.

3. Power off the computer from initramfs #

Once you've finished repairing all the disk errors that were breaking the Linux/Ubuntu boot, you can turn off the computer. For that you'll need this command:

bash
poweroff -f

Wait for it to finish shutting down, give it about 5 seconds, and turn the computer back on. Everything should be back to normal.

The bottom line on the initramfs boot error #

If this happened to you, it's because your hard drive has a physical fault. In other words, the hardware is causing the problem, and you're only patching it with software for now.

I've had this problem with 2.5" solid-state drives, where the error shows up every now and then, even though I use that laptop as a server and never turn it off.

So the way to fix the initramfs boot error on Ubuntu/Linux once and for all is to buy a new drive and reinstall everything from scratch.