Phase 4. Lesson 3 of 5. About 40 minutes.
Plain entry
If a machine will not boot, you need to know which step of the boot failed. FirmwareLow-level software stored on a chip inside a device that controls the hardware directly and runs before any operating system loads. Read more →, bootloaderThe small program the firmware starts first, whose only job is to find the operating system kernel, load it into memory, and hand over control. Read more →, kernel, or services each fail in a different way and each has its own fix. Ubuntu gives you a recovery menu for most of them, and the installer ISOA single file that holds an exact copy of an optical disc's contents, used to distribute operating system installers and boot virtual machines. Read more → is your last resort for the rest.
Terms
- GRUBGRand Unified Bootloader: the bootloader most Linux distributions use to show a boot menu, load the kernel and initramfs, and pass kernel parameters. Read more →: Ubuntu’s bootloader. Shows the boot menu.
- Kernel parameters: options passed to the kernel at boot, editable from GRUB.
- initramfsA small temporary filesystem the kernel loads into memory at boot, containing just enough tools and drivers to find and mount the real root filesystem. Read more →: a small temporary filesystemThe structure an operating system uses to organize data on a disk into files and folders, tracking names, sizes, permissions, and where each piece is stored. Read more → the kernel loads first to find and mount the real disk.
- Recovery mode: a GRUB entry that boots to a root menu with minimal services.
- emergency.target / rescue.target: systemdThe init system and service manager for most modern Linux distributions, responsible for booting the system and managing running services. Read more →’s minimal boot modes.
- chroot: running commands as if another disk were the root of the system. Used to repair an installed system from a live USB or ISO.
Depth
Which stage failed?
| Symptom | Stage | Go to |
|---|---|---|
| No logo, beeps, nothing | Firmware / hardware | Lesson 1.2, check hardware |
grub> or grub rescue> prompt | Bootloader | Fix GRUB below |
| Kernel panic, “unable to mount root fs” | Kernel / initramfs | Rebuild initramfs |
| Boots to “You are in emergency mode” | Services / filesystems (often /etc/fstab) | Lesson 4.4 |
| Boots, but no login screen | Display or service | Recovery mode, journalctl -b -1 |
Getting the GRUB menu
In a VM or with one OS installed, the menu is hidden. Hold Shift (BIOS) or tap Esc (UEFI) right after the firmware logo. In VirtualBox, click inside the window first so it gets the key. Ubuntu’s default /etc/default/grub has GRUB_TIMEOUT_STYLE=hidden and GRUB_TIMEOUT=0, so the window for the key is short; the next section makes the menu always show.
The top menu shows Ubuntu, Advanced options for Ubuntu, and on UEFI machines UEFI Firmware Settings. Choose Advanced options for Ubuntu, then the entry ending in (recovery mode), for example Ubuntu, with Linux 7.0.0-14-generic (recovery mode). You get the Recovery Menu:
resume: continue normal bootclean: try to make free spacedpkg: repair broken packagesfsck: check all filesystemsgrub: update the GRUB bootloadernetwork: enable networkingroot: drop to a root shell promptsystem-summary: show a short report
Pick root. It asks Press Enter for system maintenance (or press Control-D to continue):; press Enter for a root shell. If the menu header says (filesystem state: read-only), make the disk writable before you change anything:
mount -o remount,rw /
Running it when the disk is already writable does no harm.
Edit kernel parameters for one boot
At the GRUB menu, highlight Ubuntu and press e. Find the line starting with linux. At the end you can add:
systemd.unit=rescue.target: single-user rescue shellsystemd.unit=emergency.target: even more minimal, root may stay read-onlynomodeset: skip graphics drivers (black screen fixes) Press Ctrl+X to boot. Changes last for this boot only.
Make the menu permanent and visible
sudo cp /etc/default/grub /etc/default/grub.bak
sudo nano /etc/default/grub
Set:
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=5
Then:
sudo update-grub
Expected output on Ubuntu 26.04 (UEFI, kernel number environment-specific):
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-7.0.0-14-generic
Found initrd image: /boot/initrd.img-7.0.0-14-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
The os-prober warning is normal on a single-OS machine.
Rebuild initramfs
sudo update-initramfs -u -k all
Expected output, one line per installed kernel:
update-initramfs: Generating /boot/initrd.img-7.0.0-14-generic
The same command works whether the image is built by initramfs-tools (the desktop default) or dracut (used by Ubuntu 26.04 server cloud images).
Last resort: repair from the ISO (chroot)
When GRUB itself is gone, boot the Ubuntu ISO you verified in lesson 1.3 (attach it to the VM and move Optical up in the boot order, or pick it from the firmware boot menu). Choose Try Ubuntu, open a terminal:
lsblk -f # find your root (ext4) and EFI (vfat) partitions
sudo mount /dev/sda2 /mnt # root partition: check yours
sudo mount /dev/sdaX /mnt/boot # only if lsblk shows a separate /boot partition
sudo mount /dev/sda1 /mnt/boot/efi # EFI partition: check yours
for d in dev proc sys run; do sudo mount --rbind /$d /mnt/$d; done
sudo chroot /mnt
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu
update-grub
exit
sudo reboot
Device names differ by machine. Read lsblk -f carefully. Use --rbind, not --bind: it carries /sys/firmware/efi/efivars into the chroot. With plain --bind, grub-install prints EFI variables cannot be set on this system and does not create the boot entry. Success looks like Installation finished. No error reported., and efibootmgr then lists an Ubuntu entry pointing at \EFI\ubuntu\shimx64.efi. If sudo umount -R /mnt reports a busy target, use sudo umount -lR /mnt or just reboot. On an ARM Mac guest use --target=arm64-efi. On a legacy BIOS install use grub-install /dev/sda with no EFI options.
Going further
systemd-analyze shows boot time; systemd-analyze blame lists the slowest units; systemd-analyze critical-chain shows what each one waited on. efibootmgr -v shows UEFI boot entries, and a missing ubuntu entry explains a machine that boots straight to firmware setup.
Why it works this way
Boot is a chain: firmware, then GRUB, then the kernel and initramfs, then systemd. Each link hands off to the next, so the last thing you saw tells you which link broke. A firmware message means GRUB was never found. A GRUB prompt means the kernel or its config was not found. Kernel messages that stop means a driver or the root disk. That is why the lesson starts with “Which stage failed?” before any fix.
Self-check
- You see
grub rescue>. Which stage failed? - How do you boot one time into a rescue shell without changing any file?
- Which command applies changes to
/etc/default/grub? - What does
chroot /mntlet you do?
Answers: (1) Bootloader. (2) Press e in GRUB, add systemd.unit=rescue.target, Ctrl+X. (3) sudo update-grub. (4) Run commands as if the installed system were running, so tools like grub-install act on it.
Sources
- ArchWiki, GRUB: https://wiki.archlinux.org/title/GRUB
- Ubuntu community docs, Boot-Repair and recovery: https://help.ubuntu.com/community/RecoveryMode
- GNU GRUB manual: https://www.gnu.org/software/grub/manual/grub/
systemd.special(rescue and emergency targets): https://www.freedesktop.org/software/systemd/man/latest/systemd.special.htmlupdate-initramfs: https://manpages.ubuntu.com/manpages/resolute/man8/update-initramfs.8.html- CompTIA A+ Core 2 (220-1202), OS troubleshooting: https://www.comptia.org/certifications/a