public static void preAllocateFileIfNeeded(File file, long capacityBytes) throws IOException {
    if (!file.exists()) {
      file.createNewFile();
    }
    if (isLinux()) {
      Runtime runtime = Runtime.getRuntime();
      Process process = runtime.exec("fallocate --keep-size -l " + capacityBytes + " " + file.getAbsolutePath());
      try {
        process.waitFor();
      } catch (InterruptedException e) {
        // ignore the interruption and check the exit value to be sure
      }
      if (process.exitValue() != 0) {
        throw new IOException(
            "error while trying to preallocate file " + file.getAbsolutePath() + " exitvalue " + process.exitValue()
                + " error string " + new BufferedReader(new InputStreamReader(process.getErrorStream())).lines()
                .collect(Collectors.joining("/n")));
      }
    }
  }
Ensures that a given File is present. The file is pre-allocated with a given capacity using fallocate on linux
@param file file path to create and allocate
@param capacityBytes the number of bytes to pre-allocate
@throws IOException
ambry-utils/src/main/java/com/github/ambry/utils/Utils.java