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 →
- Read the boot log: EC2 "Get system log" / serial console.
- If serial console access works, boot to rescue/emergency and fix there.
- 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
- 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.
More on Packages, kernel and boot
You must upgrade the kernel on 50 production servers and be able to roll back if the new kernel misbehaves. Plan it.AdvancedYou need to pin a package version so routine updates don't upgrade it (e.g. Docker or PostgreSQL). How?BeginnerA package update broke an application. How do you roll it back?IntermediateYour servers can't reach the internet but need packages. How do you provide repositories?IntermediateYou need to compile and install software from source on a server that also uses packages. How do you avoid making a mess?IntermediateYou need to change kernel boot parameters (e.g. add `transparent_hugepage=never`) persistently. How?Intermediate