diff --git a/core/src/main/java/org/elasticsearch/env/ESFileStore.java b/core/src/main/java/org/elasticsearch/env/ESFileStore.java index d74432c591a..abd9d2e072f 100644 --- a/core/src/main/java/org/elasticsearch/env/ESFileStore.java +++ b/core/src/main/java/org/elasticsearch/env/ESFileStore.java @@ -84,7 +84,18 @@ class ESFileStore extends FileStore { return getFileStoreWindows(path, fileStores); } - FileStore store = Files.getFileStore(path); + final FileStore store; + try { + store = Files.getFileStore(path); + } catch (IOException unexpected) { + // give a better error message if a filestore cannot be retrieved from inside a FreeBSD jail. + if (Constants.FREE_BSD) { + throw new IOException("Unable to retrieve mount point data for " + path + + ". If you are running within a jail, set enforce_statfs=1. See jail(8)", unexpected); + } else { + throw unexpected; + } + } try { String mount = getMountPointLinux(store); diff --git a/core/src/main/java/org/elasticsearch/env/Environment.java b/core/src/main/java/org/elasticsearch/env/Environment.java index a82dab995e5..c5c769a73c2 100644 --- a/core/src/main/java/org/elasticsearch/env/Environment.java +++ b/core/src/main/java/org/elasticsearch/env/Environment.java @@ -304,6 +304,7 @@ public class Environment { * no permissions to the actual mount point are required. *
  • Exception handling has the same semantics as {@link Files#getFileStore(Path)}. *
  • Works around https://bugs.openjdk.java.net/browse/JDK-8034057. + *
  • Gives a better exception when filestore cannot be retrieved from inside a FreeBSD jail. * */ public static FileStore getFileStore(Path path) throws IOException {