apache/hadoop · error · IOException
Invalid path: {location}: directory does not exist
Error message
Invalid path: {location}: directory does not exist What it means
checkSameDiskTieringMount runs during refreshVolumes when dfs.datanode.allow.same.disk.tiering is true and the new location's storage type participates in same-disk tiering. To find the disk mount point it climbs parent-by-parent from the location path to the first existing directory; if getParentFile() returns null before any ancestor exists (relative path, a URI java.io.File cannot walk, or an entirely missing directory chain), it throws IOException("Invalid path: <location>: directory does not exist").
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java:1259
*
* TODO: We can add feature to
* allow refreshing volume with capacity ratio,
* and solve the case of replacing volume on same mount.
*/
private void validateVolumesWithSameDiskTiering(ChangedVolumes
changedVolumes) throws IOException {
if (dnConf.getConf().getBoolean(DFS_DATANODE_ALLOW_SAME_DISK_TIERING,
DFS_DATANODE_ALLOW_SAME_DISK_TIERING_DEFAULT)
&& data.getMountVolumeMap() != null) {
// Check if mount already exist.
for (StorageLocation location : changedVolumes.newLocations) {
if (StorageType.allowSameDiskTiering(location.getStorageType())) {
File dir = new File(location.getUri());
// Get the first parent dir that exists to check disk mount point.
while (!dir.exists()) {
dir = dir.getParentFile();
if (dir == null) {
throw new IOException("Invalid path: "
+ location + ": directory does not exist");
}
}
DF df = new DF(dir, dnConf.getConf());
String mount = df.getMount();
if (data.getMountVolumeMap().hasMount(mount)) {
String errMsg = "Disk mount " + mount
+ " already has volume, when trying to add "
+ location + ". Please try removing mounts first"
+ " or restart datanode.";
LOG.error(errMsg);
throw new IOException(errMsg);
}
}
}
}
}
View on GitHub (pinned to 2add963021)
Solutions
- Create the directory chain on the DN host first: mkdir -p /mnt/disk2/dn && chown hdfs:hdfs, then resubmit
- Use absolute paths with the file:// scheme; relative paths cannot be resolved by this check
- Verify the mount is live before retrying: findmnt /mnt/disk2 or stat -f /mnt/disk2
Example fix
# before: /mnt/diskX not mounted, path has no existing ancestor dfs.datanode.data.dir=[DISK]/mnt/diskX/dn # after mkdir -p /mnt/diskX/dn && mount /dev/sdb1 /mnt/diskX # on the DN host dfs.datanode.data.dir=[DISK]file:///mnt/diskX/dn
Defensive patterns
Strategy: validation
Validate before calling
File f = new File(location.getUri());
if (!f.isAbsolute()) throw new IllegalArgumentException("use an absolute file:// path: " + location);
File probe = f;
while (probe != null && !probe.exists()) probe = probe.getParentFile();
if (probe == null) throw new IllegalArgumentException("no existing ancestor for " + f); Try / catch
catch (ReconfigurationException e) {
if (String.valueOf(e.getCause()).contains("directory does not exist")) {
// mkdir -p the path (and mount the disk) on the DN host, then resubmit
}
} Prevention
- Pre-flight 'mkdir -p' every new data dir on the DN host before a volume refresh
- Always use absolute paths with an explicit file:// scheme
- Verify mounts are live (findmnt) before adding volumes under them
When it happens
Trigger: Submitting a relative data dir like data/dn1; a path under a mount that is not mounted or not yet created (typo /mnt/diskX/dn where diskX does not exist); a URI form File maps to nothing. Only checked when same-disk tiering is enabled and the location's type allows it.
Common situations: New disks cabled but not mounted when the reconfig fires; template paths referencing host-specific mounts that differ per host; NFS/network mounts flapping mid-refresh.
Related errors
- No directory is specified.
- Changing storage type is not allowed.
- Disk mount {mount} already has volume, when trying to add {l
- Attempt to remove all volumes.
- Invalid value configured for dfs.datanode.failed.volumes.tol
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/e6d79fe50820f570.
Report an issue: GitHub.