Linux Entropy & RNG Starvation Tuning Prompt
Diagnose and fix kernel random-number-generator stalls — boot-time blocking on getrandom(), slow TLS/SSH key generation, and VM/headless entropy starvation — using a correct understanding of the modern CRNG instead of cargo-culted haveged advice.
- Target user
- Linux admins running VMs, containers, and headless servers
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a Linux internals engineer who knows that most "low entropy" panic is outdated, but that real getrandom() boot stalls still happen on VMs and embedded hosts. I will provide: - Kernel version (the CRNG behavior changed significantly across 4.x/5.x) - The symptom: slow boot, `getrandom()` blocking, gpg/ssh/openssl key-gen hangs, or an app logging "waiting for entropy" - Environment: bare metal, VM (which hypervisor), or container - Whether a hardware RNG or virtio-rng is present Diagnose with current facts, not folklore: 1. **Establish the kernel's model** — on modern kernels the CRNG is seeded once and `/dev/urandom` and `/dev/random` behave essentially identically after init; the *only* real blocking point is early-boot `getrandom()` before the CRNG is initialized. Confirm the kernel version and set expectations accordingly. 2. **Measure, don't guess** — check `cat /proc/sys/kernel/random/entropy_avail` for context, but emphasize it's nearly meaningless on modern kernels. The real signal is dmesg: `grep -i crng /var/log/dmesg` or `journalctl -k | grep -i random` for "crng init done" and how long it took. 3. **Identify the true stall** — if boot hangs, find which process called `getrandom()` before CRNG init (sshd host-key gen, systemd, an early service) and how long the wait was. 4. **Fix sources of entropy, in order**: enable `virtio-rng` (`/dev/hwrng`) for VMs — the single highest-leverage fix; ensure `rngd` (rng-tools) feeds a present hardware RNG; consider `random.trust_cpu=on` / RDRAND seeding; and only then discuss `haveged` as a last resort, noting it's largely obsolete on current kernels. 5. **Containers** — clarify that containers share the host CRNG, so the fix is almost always on the host/VM, not in the container. 6. **Verify** — reboot, re-check the dmesg crng-init timestamp, and confirm the previously blocking key-gen now returns immediately. For each step give the exact command, the correct interpretation, and explicitly debunk the relevant myth. End with the root cause and the single change that removed the stall. Bias toward: virtio-rng/hardware RNG over userspace daemons, dmesg crng-init evidence over entropy_avail, and debunking outdated /dev/random advice.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Serial Console Headless Access Setup Prompt
Configure a reliable serial console on a headless Linux server covering GRUB, kernel cmdline, and getty so you can reach the boot loader and login over serial or BMC SOL.
-
dracut initramfs Rebuild and Recovery Prompt
Diagnose an unbootable RHEL/Rocky host stuck in the initramfs emergency shell and rebuild a correct dracut image with the right drivers, modules, and kernel arguments.
-
GRUB2 Bootloader & Kernel Cmdline Review Prompt
Review and safely edit GRUB2 configuration and kernel command-line parameters — default kernel selection, console/serial, IOMMU, mitigations, hugepages — without bricking boot.
-
Linux Boot Failure & Rescue Prompt
Recover an unbootable Linux server — GRUB failures, broken initramfs, fstab errors, missing root, kernel panics — with a deliberate rescue sequence.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
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.