Skip to content

Recover a Linux server that will not boot: GRUB, initramfs and emergency mode

Triage a Linux server that will not boot by the stage where it stopped: the grub rescue prompt, the (initramfs) BusyBox shell, systemd emergency mode, or a VFS kernel panic — with the chroot repair for when there is no shell at all.

When a Linux server refuses to come up, the most useful fact on the screen is where it stopped. A grub rescue> prompt, an (initramfs) BusyBox shell, an emergency-mode password prompt and a kernel panic all look equally final, but they are four failures at four points in the boot chain and the fix for one does nothing for the others: reinstalling GRUB will not repair a dirty root filesystem, and fsck will not fix a bad /etc/fstab. This guide is organised by stage. Read the last line printed, find the matching section, work from there.

What you’ll accomplish

  • Name the failed boot stage from the last line on the console instead of guessing.
  • Hand-boot from a grub rescue> prompt, then make the repair permanent.
  • Repair a root filesystem or a stale root= UUID from the (initramfs) BusyBox shell.
  • Leave systemd emergency mode and fix the /etc/fstab entry that put you there.
  • Repair a machine with no shell at all from a rescue ISO, with the bind mounts that make chroot work.

Prerequisites

  • A console you can type into. IPMI, iDRAC or iLO on hardware; the provider’s serial console or VNC viewer on a cloud VM. Open it before anything else — without one you are only watching a machine that does not answer.
  • Root or sudo, plus the root password if you land in emergency mode.
  • A rescue image you can attach: the provider’s rescue mode, or a live ISO matching the architecture and no older than the installed system.
  • Firmware awareness. BIOS/MBR machines keep GRUB’s first stage in a disk’s boot sector, so grub-install /dev/sda targets a whole disk. UEFI machines keep a .efi binary on the EFI System Partition, which must be mounted at /boot/efi first.
  • Distribution tool names differ. Debian and Ubuntu use update-grub and update-initramfs; the RHEL family uses grub2-mkconfig -o /boot/grub2/grub.cfg and dracut, with config at /boot/grub2/grub.cfg rather than /boot/grub/grub.cfg. Commands typed at the grub rescue> prompt are identical everywhere.

How it works

Four handoffs stand between power-on and a login prompt, and each fails on its own terms.

Firmware locates a bootloader — a boot sector on BIOS, an EFI binary on the ESP under UEFI. That bootloader is GRUB’s core image, which knows almost nothing on its own: it must find its prefix directory (usually /boot/grub) to load the modules that read your filesystem and the menu in grub.cfg. If the partition moved or /boot was wiped, the core image loads and has nowhere to go. That is the grub rescue> prompt: GRUB alive but blind.

GRUB then loads a kernel and an initramfs and jumps into the kernel. The initramfs is a small compressed root filesystem holding exactly the drivers and scripts needed to find the real root. If it is absent, or was built without this machine’s storage driver, the kernel reaches the pivot with nothing to pivot to: VFS: unable to mount root fs on unknown-block(0,0), then panic. If it runs but cannot mount the device named by root=, its scripts instead give up at an (initramfs) BusyBox prompt — the device is unreadable, dirty, or simply not what root= names, classically a cloned disk whose filesystem UUID no longer matches.

Once root is mounted, systemd pulls in local-fs.target, which includes every /etc/fstab entry. A failed mount or a device that never appears blocks that target, and systemd falls back to emergency.target: one root shell, nothing else started.

Decision tree keyed on the boot stage where the server stopped, showing four branches — bootloader with a grub rescue prompt, kernel with a VFS unable to mount panic, initramfs with a BusyBox prompt, and systemd emergency or rescue mode — each with its likely cause and first recovery commands

Step-by-step

  1. Get a console and read the last line. Everything below depends on it. If a graphical splash hides the messages, reboot and press Esc (UEFI) or hold Shift (BIOS) to reach the GRUB menu. Write the last line down verbatim before rebooting — it may scroll away. If you do have a shell, the kernel’s own complaints are the fastest read:

    dmesg --level=err,crit,alert,emerg

    Expected: I/O errors, filesystem complaints, or nothing at all. Nothing at all means the failure is above the kernel.

  2. If you see grub rescue>: find the partition GRUB lost. The rescue shell has four useful commands: ls, set, insmod, normal. List what the firmware sees, then probe partitions until one holds the GRUB directory.

    ls
    ls (hd0,gpt2)/

    Expected: ls prints something like (hd0) (hd0,gpt1) (hd0,gpt2). Each probe returns either error: unknown filesystem or a listing; you want the partition holding /boot/grub/, or a top-level /grub/ if /boot is separate.

  3. Point GRUB at it and boot by hand. root is where GRUB reads from, prefix where its modules live. Neither survives a reboot; this is a one-shot boot to get you a real shell.

    set root=(hd0,gpt2)
    set prefix=(hd0,gpt2)/boot/grub
    insmod normal
    normal

    Expected: the normal GRUB menu appears and entries boot. Drop /boot from prefix if /boot is a separate partition. error: file not found means the prefix path is wrong.

  4. Make the GRUB repair permanent. Nothing typed at the rescue prompt survived, so reinstall the bootloader and regenerate the menu from the booted system.

    sudo grub-install /dev/sda
    sudo update-grub

    Expected: Installing for i386-pc platform. then Installation finished. No error reported., and a Found linux image: /boot/vmlinuz-... line per kernel. On UEFI, grub-install takes no device argument, and grub-install: error: cannot find EFI directory. means the ESP is not mounted at /boot/efi. RHEL-family equivalents: grub2-install /dev/sda and grub2-mkconfig -o /boot/grub2/grub.cfg.

  5. If it reaches a menu but then fails: try an older kernel first. Open Advanced options for … and pick the previous kernel. If that boots, the newest kernel or its initramfs is the culprit and you have a working system to repair from — by a wide margin the cheapest outcome.

    sudo update-initramfs -u -k all

    Expected: one update-initramfs: Generating /boot/initrd.img-... line per installed kernel. On the RHEL family, sudo dracut -f --regenerate-all prints nothing on success.

  6. Edit the kernel line for a one-shot boot. Highlight a menu entry, press e, edit the line beginning with linux (or linux16/linuxefi), then press Ctrl-x or F10. Nothing is written to disk. Two edits earn their keep: delete quiet and splash so kernel messages become visible, and append systemd.unit=rescue.target for a single-user shell with root mounted. As a last resort init=/bin/bash gives a shell before systemd starts at all — root is read-only there, so mount -o remount,rw / comes first and sync before rebooting.

  7. If you see (initramfs): compare root= against reality. BusyBox carries enough tools to settle this.

    cat /proc/cmdline
    blkid

    Expected: /proc/cmdline contains root=UUID=6f1a..., and blkid lists every block device with its UUID= and TYPE=. No match between them means the disk was cloned, restored or replaced. blkid showing nothing at all means the initramfs lacks the storage driver — jump to step 9.

  8. Check the root filesystem. If the UUID matches, it is probably dirty. Run the checker against the device, never a mount point, and never on a mounted filesystem.

    fsck -fy /dev/sda2

    Expected: passes 1 through 5, then a summary like /dev/sda2: 128516/1310720 files (0.2% non-contiguous). -f forces a check even if the filesystem claims to be clean; -y answers yes to every repair. XFS has no equivalent — xfs_repair /dev/sda2 is a rescue-ISO job, since it is absent from the initramfs. Then type exit to resume the boot; dropping straight back to (initramfs) means the filesystem was not the problem.

  9. Fix a cloned disk: the UUID, or the missing driver. If root= names a UUID that no longer exists, either edit /etc/fstab and re-run update-grub from a chroot, or put the old UUID back with sudo tune2fs -U <uuid> /dev/sda2 (ext2/3/4 only; xfs_admin -U for XFS). If no disks appeared at all, the initramfs was built for a different storage stack — regenerate it from a chroot with a wider module set. Debian and Ubuntu take MODULES=most in /etc/initramfs-tools/initramfs.conf; the RHEL family takes explicit drivers.

    sudo dracut -f --add-drivers "virtio_blk virtio_pci nvme" --regenerate-all

    Expected: silence, then a fresh /boot/initramfs-<version>.img with a current timestamp. Confirm the driver landed with lsinitrd /boot/initramfs-<version>.img | grep virtio (lsinitramfs on Debian).

  10. If you reach emergency mode: read the failures, not the fstab. systemd already knows what broke. Log in with the root password, then ask it.

    systemctl --failed
    journalctl -xb

    Expected: systemctl --failed lists units in red — a mount unit such as mnt-backup.mount, or a check unit such as systemd-fsck@dev-sdb1.service. journalctl -xb shows this boot’s log with explanatory notes; search it for Dependency failed for and Timed out waiting for device. Our journalctl guide covers the filters that make it readable. Cannot open access to console means no root password is set — reboot and use init=/bin/bash from step 6.

  11. Repair the /etc/fstab entry and validate before rebooting. Root is read-write in emergency mode, so edit directly. For any mount the system does not need in order to function, add nofail so its absence cannot block boot, plus a short device timeout so you do not wait 90 seconds for a device that will never appear.

    UUID=1c9d... /srv/data ext4 defaults,nofail,x-systemd.device-timeout=10s 0 2
    sudo findmnt --verify --verbose
    sudo systemctl daemon-reload
    sudo mount -a

    Expected: findmnt --verify prints each entry then Success, no errors or warnings detected, and mount -a returns silently. daemon-reload matters because systemd generates and caches a .mount unit per fstab line. Then sudo systemctl default leaves emergency mode without a reboot.

  12. If there is no shell at all: repair from a rescue ISO. Boot the provider’s rescue mode or a live ISO, mount the broken system, and enter it. The bind mounts are not optional — grub-install, update-grub and dracut all read from /dev, /proc and /sys, and fail in confusing ways without them.

    Six-step sequence for repairing an unbootable system from a rescue ISO: identify disks with lsblk and blkid, mount the root filesystem under /mnt, mount the EFI partition on UEFI machines, bind-mount /dev /proc /sys and /run, chroot into the system, then reinstall GRUB and unmount cleanly

    lsblk -f
    sudo mount /dev/sda2 /mnt
    sudo mount /dev/sda1 /mnt/boot/efi
    for d in dev proc sys run; do sudo mount --rbind /$d /mnt/$d; done
    sudo chroot /mnt /bin/bash

    Expected: lsblk -f shows every partition with its filesystem, label and UUID, so you can pick the right root. After chroot the prompt changes and cat /etc/hostname prints the broken server’s name rather than the ISO’s. chroot: failed to run command '/bin/bash': No such file or directory means the wrong partition, or an architecture mismatch. Skip the ESP line on BIOS/MBR machines.

  13. Do the repair, then unmount cleanly.

    grub-install /dev/sda
    update-grub
    update-initramfs -u -k all
    exit
    sudo umount -R /mnt
    sudo reboot

    Expected: umount -R returns silently. target is busy means something is still running inside; sudo fuser -vm /mnt names it. Detach the ISO before rebooting, or you will boot it again.

Validate it works

A machine that boots once after a manual rescue is not fixed; it is lucky. Reboot it, and once SSH answers again:

systemctl is-system-running
systemctl --failed

Expected: running, and an empty failed list. degraded means something is still failing, and systemctl --failed names it.

Then confirm the boot chain itself is intact:

sudo findmnt --verify --verbose
lsinitramfs /boot/initrd.img-$(uname -r) | grep -c .
cat /proc/cmdline

Expected: no errors from findmnt --verify; an initramfs listing counted in the thousands, not 0; and a root= that matches a UUID in blkid. On the RHEL family use lsinitrd and /boot/initramfs-$(uname -r).img.

Finally, journalctl --list-boots should show several boots with timestamps. If only 0 appears, the journal is volatile and every failed boot is discarded on reboot — fix that with persistent journald storage before you need it.

Troubleshooting

  • grub-install reports success but the machine still lands at grub rescue>. You installed to the wrong disk: the firmware may boot /dev/sdb while you keep reinstalling to /dev/sda. Under UEFI, efibootmgr -v shows the disk and .efi path actually registered. Software RAID needs GRUB on every member disk.
  • fsck fixes errors, you reboot, and the same errors come back. The filesystem is not the problem — the storage under it is. Check smartctl -a /dev/sda for reallocated sectors and dmesg | grep -i 'I/O error' for media errors. Repeated corruption in the same block range means the disk is dying; image it and restore elsewhere.
  • Emergency mode returns immediately after you fix fstab. Either you skipped systemctl daemon-reload, so systemd still uses units generated from the old file, or the failure was never a mount — check what else systemctl --failed names.
  • Chroot commands fail with Failed to connect to bus. The bind mounts are incomplete; /run is the one people forget. Exit, mount all four, re-enter. systemctl stays unhappy regardless, since it cannot talk to a PID 1 that is not running.
  • After the fix, boot stalls for 90 seconds. That is systemd’s default device timeout waiting for something in /etc/fstab that no longer exists. systemd-analyze blame names the unit. Add nofail,x-systemd.device-timeout=10s, or delete the line.

When this is the wrong approach

Recovery earns its keep when the machine holds state you cannot reproduce and the failure is understood. It stops earning its keep surprisingly fast. If the server is built by configuration management and its data lives elsewhere, rebuilding usually finishes before a chroot session has diagnosed anything — and leaves you a machine whose state you actually know.

On a cloud VM that logic is stronger still. Detaching the boot volume, attaching it to a second instance as a data disk, fixing it there and reattaching is often faster than driving a repair through a laggy VNC console. And if you have a snapshot from before the change that broke it, restoring beats every procedure here.

Stop and restore from backup when fsck reports structural damage across many inodes, when the disk shows media errors, or when the outage now costs more than the rebuild. A machine that only boots after manual GRUB commands is not repaired — it is a rehearsal for the next outage.

Keep the GNU GRUB manual open for the rescue-prompt commands and device naming, and Ubuntu’s server documentation for the Debian-family initramfs and boot tooling.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.