{"record":{"id":"d3c70997e860186b","repo":"apache/hadoop","slug":"cannot-create-directory-aliasmapfile","errorCode":null,"errorMessage":"Cannot create directory ${aliasMapFile}","messagePattern":"Cannot create directory (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/BootstrapStandby.java","lineNumber":567,"sourceCode":"    }\n    File aliasMapFile = new File(pathAliasMap);\n    if (aliasMapFile.exists()) {\n      AliasMapStorageDirectory aliasMapSD =\n          new AliasMapStorageDirectory(aliasMapFile);\n      if (!Storage.confirmFormat(\n          Arrays.asList(aliasMapSD), force, interactive)) {\n        return ERR_CODE_ALREADY_FORMATTED;\n      } else {\n        if (!FileUtil.fullyDelete(aliasMapFile)) {\n          throw new IOException(\n              \"Cannot remove current alias map: \" + aliasMapFile);\n        }\n      }\n    }\n\n    // create the aliasmap location.\n    if (!aliasMapFile.mkdirs()) {\n      throw new IOException(\"Cannot create directory \" + aliasMapFile);\n    }\n    TransferFsImage.downloadAliasMap(proxyInfo.getHttpAddress(), aliasMapFile,\n        true);\n    return 0;\n  }\n\n  @Override\n  public void setConf(Configuration conf) {\n    this.conf = DFSHAAdmin.addSecurityConfiguration(conf);\n  }\n\n  @Override\n  public Configuration getConf() {\n    return conf;\n  }\n  \n  public static int run(String[] argv, Configuration conf) throws IOException {\n    BootstrapStandby bs = new BootstrapStandby();","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/BootstrapStandby.java#L549-L585","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Create the parent chain with correct ownership: mkdir -p <parent> && chown hdfs:hadoop <parent>","Ensure no regular file occupies the exact aliasmap path and the volume has space (df -h)","Confirm the mount is rw, then re-run 'hdfs namenode -bootstrapStandby'"],"exampleFix":"# before\n$ sudo -u hdfs hdfs namenode -bootstrapStandby\nIOException: Cannot create directory /data/dfs/aliasmap/inmemory\n# after\n$ sudo mkdir -p /data/dfs/aliasmap && sudo chown hdfs:hadoop /data/dfs/aliasmap\n$ sudo -u hdfs hdfs namenode -bootstrapStandby","handlingStrategy":"validation","validationCode":"File alias = new File(conf.get(\"dfs.provided.aliasmap.inmemory.leveldb.dir\"));\nif (alias.exists() && !alias.isDirectory()) {\n  throw new IOException(\"Refusing aliasmap bootstrap: regular file occupies \" + alias);\n}\nFile parent = alias.getParentFile();\nif (parent != null && !(parent.isDirectory() && parent.canWrite())) {\n  throw new IOException(\"Cannot create \" + alias + \": parent missing or not writable\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  runner.run(argv);\n} catch (IOException e) { // \"Cannot create directory <aliasMapFile>\"\n  // create/chown the parent, ensure disk space, then re-run bootstrap\n}","preventionTips":["Pre-create aliasmap parent directories in provisioning with the NN user as owner","Disk-space alerts on the volume hosting the aliasmap; it grows with provided-storage block mappings"],"tags":["hdfs","namenode","bootstrap-standby","aliasmap","mkdir-failed","permissions","disk-full"],"backgroundTag":"mkdir-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}