Fix a Boot Stuck at “Loading initramfs” After Adding an NVMe to Ubuntu 24.04

When a new NVMe sticks, the boot can stall at “Loading initramfs”

Adding a second NVMe drive to an existing Ubuntu 24.04 installation is a quick way to get more storage or carve out a dedicated data partition.
Most of the time the kernel pulls the NVMe driver on its own, but a handful of mis‑configurations can make the system hang in the initramfs shell.
Typical symptoms:

  • The screen shows “Loading initramfs …” and then stops.
  • The prompt switches to a root shell (root@hostname:/#).
  • Nothing else happens until you manually exit or reboot.

Below is a hands‑on walk‑through of the most common culprits and how to fix them. I’ll assume you have a working Ubuntu 24.04 install and a spare NVMe device that you just plugged in.


1. Verify the hardware and firmware

Before you even touch the OS, make sure the NVMe device is physically seen by the BIOS/UEFI and that its firmware is up‑to‑date.

# In the BIOS/UEFI menu, confirm the NVMe appears in the boot device list.
# If it does not, check the cable, slot, and power connections.

If the BIOS shows the drive but the OS doesn’t, the kernel may be missing the NVMe driver or the initramfs might not contain it.


2. Boot into the initramfs shell

When the boot stalls, you’ll usually see a prompt:

root@hostname:/#

That’s the initramfs shell— a minimal environment with only the modules and binaries needed to mount the real root filesystem.


3. Inspect the kernel messages

The first clue is the output of dmesg. It tells you what the kernel tried to do before it froze.

dmesg | tail -n 50

Typical problematic lines:

[    2.123456] nvme 0000:00:1f.2: NVMe device found
…
[    2.123456] nvme: cannot find NVMe device

If you see a line like nvme: cannot find NVMe device or nvme: module not found, the initramfs is missing the driver.


4. List block devices and UUIDs

The initramfs shell can list the devices that the kernel has seen.

lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
blkid

You should see your new NVMe device (e.g. nvme0n1) and its partitions. Verify that the UUID you plan to use in /etc/fstab matches the output of blkid.


5. Check the root filesystem entry

The kernel command line (visible via cat /proc/cmdline) tells the initramfs which device to mount as root. A typo here will prevent the system from finding the root partition.

cat /proc/cmdline

Look for a root= parameter that references the correct UUID or device path. If you added the NVMe as a new root, you must update the GRUB entry accordingly.


6. Ensure the NVMe driver is in the initramfs

Ubuntu’s initramfs is built by update-initramfs. By default, the NVMe driver is included, but if you removed it or the kernel was built without it, you’ll need to add it manually.

6.1. Add the driver to /etc/initramfs-tools/modules

echo "nvme" | sudo tee -a /etc/initramfs-tools/modules
echo "nvme_core" | sudo tee -a /etc/initramfs-tools/modules

6.2. Rebuild the initramfs

sudo update-initramfs -u -k all

The -k all flag rebuilds every installed kernel’s initramfs, ensuring that the new modules are present for all kernels you might boot.


7. Verify that the kernel has the necessary modules

If you’re still stuck, boot a live USB of Ubuntu 24.04, mount the root partition, and chroot into it. From there you can test module loading.

sudo mount /dev/nvme0n1p1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt

Once inside the chroot:

modprobe nvme
modprobe nvme_core

If either command fails, the module is missing from the kernel package. Install the extra modules package:

apt update
apt install linux-modules-extra-$(uname -r)

After installation, rebuild the initramfs again (step 6.2) and exit the chroot.


8. Check the bootloader configuration

Secure Boot can block unsigned kernel modules. If you’re using Secure Boot, make sure the NVMe driver is signed. Ubuntu ships signed modules by default, but if you compiled a custom kernel, you may need to sign it yourself.

8.1. Inspect /etc/default/grub

Make sure the GRUB_CMDLINE_LINUX_DEFAULT line contains the correct root= and any rd.lvm or rd.luks options you use.

sudo nano /etc/default/grub

Typical line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

If you added the NVMe as a new root, update the UUID accordingly.

8.2. Update GRUB and reboot

sudo update-grub
sudo reboot

9. Common pitfalls and quick fixes

  • Forgot to add nvme to the initramfs – that’s the most common reason for a hang.
  • Wrong UUID in /etc/fstab – double‑check with blkid.
  • Secure Boot blocking a module – either disable Secure Boot or sign the module yourself.
  • Kernel too old – upgrade to the latest 24.04 kernel or install linux-modules-extra for your kernel version.

10. TL;DR

  1. Verify the drive shows up in BIOS.
  2. Reboot into initramfs shell.
  3. Check dmesg for NVMe errors.
  4. List devices with lsblk/blkid.
  5. Confirm root= in /proc/cmdline.
  6. Add nvme/nvme_core to /etc/initramfs-tools/modules and rebuild initramfs.
  7. If still failing, chroot and load modules; install linux-modules-extra.
  8. Update GRUB and reboot.

TAGS

linux, ubuntu, nvme, initramfs, troubleshooting


See also