
Ubuntu stuck on initramfs

If your Ubuntu system is stuck on the initramfs
prompt, it usually indicates that the system is having trouble mounting the root filesystem. This can happen due to various reasons such as filesystem corruption, incorrect UUIDs in /etc/fstab
, or hardware issues. Here are some steps you can take to troubleshoot and resolve the issue:
Problem Overview
If Ubuntu boots into the initramfs shell ((initramfs)
prompt), it usually means it can’t find or mount the root filesystem. Common causes:
-
Filesystem corruption
-
Wrong UUID in
/etc/fstab
-
Disk not detected
-
LVM/encryption issues
-
Hardware failure
Step-by-Step Fix
Step 1: Check if Disks Are Detected
At the (initramfs)
prompt, run:
ls /dev/sd*
Also try:
ls /dev/nvme*
You should see something like /dev/sda
, /dev/sda1
, /dev/nvme0n1p1
, etc.
❌ If nothing is shown, try loading drivers:
modprobe ahci # For SATA drives
modprobe nvme # For NVMe SSDs
modprobe dm-mod # For LVM or RAID
Then check again with ls /dev/sd*
.
Step 2: Identify Your Root Partition
If disks are listed, run:
blkid
You’ll see output like:
/dev/sda1: UUID="xxxx" TYPE="ext4"
If blkid
gives no output, try:
fdisk -l
Look for a Linux partition (usually ext4 or xfs). Example: /dev/sda1
, /dev/nvme0n1p2
.
Step 3: Run Filesystem Check (fsck)
Now run:
fsck -f /dev/sda1
Replace
/dev/sda1
with your partition.
If you get “no such file or directory”, double-check the device name.
If fsck finds and fixes errors, type:
reboot
If fsck still fails, try:
fsck -y /dev/sda1
This will automatically confirm fixes.
Step 4: Check for LVM or Encrypted Partitions (If Applicable)
If you’re using LVM or encryption:
lvm lvscan # List logical volumes
vgchange -ay # Activate all volume groups
Then:
fsck -f /dev/mapper/ubuntu--vg-root
Step 5: Check or Fix /etc/fstab (Advanced)
If fsck succeeds, try mounting the root partition:
mount /dev/sda1 /mnt
ls /mnt
If the root filesystem is visible:
nano /mnt/etc/fstab
Check for wrong UUIDs. Get the correct one using:
blkid
Compare UUIDs and correct them in /mnt/etc/fstab
.
Step 6: Rebuild Initramfs (Optional if root mounts)
If you’re still stuck, try this:
chroot /mnt # If you're in a live USB environment
update-initramfs -u
exit
Then reboot:
reboot
If Nothing Works – Use Live USB
If the issue cannot be fixed via initramfs, boot into a Ubuntu Live USB:
Step-by-Step:
-
Boot into Ubuntu Live USB
-
Open terminal
sudo fdisk -l # Find your root partition
sudo mount /dev/sda1 /mnt
sudo fsck -f /dev/sda1 # Check filesystem
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
update-initramfs -u
update-grub
exit
sudo reboot
Bonus: Reinstall GRUB (If Bootloader Is Corrupted)
In chroot from live USB:
grub-install /dev/sda # Not /dev/sda1!
update-grub
Check Disk Health (Optional but Recommended)
From live USB:
sudo apt install smartmontools
sudo smartctl -a /dev/sda
Look for Reallocated Sector Count, Pending Sectors, etc.
Summary
Step | Task |
---|---|
1️⃣ | Check disk detection: ls /dev/sd* |
2️⃣ | Identify partition: blkid or fdisk -l |
3️⃣ | Run fsck: fsck -f /dev/sda1 |
4️⃣ | For LVM: vgchange -ay , then fsck |
5️⃣ | Mount and check /etc/fstab |
6️⃣ | Rebuild initramfs: update-initramfs -u |
7️⃣ | Use Live USB if needed |
8️⃣ | Check disk health: smartctl -a /dev/sda |
9️⃣ | Reinstall GRUB if needed |