Skip to content
Back to skills

Esp32 Storage And Filesystem

ASecurity

Use when choosing or debugging storage on ESP32 - the filesystem will not mount after a power cut, the partition is smaller than the chip, config is lost on reset, or the flash wears out. Covers LittleFS, FAT, SPIFFS and NVS.

  • 16 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 7, 2026
ai-agentsgodebugging

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 7, 2026

npx -y skills add Esmail-sarhadi/esp32-agent-skills --skill esp32-storage-and-filesystem --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Esp32 Storage And Filesystem?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Esp32 Storage And Filesystem
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/esmail-sarhadi-esp32-storage-and-filesystem/badge)](https://www.skillsdirectory.com/skills/esmail-sarhadi-esp32-storage-and-filesystem)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: esp32-storage-and-filesystem
description: Use when choosing or debugging storage on ESP32 - the filesystem will not mount after a power cut, the partition is smaller than the chip, config is lost on reset, or the flash wears out. Covers LittleFS, FAT, SPIFFS and NVS.
license: MIT
---

# Storage on ESP32

There are three storage layers and they solve different problems. Picking the
wrong one is the usual cause of "the settings disappeared".

## Which one

| Need | Use | Why not the others |
|---|---|---|
| A few keys and small values | NVS | a filesystem for 40 bytes of config is a liability |
| Files, logs, assets, a web UI | LittleFS | SPIFFS is deprecated in IDF 5 and not power-loss safe |
| An SD card the user can remove | FAT | the card must be readable on a PC |
| OTA images | the partition table | not a filesystem at all |

## NVS

NVS is a key-value store with its own partition, its own wear levelling and its
own encryption option. Two things to know:

- A write is not durable until it is committed. Losing power between the set and
  the commit loses the value, silently.
- It is small. A few thousand entries at most, and large blobs belong somewhere
  else.

If a stored value is missing after a reboot, check that the namespace string
matches exactly - a typo reads as "not found", not as an error.

## LittleFS versus SPIFFS

SPIFFS does not survive an unexpected power loss well and has been superseded.
LittleFS keeps a journal and is the default for good reason. If a project still
uses SPIFFS, that is a finding worth raising, not a style preference.

Neither one gives you atomic writes at the application level: write to a temporary
file, then rename. A rename is the closest thing to a commit a filesystem offers.

## Sizing

The filesystem is exactly as big as its partition, not as big as the flash. A
4 MB module with a 256 KB `spiffs` partition reports ~200 KB usable after
overhead, and that is correct behaviour, not a bug.

## Wear

Flash sectors tolerate roughly 100k erase cycles. A log written every second to
the same sector will wear it out in weeks. Log to RAM and flush on a schedule, or
rotate across files.

## Mount failure is a decision

`ESP_ERR_NOT_FOUND` or a failed mount on first boot is normal for a blank
partition. Formatting is the right response **once**. Formatting automatically on
every mount failure turns a transient error into data loss - require an explicit
condition, and log which one fired.

## Rules for the agent

- Do not add a filesystem for something NVS can hold.
- Never call `format()` unconditionally in the mount path.
- When a device loses settings on power loss, check the commit and the rename
  before blaming the flash.

Files in this skill

  • LICENSE.txt857 B
  • SKILL.md2.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.