# Opensearch ignoring "-XX:-UsePerfData" to disable "perfdata" java feature (to avoid creating "hsperfdata\_opensearch" dir in /tmp)

**URL:** <https://forum.opensearch.org/t/opensearch-ignoring-xx-useperfdata-to-disable-perfdata-java-feature-to-avoid-creating-hsperfdata-opensearch-dir-in-tmp/9145>\
**Category:** OpenSearch\
**Tags:** troubleshoot\
**Created:** [April 6, 2022, 2:34am UTC](https://forum.opensearch.org/t/opensearch-ignoring-xx-useperfdata-to-disable-perfdata-java-feature-to-avoid-creating-hsperfdata-opensearch-dir-in-tmp/9145 "2022-04-06T02:34:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shadab](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@shadab](https://forum.opensearch.org/u/shadab)\
**Post date:** [April 6, 2022, 2:34am UTC](https://forum.opensearch.org/t/opensearch-ignoring-xx-useperfdata-to-disable-perfdata-java-feature-to-avoid-creating-hsperfdata-opensearch-dir-in-tmp/9145/1 "2022-04-06T02:34:47Z")

</div>

Hi members,

Looking forward for some help in issues we’re facing in setting up our Opensearch environement (Linux VM - using opensearch tar ball)

**Issue:**  
Opensearch always create “hsperfdata\_{userid}” dir in “/tmp” folder. In our environment (Linux8 VM), “/tmp” is “noexec”. We cannot remove noexec behaviour due to security concerns.

Initially, we tried to fix it by changing “hsperfdata\_opensearch” location from “/tmp” to some other custom location e.g. /opt/os/tmp but nothing worked. Passed below listed variables/arguments in jvm.options / JAVA\_OPTS but no luck, nothing worked. Opensearch continue to create “hsperfdata\_opensearch” dir in /tmp folder only.

```auto
-Djava.io.tmpdir=/opt/os/tmp
TMPDIR=/opt/os/tmp
TMP=/opt/os/tmp
-Djna.tmpdir=/opt/os/tmp

```

Eventually, we thought to disable this “hsperfdata” feature in our opensearch environment. “hsperfdata” is a java feature and default location in java for this is “/tmp” (hardcoded).

To disable it, (as Java documentaion suggested), we passed java option “-XX:-UsePerfData” but opensearch is keep on ignoring it. It’s continue to create “hsperfdata\_opensearch” in /tmp.

We set “-XX:-UsePerfData” in “OPENSEARCH\_HOME/config/jvm.options” as well as tried in JAVA command in “OPENSEARCH\_HOME/bin/opensearch” executable file (hard coded for testing purpose) but no luck. Opensearch is not at all entertaining this Java option “-XX:-UsePerfData”. We even stripped out triggering command for opensearch, passed “-XX:-UsePerfData” in that java command to run opensearch, but it’s still creating “hsperfdata\_opensearch” in /tmp dir only.

NOTE: To test the behaviour independently, we created a test Hello World Java program. Tried Java option “-XX:-UsePerfData” there, and it shows expected behaviour, as follows:

- Ran Java “HelloWorld” program **WITHOUT** “-XX:-UsePerfData” - a directory “hsperfdata\_opensearch” got created in /tmp

sample command:  
/opt/opensearch-1.2.4/jdk/bin/java -Djava.io.tmpdir=/opt/os/tmp HelloWorld

- Ran Java “HelloWorld” program **WITH** “-XX:-UsePerfData” - **No** “hsperfdata\_opensearch” got created in /tmp

sample command:  
/opt/opensearch-1.2.4/jdk/bin/java -XX:-UsePerfData -Djava.io.tmpdir=/opt/os/tmp HelloWorld

However, in case of Opensearch, irrespective to if we pass Java option “-XX:-UsePerfData” or not, it always create “hsperfdata\_opensearch” in “/tmp” dir.  
NOTE: In “hsperfdata\_opensearch” → opensearch is the user we use to run the opensearch process.

Environment:  
Linux8, VM  
Opensearch1.4 which uses JVM[AdoptOpenJDK/OpenJDK 64-Bit Server VM/15.0.1/15.0.1+9]

---

<div class="post-metadata">

**Author:** ![shadab](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@shadab](https://forum.opensearch.org/u/shadab)\
**Post date:** [April 7, 2022, 1:01am UTC](https://forum.opensearch.org/t/opensearch-ignoring-xx-useperfdata-to-disable-perfdata-java-feature-to-avoid-creating-hsperfdata-opensearch-dir-in-tmp/9145/2 "2022-04-07T01:01:20Z")

</div>

Opensearch is actually ignoring all my custom configurations done in “jvm.options” or in OPENSEARCH\_JAVA\_OPTS etc… I want to change /tmp location to some custom location “/opt/os/tmp” to fix issue (Error below). But nothing is working. Could any of you please suggest how to fix it in Opensearch?

```auto
[2022-04-01T10:18:09,587][WARN][o.o.b.Natives] [npsy7sretools01] unable to load JNA native support library, native methods will be disabled.
java.lang.UnsatisfiedLinkError: /tmp/opensearch-1131263490975920622/jna1578977023810974048.tmp: /tmp/opensearch-1131263490975920622/jna1578977023810974048.tmp: failed to map segment from shared object

```

---

<div class="post-metadata">

**Author:** ![dtaivpp](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/dtaivpp/32/2814_2.png) [@dtaivpp](https://forum.opensearch.org/u/dtaivpp)\
**Post date:** [April 14, 2022, 3:05pm UTC](https://forum.opensearch.org/t/opensearch-ignoring-xx-useperfdata-to-disable-perfdata-java-feature-to-avoid-creating-hsperfdata-opensearch-dir-in-tmp/9145/3 "2022-04-14T15:05:11Z")

</div>

Hey Shadab, this actually might be better listed as a bug in the OpenSearch project. Here is the link to create one:

[https://github.com/opensearch-project/OpenSearch/issues/new?assignees=&labels=bug%2C+untriaged&template=bug\_template.md&title=[BUG]](https://github.com/opensearch-project/OpenSearch/issues/new?assignees=&labels=bug%2C+untriaged&template=bug_template.md&title=%5BBUG%5D)

This is the first I am seeing a security concern about using tmp in particular when a whole new VM is being used to host it. Do you have a link to something I can read to learn a bit more about why this is a concern? Thank you, and looking forward to looking into it more!

---

<div class="post-metadata">

**Author:** ![shadab](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@shadab](https://forum.opensearch.org/u/shadab)\
**Post date:** [April 19, 2022, 5:13am UTC](https://forum.opensearch.org/t/opensearch-ignoring-xx-useperfdata-to-disable-perfdata-java-feature-to-avoid-creating-hsperfdata-opensearch-dir-in-tmp/9145/4 "2022-04-19T05:13:59Z")

</div>

Hi @dtaivpp

I got the root cause of the issue which made us thinking to try default perf location (/tmp) to some other location where user “opensearch” has permissiones. Therefore, we no longer required to change perf location from /tmp to others.

**Below are more details:**

Trigger point of /tmp related location issues is – “when we run opensearch service on Linux as a user who doesn’t have home dir on executable path”. We start getting JNA error unsatisfied link related.

```auto
[2022-04-01T13:00:23,035][WARN][o.o.b.Natives] [osmaster1] unable to load JNA native support library, native methods will be disabled.
java.lang.UnsatisfiedLinkError: /tmp/opensearch-1073614746573548365/jna9916496385695771284.tmp: /tmp/opensearch-1073614746573548365/jna9916496385695771284.tmp: failed to map segment from shared object
        at jdk.internal.loader.NativeLibraries.load(Native Method) ~[?:?]

```

So, when user doesnt have home dir, opensearch try to use “/tmp” dir for JNA and other stuff. But, since user “opensearch” doesn’t have execute permissions, it throws “unsatisfied link” error.

To try fixing it - we tried io.dir from /tmp to other other location but in that case JVM was crashing.

**How to fix it:**

Step#1 - Create user e.g. “opensearch” with a home dir on executable path for this user.  
For example: Home dir “/opt/opensearch” for user “opensearch” .

Sample command: useradd -r -m -d /opt/opensearch opensearch

Step#2 - install opensearch in this dir /opt/opensearch/  
So, your installation will look like /opt/opensearch/opensearch1.4.xx

**More details about JNA / Unsatisfied link error I was facing:**

> [@Opensearch process FAILED to start due to "java.lang.UnsatisfiedLinkError: /tmp/opensearch-\*\*\*\*\* failed to map segment from shared object" error](https://forum.opensearch.org/t/opensearch-process-failed-to-start-due-to-java-lang-unsatisfiedlinkerror-tmp-opensearch-failed-to-map-segment-from-shared-object-error/9105/2):
>
> In addition to details shared above, when I set custom “tmpdir” path (like /opt/os\_tmp/tmp), JVM get crashed and a dir “hsperfdata\_opensearch” get created under “/tmp”. It’s empty dir. Northing get created under tmpdir path (/opt/os\_tmp/tmp).

Hope this help others facing similar issue.

---

<div class="post-metadata">

**Author:** ![dtaivpp](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/dtaivpp/32/2814_2.png) [@dtaivpp](https://forum.opensearch.org/u/dtaivpp)\
**Post date:** [April 19, 2022, 8:03pm UTC](https://forum.opensearch.org/t/opensearch-ignoring-xx-useperfdata-to-disable-perfdata-java-feature-to-avoid-creating-hsperfdata-opensearch-dir-in-tmp/9145/5 "2022-04-19T20:03:01Z")

</div>

Thank you for coming back and sharing your findings with the community! This is a great write-up!
