Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Linux Admins Difficulty: Advanced ClaudeChatGPT

Linux kexec Fast Reboot Setup Prompt

Design and validate a kexec-based fast-reboot workflow that skips firmware/POST to cut kernel-upgrade downtime, with safe fallback to a full reboot when hardware re-init is required.

Target user
Linux sysadmins and SREs minimizing kernel-patch downtime on bare metal
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior Linux systems engineer who reduces kernel-upgrade downtime on bare-metal fleets using kexec to skip firmware, POST, and bootloader time.

I will provide:
- Distro and version, and how kernels are managed (`uname -r`, `ls /boot`, package manager)
- Hardware class (server vendor/model, POST duration, whether it has slow RAID/BMC init)
- Whether the host uses `kexec-tools`, `systemd` (`systemctl kexec`), or the `kexec-load` systemd path
- Boot storage layout: LUKS, LVM, mdraid, multipath, NVMe, network/iSCSI root
- Current kernel cmdline (`cat /proc/cmdline`) and any initramfs specifics (`lsinitramfs`)
- Constraints: is this a canary or production, and the acceptable blast radius

Your job:

1. **Decide if kexec is safe here.** kexec re-executes a new kernel WITHOUT re-initializing firmware or peripheral hardware. Flag hosts where this is risky: SR-IOV/GPU passthrough, quirky NIC/RAID firmware, TPM measured boot / Secure Boot chains, or devices that need a cold reset. For those, recommend a normal reboot.
2. **Choose the load method.** Explain `kexec -l <kernel> --initrd=<initramfs> --command-line="$(cat /proc/cmdline)"` vs `kexec -s` (kexec_file_load, needed for Secure Boot signature checks) vs `systemctl kexec`. Note that copying the current cmdline verbatim is the safest default, and where `--reuse-cmdline` applies.
3. **Wire it to the running kernel.** Show how to always kexec into the just-installed kernel by resolving the newest `/boot/vmlinuz-*` + matching `initramfs`, or by parsing the default GRUB entry, so automation never boots a stale kernel.
4. **Sequence a clean transition.** Order of operations: quiesce/drain workloads, `sync`, unmount or remount-ro non-essential filesystems where possible, stop services that hate abrupt restart (databases), then trigger kexec. Note that kexec does NOT run the full shutdown; give the exact way to still run service stop hooks.
5. **Design the fallback.** kexec load can fail (`kexec_load failed`) or the new kernel can panic without firmware re-init. Provide a watchdog/fallback plan: hardware watchdog + BMC power-cycle, and a rule that a failed kexec load must trigger a normal `reboot`, never leave the host wedged.
6. **Provide verification.** How to confirm the host actually kexec'd (uptime reset, `journalctl` boot list, `last reboot`) and that all storage/network came back (multipath paths, bonded links, mounts) before returning it to service.

Output as: a go/no-go verdict for this hardware, an ordered runbook with exact commands, a fallback/watchdog section, and a short list of hardware conditions that must force a full reboot instead.

Default to caution: when firmware-level device re-init matters or evidence is ambiguous, recommend a normal reboot over kexec.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Why this prompt works

kexec is the fastest way to cut kernel-patch downtime on slow-POST servers, but it is also the fastest way to wedge a box if you skip the hardware caveats. This prompt forces a go/no-go hardware decision first, then produces a runbook with an explicit fallback so a failed load never leaves a host offline.

How to use it

  1. Run it against a single canary host before any fleet rollout.
  2. Paste /proc/cmdline, uname -r, and your storage layout so the generated commands match reality.
  3. Keep the fallback watchdog wired even after the workflow is proven — firmware quirks surface months later.

Useful commands

# Load the newest installed kernel + initramfs, reusing the live cmdline
KV=$(ls -1 /boot/vmlinuz-* | sort -V | tail -1 | sed 's|.*/vmlinuz-||')
sudo kexec -l /boot/vmlinuz-$KV --initrd=/boot/initramfs-$KV.img --reuse-cmdline

# Secure Boot / signature-verified path
sudo kexec -s -l /boot/vmlinuz-$KV --initrd=/boot/initramfs-$KV.img --reuse-cmdline

# Trigger the fast reboot
sync
sudo systemctl kexec            # runs unit stop jobs, then jumps
# or, after `kexec -l`:
sudo kexec -e

# Verify it actually kexec'd and came back clean
uptime; journalctl --list-boots | tail -3; last -x reboot | head
sudo multipath -ll; ip -br link; findmnt --verify

Related prompts

More Linux Admins prompts & error guides

Browse every Linux Admins prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.