apache/hadoop · error · IOException

Cannot create directory ${aliasMapFile}

Error message

Cannot create directory ${aliasMapFile}

What it means

After clearing any old store, formatAndDownloadAliasMap() creates the aliasmap directory with aliasMapFile.mkdirs(); a false return throws IOException('Cannot create directory <path>'). The download target location could not be established on local disk.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/BootstrapStandby.java:567

    }
    File aliasMapFile = new File(pathAliasMap);
    if (aliasMapFile.exists()) {
      AliasMapStorageDirectory aliasMapSD =
          new AliasMapStorageDirectory(aliasMapFile);
      if (!Storage.confirmFormat(
          Arrays.asList(aliasMapSD), force, interactive)) {
        return ERR_CODE_ALREADY_FORMATTED;
      } else {
        if (!FileUtil.fullyDelete(aliasMapFile)) {
          throw new IOException(
              "Cannot remove current alias map: " + aliasMapFile);
        }
      }
    }

    // create the aliasmap location.
    if (!aliasMapFile.mkdirs()) {
      throw new IOException("Cannot create directory " + aliasMapFile);
    }
    TransferFsImage.downloadAliasMap(proxyInfo.getHttpAddress(), aliasMapFile,
        true);
    return 0;
  }

  @Override
  public void setConf(Configuration conf) {
    this.conf = DFSHAAdmin.addSecurityConfiguration(conf);
  }

  @Override
  public Configuration getConf() {
    return conf;
  }
  
  public static int run(String[] argv, Configuration conf) throws IOException {
    BootstrapStandby bs = new BootstrapStandby();

View on GitHub (pinned to 2add963021)

Solutions

  1. Create the parent chain with correct ownership: mkdir -p <parent> && chown hdfs:hadoop <parent>
  2. Ensure no regular file occupies the exact aliasmap path and the volume has space (df -h)
  3. Confirm the mount is rw, then re-run 'hdfs namenode -bootstrapStandby'

Example fix

# before
$ sudo -u hdfs hdfs namenode -bootstrapStandby
IOException: Cannot create directory /data/dfs/aliasmap/inmemory
# after
$ sudo mkdir -p /data/dfs/aliasmap && sudo chown hdfs:hadoop /data/dfs/aliasmap
$ sudo -u hdfs hdfs namenode -bootstrapStandby
Defensive patterns

Strategy: validation

Validate before calling

File alias = new File(conf.get("dfs.provided.aliasmap.inmemory.leveldb.dir"));
if (alias.exists() && !alias.isDirectory()) {
  throw new IOException("Refusing aliasmap bootstrap: regular file occupies " + alias);
}
File parent = alias.getParentFile();
if (parent != null && !(parent.isDirectory() && parent.canWrite())) {
  throw new IOException("Cannot create " + alias + ": parent missing or not writable");
}

Try / catch

try {
  runner.run(argv);
} catch (IOException e) { // "Cannot create directory <aliasMapFile>"
  // create/chown the parent, ensure disk space, then re-run bootstrap
}

Prevention

When it happens

Trigger: mkdirs() on the configured dfs.provided.aliasmap.inmemory.leveldb.dir path fails — parent not writable by the NN user, disk full or quota exceeded, read-only mount, or a regular file already exists at that path.

Common situations: Aliasmap path parent owned by root on a fresh standby; path collides with an existing file; volume out of space; path on a read-only NFS mount.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/d3c70997e860186b. Report an issue: GitHub.