4

TL;DR

When a fuse filesystem is mounted via the mount command, the environment variables are not passed to the fuse script. Why?

Context

I am trying to mount hdfs (hadoop file system) via fuse.

This is easy on the command line:

# Short example version:
LD_LIBRARY_PATH=blah hadoop-fuse-dfs -onotrash  dfs://ambari:8020 /mnt/hdfsfuse
# Actual version with full path for completeness
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/hadoop/yarn/local/filecache/11/mapreduce.tar.gz/hadoop/lib/native /usr/hdp/2.5.0.0-1245/hadoop/bin/hadoop-fuse-dfs -onotrash  dfs://ambari:8020 /mnt/hdfsfuse

This is all and well, but if I put the definition of the FS in /etc/fstab to then use the mount command, I end up with:

fuse_dfs: error while loading shared libraries: libjvm.so: cannot open shared object file: No such file or directory

Looking at the hadoop-fuse-dfs script and adding debug output, I see that LD_LIBRARY_PATH is seen as empty in this script (this is true both if I export LD_LIBRARY_PATH first or if I add it at the start of the command)

System

hdp 2.5, centos 7

Question

Short of rewriting the mount script to hardcode LD_LIBRARY_PATH, how can I have environment variables in general passed via mount?

2 Answers 2

3

You can write your own mount fuse helper, which then calls the real fuse script. In the simple case of an fstab entry like:

dfs://ambari:8020  /mnt/hdfsfuse  fuse.mydfshelper  flag,flag,...

then your script /usr/bin/mydfshelper is called with args

dfs://ambari:8020 /mnt/hdfsfuse -o flag,flag,...

So you just need to write a one-line mydfshelper holding something like:

#!/bin/bash
LD_LIBRARY_PATH=blah hadoop-fuse-dfs -onotrash "$@"
1
  • That's a great tip and seems kinda obvious once you think about it :( . I have an easier option to only solve the LD_LIBRARY_PATH issue (see other answer), but I like that this answer is very generic.
    – Guillaume
    Feb 2, 2017 at 6:34
1

To solve my particular problem, (LD_LIBRARY_PATH), the easiest I found is to add the content of the variable in a file under /etc/ld.so.conf.d. For instance, I created /etc/ld.so.conf.d/hdp.conf with the content:

/usr/java/jdk1.8.0_66/jre/lib/amd64/server
/usr/hdp/2.5.0.0-1245/usr/lib

After running once ldconfig as root, this new 'ld_library_path' is available system wide.

To answer the question about environment variables in general, the answer from @meuh is best.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .