Recovering a system that will not boot
Work out where boot stops, then fix it: edit the kernel line in GRUB, use rescue targets and rd.break, and repair from rescue media with chroot and fsck.
From firmware to bootloader: UEFI and GRUBThe kernel command line and initramfssystemd as PID 1 and boot targetsMounting and fstabDisk encryption with LUKS
Recovering a system that will not boot
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Start by working out where boot stops: firmware, the GRUB menu or prompt, the kernel and initramfs, or systemd. Each stage has its own failures and its own way in.
- At the GRUB menu, `e` edits the kernel line for one boot only. Append `systemd.unit=rescue.target`, `systemd.unit=emergency.target`, `rd.break` or `init=/bin/bash` to stop early with a shell.
- A bad `/etc/fstab` line is the most common reason a server drops to emergency mode. Fix or comment it out, use `nofail` for non-essential mounts, and test with `mount -a` before rebooting next time.
- To reset a lost root password on the RHEL family: boot with `rd.break`, `mount -o remount,rw /sysroot`, `chroot /sysroot`, `passwd`, `touch /.autorelabel` for SELinux, then exit twice.
- When nothing on the disk boots, start rescue media, unlock and mount the root filesystem under `/mnt`, bind-mount `/dev`, `/proc`, `/sys` and `/run`, and `chroot` in to reinstall GRUB or rebuild the initramfs.
- Never repair a mounted filesystem. Run `e2fsck` or `xfs_repair` on an unmounted device, and treat `xfs_repair -L` as a last resort that can lose data.
Where did it stop?
A server that will not boot is stressful, because none of the tools from the rest of this group can run. The first job is not to fix anything. It is to work out where boot stopped, because each stage of the chain from firmware to GRUB, kernel and initramfs and systemd fails differently:
| What you see | Stage | Usual causes |
|---|---|---|
| No boot device, firmware screen | firmware | wrong boot order, broken ESP, Secure Boot rejection |
grub> or grub rescue> prompt |
bootloader | missing config, moved or resized partition |
| Kernel panic, “cannot find root”, dracut shell | kernel and initramfs | missing driver in initramfs, wrong root= UUID |
| “You are in emergency mode” | systemd | a failed /etc/fstab mount, failed fsck |
| Boots, but no one can log in | user space | lost password, broken PAM or SSH config |
Think of a car that will not start. Does the dashboard light up? Does the starter turn? Does the engine catch and die? Each answer rules out half the car.
On a cloud VM you get this view from the provider’s serial console. Enable that before you need it.
Stopping early from GRUB
At the GRUB menu, highlight the entry and press e. Find the line starting with linux, add a parameter at the end, and boot with Ctrl-X. The edit lasts for that boot only. Useful additions:
systemd.unit=rescue.target: systemd.special says rescue “pulls in the base system (including system mounts) and spawns a rescue shell”. Filesystems are mounted, and almost nothing else runs.systemd.unit=emergency.target, or justemergency: an emergency shell with no other services or mounts. The root filesystem may be read-only.rd.break: dracut’s man page says this drops “to a shell at the end” of the initramfs, before control passes to the real system. The real root is mounted read-only at/sysroot.init=/bin/bash: the kernel starts a shell instead of systemd. Nothing else runs, and root is read-only until you remount it.
Rescue and emergency mode ask for the root password. On systems where root has no password, as on Ubuntu by default, the emergency shell may refuse to open. Then init=/bin/bash or rescue media is the way in.
The fstab classic
The most common real-world boot failure is a bad line in /etc/fstab: a typo, a UUID that changed when a disk was replaced, or a network share that is not there. systemd.special says emergency mode is used when the check of a required filesystem fails, and a required mount that fails ends in the same place. The fix:
journalctl -xb # find the failed .mount unit and why
vi /etc/fstab # fix the line, or comment it out
systemctl daemon-reload
mount -a # test every line now, not at the next reboot
nofail on mounts the system can live without, from mounting and fstab, turns this failure into a warning.
Resetting a lost root password
On the RHEL family the documented route is rd.break:
# at the switch_root:/# prompt
mount -o remount,rw /sysroot
chroot /sysroot
passwd
touch /.autorelabel
exit
exit
The /.autorelabel step matters on SELinux systems from the SELinux lesson. The new /etc/shadow was written from outside the normal system and has the wrong label. Without a relabel, SELinux can stop logins from reading it. The relabel makes the next boot slower. On Debian and Ubuntu, init=/bin/bash, then mount -o remount,rw /, passwd, sync and a forced reboot does the same job. On RHEL 10, a Red Hat community thread reports that console= parameters on the kernel line can hide the shell, so remove them first.
All of this needs console access and an editable GRUB entry. That is the point: physical or console access has always meant root. A GRUB password, Secure Boot and disk encryption are what close that door.
Rescue media and chroot
When nothing on the disk boots, start a live or rescue image from USB, ISO or the cloud provider’s rescue mode, and repair the installed system from outside:
lsblk -f # find the root, /boot and ESP partitions
cryptsetup open /dev/nvme0n1p3 root # if encrypted
vgchange -ay # if LVM
mount /dev/mapper/vg-root /mnt
mount /dev/nvme0n1p2 /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot/efi
for d in dev proc sys run; do mount --rbind /$d /mnt/$d; done
chroot /mnt
Inside the chroot you run the installed system’s own tools: regenerate GRUB’s config (grub2-mkconfig -o ... or update-grub), reinstall the bootloader, or rebuild the initramfs (dracut -f or update-initramfs -u) after fixing a driver or UUID problem. The bind mounts are the step people forget, and without them those tools cannot see the disks or the EFI variables.
Repairing filesystems
Repair a filesystem only when it is unmounted, which is one reason rescue media exists. The e2fsck man page: “in general it is not safe to run e2fsck on mounted file systems”. Run e2fsck -f for ext4. For XFS, the xfs_repair man page says the filesystem “must be unmounted”, recommends mounting and unmounting once first so the kernel replays the log, and calls -L, which throws the log away, a last resort that “can cause the loss of user files and/or data”. Start with -n on either tool to see what it would change. If the disk itself is failing, copy the data off first.
Nothing in this lesson was run. There is no Linux machine here. Steps come from systemd.special, dracut.cmdline, e2fsck and xfs_repair man pages, read 2026-11-28, and from Red Hat’s root password reset procedure in its RHEL 8 documentation. The RHEL 10 console= note comes from a Red Hat community thread, not official documentation.
About the video
The embed is a 21-minute clip, 21:09 to 42:10, of Red Hat’s “Troubleshooting Linux Boot | Into the Terminal 115”, a live stream from July 2024. The clip covers its chapters on troubleshooting fstab, the initramfs and filesystem superblocks, the failures you are most likely to meet on a server. The stream continues with a /boot chapter at 42:10, and its earlier “What happens at boot?” chapter from 10:41 is a good review of the boot sequence. It does not, going by its chapters, cover root password resets or chroot from rescue media. Chris Titus Tech’s live-USB repair video and Red Hat’s short rescue-mode filesystem video are in deeper. I judged the stream from its chapters and description, and English from its English caption track.
Where this fits
This is the last lesson of the roadmap. You started with what a kernel and a distribution are, and finished bringing a machine back from a failed boot. Everything between, from packages and services to storage, networking and security, is what you check on the way back up.
Check yourself
A server reboots after maintenance and stops at 'You are in emergency mode', with a timeout for a mount in the log. What is the likely cause and the fix?
A filesystem in `/etc/fstab` could not be mounted, often a typo, a changed UUID or a missing disk. Log in, read `journalctl -xb`, fix or comment out the line, run `systemctl daemon-reload` and `mount -a` to test, then reboot. Add `nofail` to mounts the system can live without.
Why is `touch /.autorelabel` part of the root password reset on RHEL?
`passwd` run from the initramfs shell writes a new `/etc/shadow` without the right SELinux label. Without a relabel at the next boot, SELinux can stop logins from reading it.
After booting rescue media and running `chroot /mnt`, `grub2-install` fails because it cannot see devices. What step was missed?
Bind-mounting the live system's `/dev`, `/proc`, `/sys` and `/run` into `/mnt` before chrooting. Tools inside the chroot need those to find disks and firmware variables.
Anyone with console access can reset root this way. How is that prevented?
With a GRUB password, which stops editing the kernel line, Secure Boot and firmware passwords, which stop booting other media, and full-disk encryption, which keeps the data unreadable without the key.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.