Interview Prep/Linux/Packages, kernel and boot

A cloud instance won't boot after a change and you only have the cloud console. How do you repair it?

AdvancedScenarioPackages, kernel and boot
Answer

Situation read → Use the serial console, or mount the root volume on a rescue instance.

What I'd do →

  1. Read the boot log: EC2 "Get system log" / serial console.
  2. If serial console access works, boot to rescue/emergency and fix there.
  3. Otherwise: stop the instance, detach the root volume, attach to a rescue instance in the same AZ:
lsblk
sudo mount -o nouuid /dev/nvme1n1p1 /mnt/rescue     # nouuid for XFS clones
sudo vi /mnt/rescue/etc/fstab                         # fix the bad change
sudo umount /mnt/rescue
  1. Reattach as root device and start.

Why → You can't use GRUB interactively without a console, so you fix the filesystem from another machine.

Interview tip → Snapshot the volume before touching it.

All Linux questions Roadmap: Linux

More on Packages, kernel and boot