DEV Community

Muhammad Awais
Muhammad Awais

Posted on • Originally published at webtoolshub.online

OpenAI Codex Was Writing 640 TB/Year to Your SSD - Check and Fix in 5 Minutes

Codex SSD Bug Fixed: Check Drive Damage & Update to v0.142.0
TL;DR: OpenAI Codex had a bug that wrote up to 640 TB/year to your SSD via a runaway SQLite logger. The fix shipped in v0.142.0 (June 23, 2026) and cuts writes by ~85%. Update now, check your drive health, and delete the bloated log file. If you're on macOS, do NOT use the /tmp symlink workaround everyone is sharing - it doesn't work on macOS and nobody is saying that.


Two weeks ago, developer Rui Fan filed GitHub Issue #28224 against the Codex repo with a title that made a lot of developers stop what they were doing: "Codex SQLite feedback logs can write ~640 TB/year and rapidly consume SSD endurance."

After 21 days of normal uptime with Codex running, his main SSD had absorbed 37 terabytes of writes — all from a single SQLite file at ~/.codex/logs_2.sqlite. Annualized: roughly 640 TB per year. A typical 1 TB consumer NVMe is rated for ~600 TBW across its entire lifetime. One coding tool was silently burning through that warranty budget in under twelve months.

The fix is out. Here's what you actually need to do.


Step 0 — Check Your SSD Health First

Before anything else, read your SMART counters. This is the only way to see real cumulative write totals — df, du, and disk space UI show nothing useful here.

Linux (NVMe):

sudo apt install smartmontools   # or dnf/pacman equivalent
sudo smartctl -A /dev/nvme0n1
# Look for: Data Units Written
# Multiply by 512,000 to get bytes → divide by 1e12 for TB
Enter fullscreen mode Exit fullscreen mode

Linux (SATA):

sudo smartctl -A /dev/sda
# Samsung: attribute 233 (Media Wearout Indicator) — 100 = new, lower = more worn
# Intel:   attribute 231 (SSD Life Left) — same scale
Enter fullscreen mode Exit fullscreen mode

macOS:

brew install smartmontools
sudo smartctl -A /dev/disk0
# Apple Silicon: smartmontools may not work — use System Information → NVMe instead
Enter fullscreen mode Exit fullscreen mode

Windows:
Download CrystalDiskInfo (free, portable). Look at Total Host Writes and Health Status. Yellow "Caution" means something crossed a warning threshold.


Step 1 — Check the Log File Itself

Quit Codex completely, then:

# See current file sizes:
ls -lh ~/.codex/logs_2.sqlite ~/.codex/logs_2.sqlite-wal ~/.codex/logs_2.sqlite-shm 2>/dev/null

# Current row count retained:
sqlite3 ~/.codex/logs_2.sqlite "SELECT COUNT(*) FROM logs;" 2>/dev/null

# Historical write proxy — this is the number that matters:
sqlite3 ~/.codex/logs_2.sqlite "SELECT MAX(rowid) FROM logs;" 2>/dev/null
Enter fullscreen mode Exit fullscreen mode

The file size on disk looks deceptively calm — Codex prunes rows as fast as it inserts them. But the MAX(rowid) tells you how many total rows have ever been inserted. One user in the GitHub thread had a MAX(rowid) in the billions with only ~500k rows currently retained. That's a 10,000x gap. That gap is all SSD wear.


Step 2 — Update to v0.142.0

This is the real fix. Three PRs were merged:

  • #29432 — stopped logging every WebSocket event (previously 3 SQLite writes per event)
  • #29457 — filtered high-frequency dependency noise from the persistent log sink
  • #29599 — additional bridged event filter (targeting v0.143.0)

Together they reduce write volume by approximately 85%.

npm install -g @openai/codex@latest

# Verify:
codex --version
# Should be 0.142.0 or higher
Enter fullscreen mode Exit fullscreen mode

Step 3 — The Workaround (If You Can't Update Yet)

Linux: /tmp symlink ✅ works

# First — confirm /tmp is actually RAM-backed:
mount | grep /tmp
# Must show: tmpfs on /tmp type tmpfs
# If it shows ext4 or btrfs, /tmp is on disk and this won't help

# Apply the redirect:
rm -f ~/.codex/logs_2.sqlite ~/.codex/logs_2.sqlite-wal ~/.codex/logs_2.sqlite-shm
ln -s /tmp/codex_logs.sqlite ~/.codex/logs_2.sqlite
Enter fullscreen mode Exit fullscreen mode

Writes go to RAM. On reboot the target disappears and Codex starts fresh — which is fine, the file has no important data.

macOS: /tmp symlink ❌ does NOT work

This is the thing I'm not seeing anyone say clearly: on macOS, /tmp is a symlink to /private/tmp, which lives on your SSD. Moving the log file to /tmp on macOS just moves the writes to a different folder on the same physical drive. It doesn't protect anything.

macOS users should use the SQLite trigger instead:

sqlite3 ~/.codex/logs_2.sqlite \
  "CREATE TRIGGER IF NOT EXISTS block_log_inserts \
   BEFORE INSERT ON logs \
   BEGIN SELECT RAISE(IGNORE); END;"
Enter fullscreen mode Exit fullscreen mode

This blocks all new inserts at the database engine level. Codex runs normally. Verify the trigger survived after restarting Codex:

sqlite3 ~/.codex/logs_2.sqlite ".schema"
# Trigger definition should appear in output
Enter fullscreen mode Exit fullscreen mode

Windows

Use the SQLite trigger approach. Install sqlite3 from sqlite.org, then run the trigger command against %APPDATA%\Codex\logs_2.sqlite.


Step 4 — Clean Up the Existing Log Files

Quit Codex, then:

rm -f ~/.codex/logs_2.sqlite
rm -f ~/.codex/logs_2.sqlite-wal
rm -f ~/.codex/logs_2.sqlite-shm
# Codex recreates a clean, minimal file on next launch
Enter fullscreen mode Exit fullscreen mode

Or if you want to compact without deleting:

sqlite3 ~/.codex/logs_2.sqlite "VACUUM;"
Enter fullscreen mode Exit fullscreen mode

One developer went from a 27 GB file to 73 MB with just the delete. The log file contains zero conversation data, zero project data, zero credentials — it's pure telemetry. Delete it without hesitation.


Why Did This Happen?

Three things combined:

  1. TRACE level logging by default — the noisiest possible setting. Logged everything: raw WebSocket payloads, inotify events for opening /etc/passwd, every OpenTelemetry span. About 71% of logged data had no diagnostic purpose.

  2. SQLite WAL write amplification — SQLite in WAL mode writes changes to a separate log file before checkpointing them to the main DB. With tens of thousands of insert-delete cycles per minute, the drive absorbs far more physical writes than the file size implies. The file looked stable at ~1 GB on disk while absorbing TB-scale writes.

  3. RUST_LOG was ignored — setting RUST_LOG=warn in your shell had zero effect on the SQLite sink. The standard Rust log-control mechanism was bypassed entirely. There was no user-accessible way to quiet it before the v0.142.0 fix.


Should You Stop Using Codex?

No — if you update to v0.142.0. The fix is real and significant. But this incident is a useful reminder that AI coding CLIs are runtime software with persistent processes and local databases, not simple utilities that exit cleanly after each run. Monitor them like you would any long-running daemon.

Running sudo smartctl -A /dev/nvme0n1 once a month takes five seconds. After this, it's on my monthly checklist.


For a complete walkthrough including SMART data interpretation, platform-specific steps, and what the three fix PRs actually changed under the hood, the full guide is on WebToolsHub: OpenAI Codex SSD Bug Fix — Full Guide


Have you checked your drive health after this? What did your SMART counters show? Drop it in the comments.

Top comments (0)