From power-on to a login prompt: POST, UEFI and Secure Boot, GRUB 2, the kernel and initramfs, systemd targets, and the recovery paths you need when one of them breaks.
6 sections4 incidents10 questions6 labs
The boot chain, stage by stage
1POSTfirmware · BMCCPU, memory training, PCIe
2Boot managerUEFI NVRAMPicks the EFI binary
3shim + GRUB/boot/efi · /bootMenu, kernel line
4KernelvmlinuzDrivers, memory, CPUs
5initramfsdracut · initramfs-toolsFinds and mounts root
6switch_root/sysrootPivot to the real root
7systemdPID 1Dependency graph
8default.targetmulti-userServices, login
Firmware runs POST. A failure shows as beep codes, a POST code or an entry in the BMC event log. There is no journal yet.
The UEFI boot manager reads its NVRAM entries and loads an EFI executable from the ESP. Check them later with efibootmgr -v.
shim checks GRUB, GRUB reads its config and BLS entries, then loads the kernel and initramfs with the command line.
The kernel decompresses, brings up memory and CPUs, and starts built-in drivers. A panic here usually means no usable initramfs.
The initramfs loads storage drivers, assembles LVM, RAID and LUKS, and mounts root read-only at /sysroot.
switch_root frees the RAM filesystem and executes /sbin/init from the real root. rd.break stops right before this point.
systemd builds the unit graph, generates mount units from fstab and starts everything it can in parallel.
default.target is reached: services run and logins open. systemd-analyze shows how long each phase took.
Power-on, POST and firmware
Linux is not the first code that runs. When the power supply reports a stable rail, the CPU starts at its reset vector inside the firmware. Everything up to the boot loader belongs to the board vendor, and most "the server will not boot" tickets on physical hardware end here.
What POST actually does
Loads CPU microcode and trains memory: it reads each DIMM's SPD data and tunes timings. Memory training is why a server with a lot of RAM sits on a black screen for a minute or more.
Enumerates PCIe devices and runs their option ROMs: RAID controllers, NICs with PXE, GPUs.
Builds the hardware tables the kernel reads later: ACPI for power and topology, SMBIOS/DMI for inventory.
Hands control to the boot manager, which picks what to load next.
A failure here shows up as beep codes, a POST code on the board's debug display, or a lit fault LED. Linux has not started, so there is no journal.
Servers have a second computer: the BMC
Enterprise servers ship a baseboard management controller with its own network port and its own power. It keeps the System Event Log (SEL), reads sensors and gives you a remote console, even when the host is powered off.
bash
ipmitool sel elist # hardware events: ECC errors, PSU loss, thermal trips
ipmitool sdr type temperature # sensor readings
ipmitool chassis bootdev pxe # one-time boot device override
Newer platforms expose the same data through the Redfish REST API. In the cloud you never touch firmware. EC2 gives you the instance console output, a screenshot and the EC2 Serial Console for this phase instead.
UEFI or legacy BIOS
Legacy BIOS
UEFI
Where the loader lives
446 bytes of code in the MBR, the rest in the gap after it or in a BIOS boot partition on GPT
An EFI executable on the EFI System Partition, a FAT filesystem mounted at /boot/efi
How it is chosen
Fixed disk order in setup
Boot entries stored in NVRAM (Boot0001, BootOrder)
Disk label
MBR, limited to 2 TiB with 512-byte sectors
GPT
Signature checks
None
Optional Secure Boot
From a running system:
bash
[ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
efibootmgr -v # NVRAM entries and the file each one loads
dmidecode -t bios -t system # vendor, firmware version, serial number
If someone replaced a disk or restored an image and the machine ignores a perfectly good ESP, the NVRAM entry is usually missing. Recreate it from rescue media with efibootmgr --create, pointing to the shim binary of your distribution.
Secure Boot and GRUB 2
The chain of trust
With Secure Boot on, every stage checks the signature of the next one before running it. Distributions cannot ask Microsoft to sign every kernel, so they insert a small first-stage loader, shim.
2shimx64.efisigned by MicrosoftCarries the distro certificate and MOK
verifies
3grubx64.efisigned by the distroAsks shim to check the kernel
verifies
4Kernelsigned by the distroLockdown mode
verifies
5Modulessigned or MOKUnsigned modules refused
The firmware trusts the certificates in db. Revoked hashes in dbx, and SBAT generations in shim, block known-vulnerable loaders.
shim is signed with the Microsoft UEFI CA, so the firmware runs it. It embeds the distribution certificate and reads enrolled MOKs.
shim verifies GRUB against the distribution certificate. A tampered GRUB stops the boot with a security violation.
GRUB asks shim to verify the kernel. The kernel starts in lockdown, which restricts raw memory and hardware access.
Modules must be signed by the distribution or by a key you enrolled with mokutil. A DKMS driver without a MOK will not load.
The firmware's db holds the certificates it trusts. Its dbx holds revoked hashes and certificates.
shimx64.efi is signed with the Microsoft UEFI CA and carries the distribution's own certificate.
shim verifies grubx64.efi. GRUB asks shim to verify the kernel.
The kernel then refuses unsigned modules while lockdown is active.
Machine Owner Keys (MOK) let you trust your own signatures for out-of-tree drivers built with DKMS. Run mokutil --import key.der, and confirm the request in MokManager at the next boot.
SBAT metadata lets vendors revoke whole generations of vulnerable boot loaders without filling dbx.
RHEL 8 and later describe each kernel with a Boot Loader Specification (BLS) snippet in /boot/loader/entries/. grub.cfg reads those snippets, so installing a kernel does not rewrite the main config. Since RHEL 9, the grub.cfg on the ESP of a UEFI system is a short stub that points to /boot/grub2/grub.cfg. Use grubby instead of editing files:
Arguments for kernels installed later come from the defaults of your release, usually /etc/default/grub and, on recent releases, /etc/kernel/cmdline. Check both after a change you want to keep.
GRUB 2 on Debian and Ubuntu
The config is generated: edit /etc/default/grub, then run update-grub, which wraps grub-mkconfig -o /boot/grub/grub.cfg. With GRUB_DEFAULT=saved you choose an entry with grub-set-default, or boot it once with grub-reboot.
The one check that never lies
bash
cat /proc/cmdline
Whatever the files say, this is what the running kernel received. At the GRUB menu, e edits an entry for one boot only and Ctrl-x boots it. That is how you add rd.break or systemd.unit=rescue.target. Protect it on shared consoles with grub2-setpassword on RHEL, or a password_pbkdf2 entry on Debian.
Kernel and initramfs
GRUB loads two files into memory: the compressed kernel (vmlinuz-<version>) and an initial RAM filesystem (initramfs-<version>.img on RHEL, initrd.img-<version> on Debian). Then it jumps into the kernel with the command line.
The kernel decompresses itself, sets up memory management and CPUs, and starts its built-in drivers. It unpacks the initramfs, a cpio archive, into a RAM-backed root filesystem and runs /init from it.
Why the initramfs exists
The real root filesystem can sit behind anything the kernel does not have built in: an NVMe or virtio driver loaded as a module, an LVM volume, a RAID array, a LUKS container, iSCSI or NFS. The initramfs carries just enough userspace to reach it.
From initramfs to the real root
initramfs, in RAM
/initsystemd (dracut) or busybox scripts
udevLoads nvme, virtio, raid drivers
lvm · mdadm · cryptsetupAssembles and unlocks
switch_root
Real root, on disk
mount /sysrootroot= from the command line, read-only
switch_rootMoves /dev /proc /sys /run, frees RAM
/sbin/initsystemd from the real root, PID 1
The kernel unpacks the cpio archive into a RAM filesystem and executes /init.
udev reacts to devices as they appear and loads the storage drivers packed into the image.
LVM activates volume groups, mdadm assembles arrays, cryptsetup asks for the LUKS passphrase.
The device named by root= is mounted read-only at /sysroot. A timeout here drops you into the dracut shell.
switch_root moves the API filesystems, deletes the initramfs contents and changes root to /sysroot.
systemd from the real root takes over as PID 1 and starts the normal boot.
dracut builds it on the RHEL family and Fedora. Inside, systemd runs the early boot.
initramfs-tools builds it on Debian and Ubuntu LTS releases, with busybox and shell scripts. Some newer Ubuntu releases moved to dracut, so check which generator your release ships.
bash
lsinitrd /boot/initramfs-$(uname -r).img | grep -E 'nvme|virtio|lvm|crypt' # RHEL
lsinitramfs /boot/initrd.img-$(uname -r) | grep -E 'nvme|lvm' # Debian/Ubuntu
dracut -f --kver <version> # rebuild for one kernel
dracut -f --regenerate-all # rebuild for every installed kernel
update-initramfs -u -k all # Debian/Ubuntu equivalent
Finding root and pivoting
The command line tells the initramfs what to wait for: root=UUID=..., or root=/dev/mapper/rhel-root rd.lvm.lv=rhel/root, plus rd.luks.uuid= for an encrypted root. udev loads drivers as devices appear. LVM and mdadm assemble what they find. Root is mounted read-only at /sysroot. Then switch_root frees the initramfs, moves /dev, /proc, /sys and /run, and executes /sbin/init from the real root. That is systemd, as PID 1.
How it fails
Message
Where you are
Usual cause
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
Kernel, no userspace
Missing or empty initramfs for that kernel, often because /boot filled up during an update
dracut-initqueue timeout then /dev/mapper/rhel-root does not exist
dracut emergency shell
VG not found, wrong rd.lvm.lv, missing storage driver
ALERT! UUID=... does not exist. Dropping to a shell!
Debian (initramfs) prompt
Wrong root= UUID or missing driver
Inside the dracut shell, blkid, lvm vgscan, lvm vgchange -ay and cat /proc/cmdline tell you which piece is missing. Logs are in /run/initramfs/rdsosreport.txt.
Kernel arguments worth knowing
rd.break stops just before switch_root. rd.shell drops to a shell on failure. systemd.unit= picks a target. console=ttyS0,115200n8 sends output to a serial console, which is what the cloud serial consoles read.
systemd as PID 1
Once the real root is mounted, systemd builds a dependency graph from unit files and starts as much as it can in parallel. Unit files come from three places, highest priority first: /etc/systemd/system (your changes), /run/systemd/system (runtime) and /usr/lib/systemd/system (packages).
Targets replace runlevels
The goal of a boot is default.target, a symlink to multi-user.target on servers or graphical.target on desktops.
bash
systemctl get-default
systemctl set-default multi-user.target
systemctl isolate rescue.target # switch now, stopping what the target does not need
The early chain is sysinit.target (udev, local filesystems, swap, tmpfiles), then basic.target, then multi-user.target. The old runlevel3.target still exists as an alias.
Ordering is not dependency
Wants= and Requires= pull units in. After= and Before= only order them. A unit that Requires= a database but has no After= starts at the same time as the database. That race is a classic cause of services that fail only at boot.
fstab becomes units
systemd-fstab-generator turns every line of /etc/fstab into a .mount unit pulled in by local-fs.target, or remote-fs.target for _netdev. A mount that fails without nofail fails local-fs.target, and the boot lands in emergency.target. A device that never appears holds the boot for the default 90 seconds first. You can shorten that wait per line with x-systemd.device-timeout=10s.
Measuring a boot
bash
systemd-analyze # firmware, loader, kernel, initrd and userspace time
systemd-analyze blame | head # slowest units (they may run in parallel)
systemd-analyze critical-chain # the chain that actually delayed the target
systemctl list-jobs # what is still waiting during a slow boot
journalctl -b -p err # errors from this boot
journalctl -b -1 -e # previous boot, needs a persistent journal
blame sorts by duration, but a slow unit off the critical chain costs nothing. Read critical-chain before you disable anything. NetworkManager-wait-online.service and systemd-networkd-wait-online.service often sit at the top of blame. They run only because some unit wants network-online.target. Find that unit with systemctl list-dependencies --reverse network-online.target before you touch the wait service.
Rescue, emergency and break-in paths
Pick the lightest mode that gets you a shell where the broken piece can be fixed.
Mode
How to reach it
What you get
Use it for
rescue.target
systemd.unit=rescue.target on the kernel line
Root password prompt, local filesystems mounted, no network
Service or config problems after the disks are fine
# at the GRUB menu: e, append rd.break to the linux line, Ctrl-x
mount -o remount,rw /sysroot
chroot /sysroot
passwd root
touch /.autorelabel # SELinux relabels the whole filesystem at next boot
exit
exit
The relabel is the safe default, and it is slow on large filesystems. The faster route is load_policy -i, then restorecon -v /etc/shadow, then exit twice. It only fixes the one file you changed, so skip it if you are unsure what else you touched.
If emergency.target answers "Cannot open access to console, the root account is locked", the root account has no password. rd.break does not ask for one.
Root password reset on Debian and Ubuntu
bash
# at the GRUB menu: e, on the linux line replace "ro quiet splash" with "rw init=/bin/bash", Ctrl-x
passwd root
sync
exec /sbin/init # or: reboot -f
In the cloud there is no GRUB menu
Turn on the provider's serial console before you need it. On EC2 that is an account-level setting, and you also need an OS user with a password. Without a console, the reliable path is a volume swap:
Stop the instance and detach its root volume.
Attach the volume to a rescue instance in the same Availability Zone.
Mount it and fix the file, or chroot into it and fix the package.
Detach it, attach it back as the root device, and start the instance.
When the rescue instance runs the same image, mount XFS with -o nouuid, because both root filesystems share a UUID.
Kernel updates, rollback and crash dumps
Several kernels stay installed on purpose
On the RHEL family, installonly_limit in /etc/dnf/dnf.conf (3 by default) sets how many kernels stay installed. A new kernel becomes the default, under the UPDATEDEFAULT=yes setting in /etc/sysconfig/kernel. The old ones are your rollback.
bash
rpm -q kernel # installed kernels
uname -r # running kernel
dnf needs-restarting -r # exit code 1 means a reboot is needed
ls /var/run/reboot-required # Debian/Ubuntu flag file after an update
Ubuntu keeps the running kernel and the previous one. apt autoremove --purge cleans up the rest.
Rolling back
Reboot and pick the previous kernel in the GRUB menu, under "Advanced options" on Ubuntu.
Confirm with uname -r, then make it the default until the new one is fixed: grubby --set-default /boot/vmlinuz-<old> on RHEL, or grub-set-default with GRUB_DEFAULT=saved on Ubuntu.
Look for why the new kernel failed. Check that its initramfs exists, that /boot had space, and that its modules are present for out-of-tree drivers built with DKMS.
Live patching (kpatch on RHEL, Livepatch on Ubuntu) applies selected security fixes without a reboot. It does not replace kernel updates.
Modules
bash
lsmod | grep nvme
modinfo -F version e1000e
modprobe -r <module> && modprobe <module>
cat /etc/modprobe.d/*.conf # options and blacklists
To make sure a driver is in the initramfs, use dracut --add-drivers on RHEL, or add it to /etc/initramfs-tools/modules on Debian.
When the kernel itself crashes
kdump reserves memory at boot with the crashkernel= argument and loads a second kernel there. On a panic, that kernel boots and saves the memory image to /var/crash, where you open it with the crash tool.
bash
kdumpctl status # RHEL
kdump-config show # Debian/Ubuntu (kdump-tools)
cat /proc/sys/kernel/tainted # non-zero: proprietary or unsigned modules, previous oops
Without kdump, a panic on a remote server leaves you only what the serial console captured.
Incidents
Each incident follows the order you would work in: confirm the symptom, narrow down the layer, fix, verify.
Kernel panic after a kernel update
Symptom. The console shows "VFS: Unable to mount root fs on unknown-block(0,0)" right after the reboot that followed dnf update.
# GRUB menu: select the previous kernelThe old kernel and its initramfs are still installed. Get a working system first.
uname -r; rpm -q kernelConfirm which kernel you are on and which one failed.
ls -lh /boot/initramfs-*; df -h /bootA missing or tiny initramfs for the new kernel, and a full /boot, are the usual pair.
dracut -f --kver <new-version>Rebuild the image once /boot has space.
lsinitrd /boot/initramfs-<new-version>.img | grep -E "nvme|virtio|xfs"Prove the storage driver and filesystem module are inside before you reboot.
Root cause. The initramfs for the new kernel was never written, usually because /boot filled up during the transaction.
How to explain it
I boot the previous kernel from GRUB so the service is back, then check whether the new kernel has a complete initramfs and whether /boot ran out of space. I rebuild it with dracut, confirm the storage drivers are inside with lsinitrd, and only then reboot into the new kernel during a window, keeping the old one as the fallback.
Boot stops in emergency mode after a disk change
Symptom. "You are in emergency mode" after a data disk was replaced. The root filesystem is fine.
systemctl --failedFind which mount unit failed.
journalctl -xb | grep -i -E "timed out|dependency failed"A device timeout means the UUID in fstab no longer exists.
lsblk -f; cat /etc/fstabCompare the UUIDs on disk with the ones in fstab.
mount -o remount,rw /Root is read-only in emergency mode, so remount it before you edit.
findmnt --verify --verbose; systemctl daemon-reload; mount -aValidate the corrected file and regenerate mount units before you reboot.
Root cause. fstab referenced the old disk by UUID without nofail, so local-fs.target failed.
How to explain it
Emergency mode with a healthy root points at local-fs.target. I check systemctl --failed and the journal for the mount that timed out, compare fstab against lsblk -f, fix the UUID, and add nofail for data volumes that should not block the boot. findmnt --verify before the reboot proves the file is valid.
Boot takes three minutes
Symptom. SSH becomes available long after the VM shows as running. Nothing fails.
systemd-analyzeSplit the time between firmware, loader, kernel, initrd and userspace.
systemd-analyze critical-chainRead the chain that delayed multi-user.target, not just the slowest unit.
systemctl list-dependencies --reverse network-online.targetIf wait-online is on the chain, find who requests it.
journalctl -b -u systemd-udev-settle.service -u "*.mount"Device timeouts and udev settle are the other usual suspects.
Root cause. A NIC configured for DHCP with no cable kept network-online.target waiting, and an NFS mount wanted it.
How to explain it
I start with systemd-analyze to see which phase is slow, then critical-chain, because blame lists parallel work that may not matter. If the wait is network-online, I find which unit wants it and fix the real cause, an unused interface or a mount that should use x-systemd.automount, instead of disabling the wait service blindly.
A physical server never reaches GRUB
Symptom. The fans spin and the console stays black, or the firmware says no boot device was found.
ipmitool -I lanplus -H <bmc> -U <user> sel elistThe BMC log shows DIMM, CPU and power faults that happened before any OS code ran.
# BMC virtual console: read the POST code or errorMemory training stalls and missing controllers show on screen or as a POST code.
efibootmgr -vFrom rescue media: is there an NVRAM entry pointing to shimx64.efi on the ESP?
efibootmgr --create --disk /dev/sda --part 1 --label "Linux" --loader "\EFI\redhat\shimx64.efi"Recreate the entry after a board swap or firmware reset.
Root cause. A firmware reset cleared the NVRAM boot entries, so the ESP was never read.
How to explain it
Before GRUB there is no Linux to debug, so I go to the BMC: the event log and the virtual console tell me if it is hardware, like memory or power, or if the firmware simply has no valid boot entry. After a board swap or a firmware reset I recreate the UEFI entry with efibootmgr from rescue media.
Pick an answer to see the explanation. Your best score is saved in this browser.
Interview questions
Open questions. Try your own answer out loud, then compare with the model answer, written in English as you would give it in an interview.
Walk me through what happens from power-on to a login prompt.
Model answer
Firmware runs POST: microcode, memory training, PCIe enumeration. The UEFI boot manager reads its NVRAM entries and loads shim from the ESP. With Secure Boot, shim verifies GRUB and GRUB asks shim to verify the kernel. GRUB loads the kernel and the initramfs with the command line. The kernel initializes, unpacks the initramfs and runs /init, which loads storage drivers, assembles LVM, RAID or LUKS and mounts root read-only at /sysroot. switch_root hands over to systemd from the real root as PID 1. systemd generates mounts from fstab and starts units toward default.target, usually multi-user.target on a server.
You lost the root password on a RHEL server. How do you get back in?
Model answer
From the console I edit the GRUB entry and append rd.break. In the initramfs shell I remount /sysroot read-write, chroot into it, run passwd, and create /.autorelabel so SELinux fixes the shadow file context on the next boot. On a big filesystem I can run load_policy -i and restorecon on /etc/shadow instead. Then exit twice. Afterwards I would review who has console access and whether a GRUB password is set.
An EC2 instance does not come back after a reboot. What do you do?
Model answer
First the console output and screenshot, to see if it stops in GRUB, in the kernel, in the initramfs or in emergency mode. If the serial console is enabled I use it. If not, I stop the instance, attach the root volume to a rescue instance in the same AZ, mount it with nouuid if it is XFS from the same image, fix fstab, the initramfs or the boot loader, and attach it back. Then I make sure the fix also goes into the AMI or the config management, so the next instance does not repeat it.
What is the difference between rescue.target and emergency.target?
Model answer
Both ask for the root password. rescue.target mounts all local filesystems and starts basic services, without network, so it is good for configuration or service problems. emergency.target mounts only / read-only and starts almost nothing, which you need when fstab or a mount is the problem. If even that fails, rd.break or rescue media goes below both.
How would you add a kernel argument to every kernel, including future ones?
Model answer
On RHEL, grubby --update-kernel=ALL --args adds it to the existing BLS entries, and I make sure the default command line for new kernels has it too, in /etc/default/grub or /etc/kernel/cmdline depending on the release. On Ubuntu I add it to GRUB_CMDLINE_LINUX in /etc/default/grub and run update-grub. After the reboot I verify it in /proc/cmdline.
What does Secure Boot protect against, and what does it not?
Model answer
It makes sure every stage up to the kernel and its modules is signed by a trusted key, which stops boot kits and unsigned kernel modules. It does not protect a running system from a compromised root user, an attacker who can enroll a MOK with console access, or anything in userspace. It is one layer, next to disk encryption, a GRUB password and measured boot with a TPM.