🩺 Interactive 3 AM Linux Incident & eBPF Rescue Selector

VERIFIED ON KERNEL 7.0.14-29-pve
Likely Kernel Cause
Unlinked Open FD
Fastest Triage Command
find /proc/[0-9]*/fd
Measured Lab Fix Time
1 ms (Zero Restart)

1. Exact System & Air-Gapped Proxmox Lab Environment

Reproducibility matters in kernel benchmarks. An strace penalty on a sleeping container means nothing compared to real TCP/file syscalls, and an unprivileged LXC container behaves very differently from a bare-metal host when it comes to eBPF capabilities and tmpfs limits. Here is the exact hardware and software stack behind every log below:

Layer Exact Specification Measured Role in Experiments
Hypervisor / Host OS Proxmox VE 9.2.27 on Debian GNU/Linux 13.7 (trixie) Container lifecycle, host-level bpftrace & pct fstrim
Shared Linux Kernel 7.0.14-29-pve (shared between host and unprivileged LXC) Executes Ring 0 eBPF tracepoints for CT 201
Hardware Node Dell D10U Micro PC • Intel Core i5-7500T @ 2.70GHz (4 threads) • 31 GiB RAM Home/SOHO standard server class hardware
Production Pool (Untouched) nvme0n1 — INTEL SSDPEKNW010T8 (953.9G, Btrfs) Runs 24/7 services (AI worker + Uptime Kuma) untouched
Isolated Lab Disk sda1 — SK hynix SC300B SATA 512GB (476.9G, ext4) Holds sparse .raw images for CT 200 template & CT 201
Network Air-Gap Internal bridge vmbr1 (10.99.0.1/24) + iptables DROP to LAN & host Zero visibility into 192.168.0.0/23 or host SSH/8006
Test Container (CT 201) Unprivileged LXC • Debian 13 (trixie) • 1 vCPU, 512 MB RAM, swap: 0 / = 20G ext4, /lab-disk = 2.0G ext4 (131,072 inodes), /tmp = tmpfs
Diagnostic Tooling bpftrace v0.23.2 (host), strace 6.13, lsof 4.99.4, Python 3.13.5 Measured timings, syscalls, FD counts & OOM captures

Why attach a dedicated 2.0 GB mountpoint (mp0) at /lab-disk alongside the 20 GB sparse rootfs? Because it lets us hit genuine ENOSPC and 100% inode exhaustion in three seconds without wiping out OS binaries first—and keeping everything on a secondary SATA drive means our main NVMe pool never feels a single chaotic write.

2. Ghost Space (1 ms Fix), lsof +L1 Pitfalls & Inode Exhaustion

Experiment #1: df -h at 100% (0 Avail) vs du -sh at 4.0K

A background Python worker inside CT 201 opened /lab-disk/app.log and allocated blocks down to 0 B free. We then ran what every panicked admin runs at 3 AM: rm -f /lab-disk/app.log—without restarting the process.

Because Linux directories store filenames while open file descriptors point directly to the inode, removing the filename leaves all 1.8 GB locked on disk. Interestingly, a zero-byte touch still succeeded (it only needs an inode, not a data block), whereas writing real data via dd failed immediately:

CT 201 // Live Terminal Capture: Ghost Space & 1 ms Truncate Rescue
# After rm -f /lab-disk/app.log (process still running in background)
$ du -sh --exclude=lost+found /lab-disk
4.0K    /lab-disk

$ df -h /lab-disk
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop3      2.0G  1.8G     0 100% /lab-disk

$ dd if=/dev/zero of=/lab-disk/nowy_plik.txt bs=4k count=1
dd: error writing '/lab-disk/nowy_plik.txt': No space left on device

# Forensic discovery without extra packages (works even when apt cannot run at 0 B!)
$ find /proc/[0-9]*/fd -lname '*(deleted)*' -ls 2>/dev/null
  2021678      0 l-wx------   1 root     root           64 Nov 16 19:53 /proc/711/fd/3 -> /lab-disk/app.log (deleted)

# Zero-downtime recovery (no service restart, PID 711 stays alive):
$ : > /proc/711/fd/3    # measured duration: 1 ms!
$ df -h /lab-disk
/dev/loop3      2.0G  540K  1.8G   1% /lab-disk

Experiment #2 (Heisenberg Benchmark): lsof +L1 Syntax Trap vs /proc at 2,000+ Open FDs

Old-school Unix admins rightly love lsof +L1 ("open files with link count below 1"). So we installed lsof 4.99.4 in CT 201, launched four workers holding 2,000 active descriptors alongside a 500 MB deleted file, and discovered both a classic syntax trap and a 4.25× speed gap:

  • The lsof OR-trap: running lsof +L1 /lab-disk (without -a) evaluates as link count < 1 OR anything under /lab-disk—flooding our terminal with 170 KB of output covering all 2,000 normal NLINK=1 files in 88 ms!
  • Clean lsof +L1 (no path): took 68 ms to return the deleted file cleanly.
  • Built-in find /proc/[0-9]*/fd -lname "*(deleted)*" -ls: completed in 16 ms—4.25× faster and pre-installed on every minimal Linux rescue shell.

Experiment #3: Death by Inodes (131,059 Empty Files) & ARG_MAX Failure

On ext4 (including almost every cloud VPS and Proxmox LXC raw disk), the maximum number of files is fixed at format time—think of inodes as numbered library index cards while gigabytes are shelf space. When our script generated 131,059 completely empty 0 B files in 3,053 ms inside /lab-disk/spool, df -h looked 99% empty—yet even touch failed:

CT 201 // Live Terminal Capture: 1% Disk Used, 100% Inodes Exhausted
$ df -h /lab-disk
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop3      2.0G  4.3M  1.8G   1% /lab-disk

$ df -i /lab-disk
Filesystem     Inodes  IUsed IFree IUse% Mounted on
/dev/loop3     131072 131072     0  100% /lab-disk

$ touch /lab-disk/test.txt
touch: cannot touch '/lab-disk/test.txt': No space left on device

# Classic junior panic: shell wildcard expansion hits kernel ARG_MAX (2 MB)!
$ getconf ARG_MAX
2097152
$ rm -rf /lab-disk/spool/*
bash: /bin/rm: Argument list too long

# Streaming fix (reads directory natively without shell glob expansion):
$ find /lab-disk/spool -type f -delete   # cleared 131,059 files in 1,415 ms!
$ df -i /lab-disk
/dev/loop3     131072     12 131060    1% /lab-disk

Quick Btrfs & ZFS caveat: unlike ext4, both Btrfs (used on our Proxmox NVMe host pool) and ZFS allocate inodes dynamically—so they rarely run out of numbered file slots. Instead, they fail in two sneaky ways at the pool layer: (1) old Copy-on-Write snapshots keep deleted blocks alive like filesystem-level Ghost Space, and (2) at absolute 0 B free, even rm bigfile can fail with No space left on device because updating directory metadata needs a free CoW block—making truncate -s 0 bigfile your lifesaver there too.

3. Hard Benchmark: Legacy strace -f vs Ring 0 eBPF (bpftrace)

Why do senior SREs warn against attaching strace to a busy database or API worker? Because strace uses ptrace, pausing the target process twice on every syscall (entry and exit) for user-space context switches. Inside CT 201, we spun up a single-process Python HTTP socket worker answering 2,000 sequential local requests while opening /etc/hostname on each call, and traced the exact same PID three ways (with strace output discarded to /dev/null so terminal printing wouldn't skew the result):

Tracing Mode (2,000 HTTP + File I/O Requests) Elapsed Time Throughput Impact vs Baseline
Baseline (Unobserved Worker) 0.269 s 7,441.3 req/s Reference (100%)
Legacy strace -f -p 1065 -o /dev/null 0.870 s 2,300.1 req/s -69.1% throughput (3.23× slower!)
Ring 0 bpftrace (HOST_PID=394613) 0.275 s 7,259.9 req/s Only ~2.4% overhead counting 24,000 syscalls
Proxmox Host // Kernel 7.0.14-29-pve Inspecting CT 201 Process (HOST_PID=394613)
# Because unprivileged LXC restricts CAP_BPF inside guests, attach bpftrace on the host:
$ bpftrace -e 'tracepoint:raw_syscalls:sys_enter /pid == 394613/ { @syscalls = count(); }'
Attaching 1 probe...
^C
@syscalls: 24000

Also note a real-world bpftrace v0.23.2 verifier detail we hit when filtering path strings inside sys_enter_unlinkat: calls like strcontains(str(args->pathname), ...) without bounded string lengths exceed the kernel BPF verifier instruction complexity budget. Clamp strings cleanly (e.g. str($ptr, 16)) or probe VFS helpers rather than pasting unverified snippets blindly at 3 AM.

4. The 3 AM Playbook: Debian 13 /tmp OOM, journalctl --rotate, ssh -T & fsync Histograms

Experiment #4: Why Filling /tmp Killed the Entire Debian 13 LXC Container (Exit 137)

During our first full-root disk-fill test in CT 201, writing blocks to /tmp/.crash_fill.bin never reached disk exhaustion—the container abruptly exited with code 137 (SIGKILL)! Inspecting mounts and host dmesg -T revealed a critical Debian 13 (trixie) surprise: Debian 13 mounts /tmp as tmpfs in RAM by default, and inside an unprivileged container df -h /tmp reports 16G (half the Proxmox host's 31 GiB RAM) even though CT 201 has a hard 512 MB limit (swap: 0). Any job dumping huge sort buffers or uploads to /tmp OOM-kills the container unless you target real storage (like /var/tmp).

Experiment #5 & #6: ssh -T Root Rescue at 0 B & Why journalctl --vacuum-size Freed 0B

When /var/tmp filled /dev/loop2 to 100% (0 Avail), normal interactive SSH logins risk failing on PTY allocation or bash history writes, and running sudo without a PTY or on exhausted /run/auth.log paths can stall. Jumping straight in via non-interactive key auth (ssh -T) with HISTFILE=/dev/null rescued the root filesystem cleanly—followed by pct fstrim 201 on the Proxmox host to return 18.9 GiB of discarded sparse blocks back to our SATA pool.

Similarly, flooding /dev/log (note: modern Debian 13 without rsyslog uses /dev/log rather than /run/systemd/journal/syslog) pushed /var/log/journal from 8M up to 28.5M. Running journalctl --vacuum-size=50M alone freed 0B because systemd never shrinks the currently active journal file—always pair journalctl --rotate && journalctl --vacuum-size=50M, then set SystemMaxUse=100M and MaxRetentionSec=14day inside /etc/systemd/journald.conf.d/.

Experiment #7: Kernel fsync() Latency Histograms & Catching Silent OOM Victims Live

Finally, when a server exhibits sky-high Load Average while htop shows 95% idle CPU, processes are usually blocked in uninterruptible sleep (D-State, immune to kill -9 while waiting inside kernel I/O). A four-line bpftrace histogram immediately exposes disk flush latency—and tracepoint:oom:mark_victim catches memory-cgroup kills the instant a runaway process disappears with zero application logs:

Proxmox Host // Live Ring 0 Histograms & Instant OOM Forensic Capture
# 1. Synchronous disk flush latency across 30 x 2 MB fsync() writes in CT 201:
$ bpftrace -e '
tracepoint:syscalls:sys_enter_fsync { @t[tid] = nsecs; }
tracepoint:syscalls:sys_exit_fsync /has_key(@t, tid)/ { @fsync_ms = hist((nsecs - @t[tid]) / 1000000); delete(@t, tid); }
'
@fsync_ms:
[0]                    1 |@@                                                  |
[1]                    0 |                                                    |
[2, 4)                 0 |                                                    |
[4, 8)                 0 |                                                    |
[8, 16)               19 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[16, 32)              11 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                      |

# 2. Catching silent OOM cgroup kills (when app logs show nothing):
$ bpftrace -e 'tracepoint:oom:mark_victim { printf("eBPF_OOM_VICTIM pid=%d comm=%s\n", args->pid, str(args->comm)); }'
eBPF_OOM_VICTIM pid=405989 comm=

$ dmesg -T | grep -iE 'Killed process|oom-kill' | tail -n 2
[Mon Nov 16 20:56:27] oom-kill:constraint=CONSTRAINT_MEMCG,...,oom_memcg=/lxc/201,...,task=python3,pid=405989
[Mon Nov 16 20:56:27] Memory cgroup out of memory: Killed process 405989 (python3) total-vm:526656kB, anon-rss:506456kB

Experiment #8 (Production Guard): Automated Zero-RAM Ghost Space Self-Healing via /proc

Translating Experiments #1, #2, and #6 into unattended protection means scanning /proc/[0-9]*/fd/* directly across the Proxmox host and every running LXC container (mapping CT <id> from /proc/<pid>/cgroup) inside our zero-RAM proxmox-health-guard oneshot script—bypassing slow lsof +L1 invocations completely. When root disk usage crosses the self-heal threshold (>= 88%) or journals bloat, active recovery executes in a strict, damage-proof sequence:

  • Rotate Before Vacuum: Always triggers journalctl --rotate && journalctl --vacuum-size=50M, because systemd refuses to shrink an open active journal file (returning freed 0B otherwise).
  • In-Place logrotate -f with copytruncate: Rotates growing automation logs cleanly without breaking open file descriptors held by running workers.
  • Strict Whitelist-Only os.truncate on /proc/<PID>/fd/<FD>: Automated zeroing is permitted ONLY on plain log targets (.log or inside /var/log/), and is HARD-BLOCKED on .db, .sqlite, .journal, and paths under /var/lib/. Protected database and runtime binaries (postgres, mysqld, mariadbd, sqlite3, forgejo, ollama, node, adguardhome) are never truncated automatically—non-whitelisted deleted descriptors raise an immediate CRIT alert instead.
  • Race-Condition Lock & Live Self-Test (--test-ghost-heal): Right before calling os.truncate, the guard re-reads os.readlink and st_ino to prevent PID/FD reuse races. Verified live with --test-ghost-heal: an unlinked 12.2 MB log held open by a live Python child on /proc/<pid>/fd/3 was truncated to 0 B (st_size=0 B, st_blocks=0) while the process continued running uninterrupted.
Proxmox Host // Safe Automated Ghost Space Self-Test (--test-ghost-heal)
# Verify /proc Ghost Space detection + inode-checked truncation on an unlinked 12.2 MB test log:
/usr/local/sbin/proxmox-health-guard --test-ghost-heal
# 1. Child process opens /tmp/ghost_test.log (12.2 MB) and immediately unlinks it (deleted)
# 2. Guard scans /proc/[0-9]*/fd/*, verifies .log whitelist + st_ino match
# 3. Truncates /proc/<pid>/fd/3 -> st_size=0 B, st_blocks=0 while child stays alive (PASSED)

🧰 Deploy This 3 AM Rescue Kit on Your Own Infrastructure

Pair these Ring 0 eBPF diagnostics with offline AI log triage and laminated 300 DPI rack runbooks so you never waste 40 minutes Googling flags during a P1 outage:

5. Frequently Asked Questions

Why does df -h still say 100% after deleting a massive file with rm -f?

rm only removes the filename pointer in the directory. Any daemon still holding that file descriptor open keeps every data block reserved in the kernel. Locate it with find /proc/[0-9]*/fd -lname '*(deleted)*' -ls (or lsof +L1) and zero it out cleanly using : > /proc/<PID>/fd/<FD>.

Why should I run journalctl --rotate before --vacuum-size=50M?

systemd-journald refuses to delete or shrink the currently active binary journal file. Rotating first closes the active log into an archive so --vacuum-size can immediately reclaim space.

When does tune2fs -m 1 save non-root services on ext4?

By default, ext4 reserves 5% of blocks exclusively for root, meaning databases and web servers hit No space left on device earlier. Lowering that reserve to 1% (tune2fs -m 1 /dev/...) instantly unlocks breathing room for non-root workers while you clean up.