Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What initramfs Does

The bootloader loads two files: the kernel and the initramfs image. The kernel unpacks the image into memory and runs the script inside it. That script loads the drivers for the disk controller and the file system, sets up LVM, RAID, or encryption if used, finds the root file system by the UUID or name on the kernel command line, mounts it, and hands over to systemd. Background on the kernel is in what is a kernel.

Where the Image Lives

DistributionImage file
Debian, Ubuntu/boot/initrd.img-VERSION
AlmaLinux, Rocky/boot/initramfs-VERSION.img
uname -r
ls -lh /boot

There is one image per installed kernel, built automatically when a kernel package is installed.

Rebuild the Image

Rebuild it after you change storage drivers, encryption, or LVM settings, or after moving the system to other hardware. First check that /boot has room with df -h /boot. On Debian and Ubuntu:

sudo update-initramfs -u
sudo update-initramfs -u -k all

On AlmaLinux and Rocky Linux:

sudo dracut -f
sudo dracut -f --regenerate-all

In each pair, the first line rebuilds the image of the running kernel and the second rebuilds all of them.

Stuck at the (initramfs) Prompt

SSH is not running at this stage, so open the server console in your provider's control panel. The prompt is a small BusyBox shell with few commands. Read the lines above it: they name the problem and usually the device. AlmaLinux and Rocky Linux show a similar dracut emergency shell.

File System Errors: Run fsck

When the message says the root file system needs a manual check, it names the device, for example /dev/sda1, /dev/vda1, or an LVM path under /dev/mapper. Root is not mounted yet at this prompt, which is the condition fsck needs: never run it on a mounted file system. If your provider offers disk snapshots, take one first.

fsck -y /dev/vda1
exit

-y answers yes to every repair question. exit continues the boot. If fsck reports that it changed the file system, run it again until it finishes clean. fsck does nothing on XFS, the default on AlmaLinux and Rocky Linux; there the tool is xfs_repair. Details and options are in fsck: check and repair a file system.

Root Device Not Found

The kernel looks for a UUID that no disk has, for example after a partition was recreated or a disk was cloned. Compare the two at the prompt:

blkid
cat /proc/cmdline

If root=UUID= on the command line differs from the UUID that blkid shows for the root partition, boot once with a corrected value: in the GRUB menu (press Esc or hold Shift during boot if it is hidden) press e, fix the root= value on the line that starts with linux, and press Ctrl+X. In the running system, correct /etc/fstab as described in fstab explained, then run sudo update-grub on Debian and Ubuntu, or sudo grubby --update-kernel=ALL --args="root=UUID=NEW_UUID" on AlmaLinux and Rocky Linux. If GRUB itself does not start, see GRUB rescue.

Missing Driver After a Move

If blkid lists no disk at all, the image probably lacks the driver for the disk controller, which happens after a disk or virtual machine moves to another hypervisor or controller type. Boot the rescue system from your provider's control panel, then mount the root file system and rebuild from inside it:

mount /dev/vda1 /mnt
for d in dev proc sys; do mount --bind /$d /mnt/$d; done
chroot /mnt
update-initramfs -u -k all                    # Debian, Ubuntu
dracut -f --regenerate-all --no-hostonly      # AlmaLinux, Rocky Linux
exit
umount -R /mnt

Use lsblk to find the right device. With LVM, run vgchange -ay before mounting. If /boot is a separate partition, mount it on /mnt/boot before the chroot. --regenerate-all builds images for the installed kernels rather than the rescue kernel, and --no-hostonly makes a larger, generic image with all common drivers. Then reboot from the normal disk; once it runs, sudo dracut -f --regenerate-all makes a smaller image for the new hardware.

A Full /boot Partition

When /boot runs out of space, the image is written incomplete and the next boot can stop at the prompt. Pick an older kernel under the advanced options in the GRUB menu, then on Debian and Ubuntu:

df -h /boot
sudo apt autoremove --purge
sudo update-initramfs -u -k all

On AlmaLinux and Rocky Linux, dnf removes the oldest kernel on its own once more are installed than installonly_limit in /etc/dnf/dnf.conf allows.

Was this answer helpful?
Loading...