apache/hadoop · critical · java.io.IOException
NameNode is not formatted.
Error message
NameNode is not formatted.
What it means
FSImage.recoverStorageDirs() visited every storage directory and none contained formatted state (a VERSION file), so isFormatted stayed false. With a normal startup option the NameNode has no namespace to load and aborts. Rollback and IMPORT are exempt because they write state instead of only reading it.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java:254
&& startOpt != StartupOption.IMPORT)
throw new IOException(
"All specified directories are not accessible or do not exist.");
// 1. For each data directory calculate its state and
// check whether all is consistent before transitioning.
Map<StorageDirectory, StorageState> dataDirStates =
new HashMap<StorageDirectory, StorageState>();
boolean isFormatted = recoverStorageDirs(startOpt, storage, dataDirStates);
if (LOG.isTraceEnabled()) {
LOG.trace("Data dir states:\n " +
Joiner.on("\n ").withKeyValueSeparator(": ")
.join(dataDirStates));
}
if (!isFormatted && startOpt != StartupOption.ROLLBACK
&& startOpt != StartupOption.IMPORT) {
throw new IOException("NameNode is not formatted.");
}
int layoutVersion = storage.getLayoutVersion();
if (startOpt == StartupOption.METADATAVERSION) {
System.out.println("HDFS Image Version: " + layoutVersion);
System.out.println("Software format version: " +
storage.getServiceLayoutVersion());
return false;
}
if (layoutVersion < Storage.LAST_PRE_UPGRADE_LAYOUT_VERSION) {
NNStorage.checkVersionUpgradable(storage.getLayoutVersion());
}
if (startOpt != StartupOption.UPGRADE
&& startOpt != StartupOption.UPGRADEONLY
&& !RollingUpgradeStartupOption.STARTED.matches(startOpt)
&& layoutVersion < Storage.LAST_PRE_UPGRADE_LAYOUT_VERSIONView on GitHub (pinned to 2add963021)
Solutions
- New cluster: run 'hdfs namenode -format [-clusterid mycluster]' then start the NameNode (never format over an existing cluster's data).
- Existing cluster: check mounts and dfs.namenode.name.dir — the formatted volume is probably elsewhere or unmounted; <dir>/current/VERSION should exist.
- HA cluster: copy current/ (fsimage, edits, VERSION) from the healthy Standby NameNode into this node's name dir.
- Otherwise restore fsimage+edits from the Secondary NameNode checkpoint or backups.
Example fix
# before hdfs --daemon start namenode # IOException: NameNode is not formatted. # after (new cluster only!) hdfs namenode -format -clusterid mycluster hdfs --daemon start namenode
Defensive patterns
Strategy: validation
Validate before calling
for (URI u : nameDirUris) {
Path versionFile = Paths.get(u.getPath(), "VERSION");
if (!Files.exists(versionFile)) {
// unformatted dir: format explicitly or restore metadata before starting
}
} Prevention
- Keep NameNode metadata off /tmp (the default location is only for tests).
- Script a startup check that <name.dir>/current/VERSION exists on every dir.
- In HA, keep a Standby so metadata always has a second copy.
When it happens
Trigger: First start of a NameNode without running 'hdfs namenode -format'; dfs.namenode.name.dir retargeted to a fresh path or a wiped volume; VERSION files deleted by cleanup scripts; container started without its metadata volume mounted.
Common situations: Brand-new clusters never formatted; default /tmp-based name dirs cleaned on reboot; volume remounted empty after disk replacement; name.dir pointing to the wrong path after config drift.
Related errors
- Cannot lock storage {root}. The directory is already locked
- All specified directories are not accessible or do not exist
- Directory {dir} is in an inconsistent state: storage directo
- Unknown nameservice: {}
- Configuration has multiple addresses that match local node's
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/7b36ee7671d69259.
Report an issue: GitHub.