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/fstabentry that put you there. - Repair a machine with no shell at all from a rescue ISO, with the bind mounts that make
chrootwork.
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/sdatargets a whole disk. UEFI machines keep a.efibinary on the EFI System Partition, which must be mounted at/boot/efifirst. - Distribution tool names differ. Debian and Ubuntu use
update-grubandupdate-initramfs; the RHEL family usesgrub2-mkconfig -o /boot/grub2/grub.cfganddracut, with config at/boot/grub2/grub.cfgrather than/boot/grub/grub.cfg. Commands typed at thegrub 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.
Step-by-step
-
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 holdShift(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,emergExpected: I/O errors, filesystem complaints, or nothing at all. Nothing at all means the failure is above the kernel.
-
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:
lsprints something like(hd0) (hd0,gpt1) (hd0,gpt2). Each probe returns eithererror: unknown filesystemor a listing; you want the partition holding/boot/grub/, or a top-level/grub/if/bootis separate. -
Point GRUB at it and boot by hand.
rootis where GRUB reads from,prefixwhere 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 normalExpected: the normal GRUB menu appears and entries boot. Drop
/bootfromprefixif/bootis a separate partition.error: file not foundmeans theprefixpath is wrong. -
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-grubExpected:
Installing for i386-pc platform.thenInstallation finished. No error reported., and aFound linux image: /boot/vmlinuz-...line per kernel. On UEFI,grub-installtakes no device argument, andgrub-install: error: cannot find EFI directory.means the ESP is not mounted at/boot/efi. RHEL-family equivalents:grub2-install /dev/sdaandgrub2-mkconfig -o /boot/grub2/grub.cfg. -
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 allExpected: one
update-initramfs: Generating /boot/initrd.img-...line per installed kernel. On the RHEL family,sudo dracut -f --regenerate-allprints nothing on success. -
Edit the kernel line for a one-shot boot. Highlight a menu entry, press
e, edit the line beginning withlinux(orlinux16/linuxefi), then pressCtrl-xorF10. Nothing is written to disk. Two edits earn their keep: deletequietandsplashso kernel messages become visible, and appendsystemd.unit=rescue.targetfor a single-user shell with root mounted. As a last resortinit=/bin/bashgives a shell before systemd starts at all — root is read-only there, somount -o remount,rw /comes first andsyncbefore rebooting. -
If you see
(initramfs): compareroot=against reality. BusyBox carries enough tools to settle this.cat /proc/cmdline blkidExpected:
/proc/cmdlinecontainsroot=UUID=6f1a..., andblkidlists every block device with itsUUID=andTYPE=. No match between them means the disk was cloned, restored or replaced.blkidshowing nothing at all means the initramfs lacks the storage driver — jump to step 9. -
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/sda2Expected: passes 1 through 5, then a summary like
/dev/sda2: 128516/1310720 files (0.2% non-contiguous).-fforces a check even if the filesystem claims to be clean;-yanswers yes to every repair. XFS has no equivalent —xfs_repair /dev/sda2is a rescue-ISO job, since it is absent from the initramfs. Then typeexitto resume the boot; dropping straight back to(initramfs)means the filesystem was not the problem. -
Fix a cloned disk: the UUID, or the missing driver. If
root=names a UUID that no longer exists, either edit/etc/fstaband re-runupdate-grubfrom a chroot, or put the old UUID back withsudo tune2fs -U <uuid> /dev/sda2(ext2/3/4 only;xfs_admin -Ufor 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 takeMODULES=mostin/etc/initramfs-tools/initramfs.conf; the RHEL family takes explicit drivers.sudo dracut -f --add-drivers "virtio_blk virtio_pci nvme" --regenerate-allExpected: silence, then a fresh
/boot/initramfs-<version>.imgwith a current timestamp. Confirm the driver landed withlsinitrd /boot/initramfs-<version>.img | grep virtio(lsinitramfson Debian). -
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 -xbExpected:
systemctl --failedlists units in red — a mount unit such asmnt-backup.mount, or a check unit such assystemd-fsck@dev-sdb1.service.journalctl -xbshows this boot’s log with explanatory notes; search it forDependency failed forandTimed out waiting for device. Our journalctl guide covers the filters that make it readable.Cannot open access to consolemeans no root password is set — reboot and useinit=/bin/bashfrom step 6. -
Repair the
/etc/fstabentry 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, addnofailso 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 2sudo findmnt --verify --verbose sudo systemctl daemon-reload sudo mount -aExpected:
findmnt --verifyprints each entry thenSuccess, no errors or warnings detected, andmount -areturns silently.daemon-reloadmatters because systemd generates and caches a.mountunit per fstab line. Thensudo systemctl defaultleaves emergency mode without a reboot. -
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-grubanddracutall read from/dev,/procand/sys, and fail in confusing ways without them.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/bashExpected:
lsblk -fshows every partition with its filesystem, label and UUID, so you can pick the right root. Afterchrootthe prompt changes andcat /etc/hostnameprints the broken server’s name rather than the ISO’s.chroot: failed to run command '/bin/bash': No such file or directorymeans the wrong partition, or an architecture mismatch. Skip the ESP line on BIOS/MBR machines. -
Do the repair, then unmount cleanly.
grub-install /dev/sda update-grub update-initramfs -u -k all exitsudo umount -R /mnt sudo rebootExpected:
umount -Rreturns silently.target is busymeans something is still running inside;sudo fuser -vm /mntnames 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-installreports success but the machine still lands atgrub rescue>. You installed to the wrong disk: the firmware may boot/dev/sdbwhile you keep reinstalling to/dev/sda. Under UEFI,efibootmgr -vshows the disk and.efipath actually registered. Software RAID needs GRUB on every member disk.fsckfixes errors, you reboot, and the same errors come back. The filesystem is not the problem — the storage under it is. Checksmartctl -a /dev/sdafor reallocated sectors anddmesg | 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 elsesystemctl --failednames. - Chroot commands fail with
Failed to connect to bus. The bind mounts are incomplete;/runis the one people forget. Exit, mount all four, re-enter.systemctlstays 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/fstabthat no longer exists.systemd-analyze blamenames the unit. Addnofail,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.