inetum-orleans / nfs4j-daemon

Pure Java NFS v3/v4.1 server backed by dCache nfs4j
Apache License 2.0
35 stars 10 forks source link

nfs4j-daemon

Pure Java NFS v3/v4.1 server backed by dCache nfs4j.

This project has been designed as an alternative to winnfsd. Vagrant plugin is available at gfi-centre-ouest/vagrant-nfs4j.

NFS v3 is available, but not untested and unsupported. You should use NFS v4.1 only for now.

TODO:

Quickstart

java -jar nfs4j-daemon.jar
nfs4j-daemon.exe
mkdir /mnt/nfs4j
mount -t nfs 192.168.1.1:/ /mnt/nfs4j

Options

All options are available through Command Line and Configuration File.

Command Line

java -jar nfs4j-daemon.jar --help
Usage: <main class> [-h] [--api] [--no-share] [--portmap-disabled] [--udp]
                    [--api-bearer=<apiBearer>] [--api-ip=<apiIp>]
                    [--api-port=<apiPort>] [-c=<config>] [-e=<exports>]
                    [-g=<gid>] [-m=<mask>] [-p=<port>] [-t=<permissionType>]
                    [-u=<uid>] [<shares>...]
      [<shares>...]          Directories to share
  -c, --config=<config>      Path to configuration file
  -u, --uid=<uid>            Default user id to use for exported files
  -g, --gid=<gid>            Default group id to use for exported files
  -m, --mask=<mask>          Default mask to use for exported files
  -t, --permission-type=<permissionType>
                             Permission type to use (DISABLED, EMULATED, UNIX)
                               Default: DISABLED
  -p, --port=<port>          Port to use
      --api                  Enable HTTP API
      --api-port=<apiPort>   Port to use for API
      --api-ip=<apiIp>       Ip to use for API
      --api-bearer=<apiBearer>
                             Bearer to use for API authentication
      --no-share             Disable default share and configured shares
      --udp                  Use UDP instead of TCP
      --portmap-disabled     Disable embedded portmap service
  -e, --exports=<exports>    Path to exports file (nsf4j advanced configuration)
  -h, --help                 Display this help message

Configuration File

Configuration file is loaded from nfs4j.yml in working directory by default.

You can set a custom filepath to this configuration file with -c, --config=<config> command line option.

port: 2048
udp: false
permissions:
  gid: 1000
  uid: 1000
  mask: 0644
shares:
  - 'C:\Users\Toilal\projects\planireza'
  - 'C:\Users\Toilal\projects\docker-devbox'
  - 'D:\'

Make sure you are using single quote on shares definition strings in yaml configuration file to avoid issues with backslashes.

Shares configuration

# Service side
java -jar nfs4j-daemon.jar
# Client side
mount -t nfs 192.168.1.1:/ /mnt/nfs4j
# Service side
java -jar nfs4j-daemon.jar C:\my\folder
# Client side
mount -t nfs 192.168.1.1:/ /mnt/nfs4j
# Server side
java -jar nfs4j-daemon.jar C:\my\folder D:\another\folder
# Client side
mount -t nfs 192.168.1.1:/C/my/folder /mnt/nfs4j-1
mount -t nfs 192.168.1.1:/D/another/folder /mnt/nfs4j-2
# Service side
java -jar nfs4j-daemon.jar C:\my\folder:/folder1 D:\another\folder:/folder2
# Client side
mount -t nfs 192.168.1.1:/folder1 /mnt/nfs4j-1
mount -t nfs 192.168.1.1:/folder2 /mnt/nfs4j-2
shares:
  - 'C:\my\folder:/folder1'
  - 'D:\another\folder:/folder2'
shares:
  - path: 'C:\my\folder'
    alias: '/folder1'
  - path: 'D:\another\folder'
    alias: '/folder2'

Symbolic links support on Windows

On default Windows installation, unprivileged user can't create symbolic links, so nfs4j may fail to create symbolic links too.

You have some options to workaround this issue.

Build from sources

mvn clean verify