Skip to main content

Quick-Save VMs + a Local LLM: Letting Broken Linux Binaries Hallucinate What's Missing

· 7 min read

In Plain English: Imagine a video-game Quick-Save button for a whole Linux computer, wired up to a local AI on your GPU. Whenever a program crashes because a config file, a shared .so library, or a hardware chip is missing, we pause or rewind the computer in ~55 milliseconds, let the AI invent just enough fake reality to keep the program happy, and hit play again. Once the program finally starts cleanly, all the files the AI invented stay saved as normal files on disk — so you never need the AI again.

TL;DR: After letting an AI agent boot extracted IoT firmware inside unkernel-rs, I wondered how far we could push the idea from outside the VM. Pairing unkernel-rs’s ~55 ms live-RAM snapshots (introduced in the Python VM showcase) with Inkling 2 Mini on a local RTX 5060 Ti (llama.cpp) and one generic prompt, unmodified nginx/1.30.8 booted from a wiped system (even with libpcre2-8.so.0 deleted!) to HTTP/1.1 200 OK in 4 tries, wiped dropbear 2026.91 reached a live SSH-2.0 banner in 2 tries, and stripped binaries even survived live SIGSEGV crashes mid-air.


The Idea: Treat Every Failure as a Rewindable Save-State

After watching a coding agent write shims for embedded firmware, I saw a wild bare-metal experiment where an OS trapped CPU faults and asked a tiny LLM to patch assembly on the fly. That sparked an obvious question: could we do something similar for normal, unmodified Linux programs — entirely from outside the VM?

Most Linux binaries fail to start for very mundane reasons: a missing config file, an empty /var/lib/... folder, a missing .so shared library, a missing SSH key, or a hardware memory address that doesn’t exist on your laptop.

If rebooting a VM takes 10 seconds, guessing fixes one by one feels glacial. When restoring a clean live-RAM snapshot (RamSnapshot) takes ~55 milliseconds inside an air-gapped WebAssembly Linux VM, you can treat startup like a video game with instant Quick-Save and Quick-Load:

Interactive Architecture Quick-Save VM + Local LLM Recovery Loop Click any recovery mode below to see how the VM and local 5060 Ti oracle interact
What Breaks

An unmodified daemon exits on boot because /etc/nginx/nginx.conf, /var/lib/nginx/logs, or /etc/dropbear/dropbear_ed25519_host_key was wiped.

What the Host Oracle Does

The host LLM reads only stderr/exit_code, emits files or setup_commands (e.g. dropbearkey), writes them into the persistent host overlay, and restores the clean RamSnapshot in ~55 ms.

Measured Outcome

Both wiped nginx/1.30.8 (HTTP/1.1 200 OK) and wiped dropbear 2026.91 (SSH-2.0-dropbear_2026.91) booted to live verified ports using one generic prompt — and the generated fixtures stay on disk forever.

branch = snap.restore()  # ~55 ms
branch.mount("./overlay", "/mnt/overlay")
# On exit: LLM writes missing file -> rewind & retry

Two simple rules keep this clean:

  1. All intelligence stays outside the VM: Python on the host watches what failed, asks the local 5060 Ti LLM for a fix, and rewinds the VM. The guest stays disposable and offline (--sinkhole).
  2. Hallucinate once, keep forever (“crystallization”): Every config file, folder, key, or library the AI invents is written into a normal host folder (./overlay) mounted into each VM rewind. Once the binary starts cleanly, those files sit on your disk as deterministic, inspectable fixtures — zero LLM needed on future runs.

Loop 1: Booting Real Unmodified Programs from a Wiped System

To make sure this wasn’t a parlor trick that only worked on hand-crafted toy code, I built a 100% generic recovery script (generic_oracle.py). Its prompt knows nothing in advance about web servers, SSH, ports, or library names — it only sees the command we ran and whatever error Linux printed.

Then I deliberately broke three real Alpine Linux packages before taking the Quick-Save snapshot:

  1. nginx: Installed nginx, deleted /etc/nginx, /var/lib/nginx, /var/log/nginx, /run/nginx, and /var/www (plus libpcre2-8.so.0 was missing from the disk).
  2. dropbear (SSH server): Installed dropbear, deleted /etc/dropbear and /var/run/dropbear.pid.
  3. lighttpd: Installed lighttpd, deleted /etc/lighttpd, /var/www, and /usr/lib/libpcre2-8.so*.

Here is the core host loop in Python — take one RamSnapshot, rewind in ~55 ms per attempt, check if a local TCP port opened, and test it over unkernel-rs’s air-gapped connect_tcp(port) channel:

snap = vm.ram_snapshot()  # Quick-Save (~58 ms)

for attempt in range(1, 7):
    branch = snap.restore()  # Quick-Load (~55 ms)
    branch.mount("./overlay", "/mnt/overlay")
    # run the unmodified binary and check /proc/net/tcp ...

    if listen_port is not None:
        sock = branch.connect_tcp(listen_port)  # air-gapped check, zero host ports!
        sock.write(b"GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n")
        resp = sock.read(4096).decode("utf-8", errors="replace")
        if "200 OK" in resp or resp.startswith("SSH-2.0-"):
            break  # Working service verified!

    decision = ask_local_llm(stderr_and_missing_symbols)
    save_to_host_overlay(decision)
    branch.shutdown()

What Actually Happened (Same Generic Prompt, Zero Hints)

  • nginx/1.30.8 — Working 200 OK in 4 attempts (51–67 ms rewinds):
    • Attempt #1: Failed immediately with exit code 127 — Linux’s dynamic loader saying “I can’t even start nginx because libpcre2-8.so.0 is missing.” The 5060 Ti generated a minimal replacement .so (more on that below).
    • Attempt #2 & #3: Created /var/lib/nginx/logs, /var/lib/nginx/tmp/client_body, a fresh nginx.conf, and index.html.
    • Attempt #4: Bound :8080 and returned HTTP/1.1 200 OK.
  • dropbear 2026.91 — Working SSH server in 2 attempts (54 ms rewinds):
    • Attempt #1: Exited complaining about missing /etc/dropbear/dropbear_*_host_key.
    • Attempt #2: Instead of trying to type fake text into a binary crypto key, the LLM asked to run dropbearkey, bound :2222, and greeted connect_tcp(2222) with SSH-2.0-dropbear_2026.91.
  • lighttpd/1.4.85 — Reached :8080, ran out of attempts on 403 Forbidden:
    • Rebuilt its missing libpcre2-8.so.0, wrote lighttpd.conf, and opened port 8080 — then spent its remaining attempts adding mod_mimetype instead of mod_indexfile to fix 403 Forbidden. (In an earlier 3-attempt run, it spotted mod_indexfile right away and served 200 OK.)

Loop 2: Rebuilding a Deleted .so Library on the Fly

What happens if you drop a binary into the VM, but one of the shared .so libraries it depends on is completely gone?

When Linux refuses to start a binary (exit code 127), the error message names the missing .so file, and running nm -D -u on the binary lists the exact function names it expected to find inside that library. For lighttpd with libpcre2-8.so.0 deleted, the 5060 Ti wrote a 10-line C stub file that compiled into a working .so on the first try:

int pcre2_code_free_8() { return 0; }
int pcre2_compile_8() { return 0; }
int pcre2_get_error_message_8() { return 0; }
int pcre2_get_ovector_pointer_8() { return 0; }
int pcre2_jit_compile_8() { return 0; }
int pcre2_match_8() { return 0; }
int pcre2_match_data_create_8() { return 0; }
int pcre2_match_data_create_from_pattern_8() { return 0; }
int pcre2_match_data_free_8() { return 0; }
int pcre2_pattern_info_8() { return 0; }

To be clear about why this worked: basic lighttpd and nginx configs don’t run regular-expression routes on startup, so stubbing pcre2_* to return 0 is enough to get past the loader and serve real pages. If a config actively matched regexes, those empty stubs wouldn’t cut it — but for getting an unfamiliar binary past load-time dependency walls automatically, it works surprisingly well.


Loop 3: Freeze-Frame Crash Surgery (SIGSEGV)

Finally, I wanted to test whether this could prevent real memory crashes (“segfaults” / SIGSEGV) mid-flight — without even restarting the program.

Normally, if an embedded program tries to read from a physical hardware chip address that doesn’t exist (say 0x30001000), or follows an empty (NULL) driver pointer, Linux kills it instantly.

Instead of letting it die, I preloaded a small ~100-line crash catcher (segv_healer.so) that acts like a freeze-frame repair crew:

  1. Freeze the crash mid-air before Linux terminates the process.
  2. Show the AI the next few machine instructions around the crash site (objdump -d).
  3. Invent the missing memory (allocate a fake slice of RAM at that hardware address, or point the empty CPU register at a newly created struct) and unpause on the exact same instruction.

Here is the actual stripped AArch64 assembly window the 5060 Ti received when a silent, stripped test binary crashed reading 0x30001000:

c28:  mov   x0, #0x1000
c2c:  movk  x0, #0x3000, lsl #16
c30:  ldr   w1, [x0]            ; <-- CRASH: 0x30001000 doesn't exist yet!
c34:  mov   w0, #0x5175         ;     next lines check if the value equals 0x5175
c38:  cmp   w1, w0
c3c:  b.ne  c48

Even with all symbols and error messages stripped out of the binary:

  1. The 5060 Ti read mov w0, #0x5175 + cmp w1, w0, created a page of RAM at 0x30001000 containing 0x5175, and hit unpause — the CPU retried line c30 and sailed right past the check.
  2. Moments later, the binary hit two back-to-back NULL pointer crashes (ctx->sensor->ready). Both times, the AI allocated a fake struct, wrote 1 into the expected field offset, updated register x0, and unpaused — letting the “unbootable” binary open port :9091 and return HTTP/1.1 200 OK ({"missing_so_synthesized":true,"hal_ver":1,"xor_mmio":"0x00005175","chained_ready":1}).

Honest Takeaways: What’s Fast, What’s Slow, and What’s Real

Running all of these side by side made the real tradeoffs crystal clear:

  • The VM is basically free; thinking tokens are the bottleneck: Rewinding the entire Linux VM took 48–85 ms, whereas each 5060 Ti call took 1.9–17.7 s because Inkling 2 Mini spent hundreds of internal thinking tokens before outputting a 10-line JSON reply (my script passed Qwen-style enable_thinking: False instead of Inkling’s reasoning_effort: "low" that I benchmarked earlier!). Setting reasoning_effort: "low" or using a fast non-thinking coder model would drop the whole multi-step recovery to ~1–2 seconds.
  • Short memory causes loops: When each attempt was stateless, lighttpd repeated the same mod_mimetype guess. Keeping a 3-line history of “tried X → got Y” — or spinning up 3 parallel 55 ms RamSnapshot branches at once and keeping whichever gets furthest — solves that cleanly.
  • Great discovery tool, terrible production runtime: You would never want an LLM hallucinating RAM pages under a live production server, and deep hardware protocols (crypto signatures, live video DMA) still need real code.

As a Zero-to-Boot triage tool, though, it feels remarkably close to practical: point it at a broken binary or wiped service inside an offline micro-VM, let your local GPU poke at it for 10 seconds, and walk away with normal, deterministic config and stub files that work on their own.

The views and opinions expressed here are my own and do not reflect those of my employer.