github.com/artpar/rclone@v1.67.3/docs/content/commands/rclone_serve_nfs.md (about)

     1  ---
     2  title: "rclone serve nfs"
     3  description: "Serve the remote as an NFS mount"
     4  slug: rclone_serve_nfs
     5  url: /commands/rclone_serve_nfs/
     6  groups: Filter
     7  status: Experimental
     8  versionIntroduced: v1.65
     9  # autogenerated - DO NOT EDIT, instead edit the source code in cmd/serve/nfs/ and as part of making a release run "make commanddocs"
    10  ---
    11  # rclone serve nfs
    12  
    13  Serve the remote as an NFS mount
    14  
    15  ## Synopsis
    16  
    17  Create an NFS server that serves the given remote over the network.
    18  	
    19  The primary purpose for this command is to enable [mount command](/commands/rclone_mount/) on recent macOS versions where
    20  installing FUSE is very cumbersome. 
    21  
    22  Since this is running on NFSv3, no authentication method is available. Any client
    23  will be able to access the data. To limit access, you can use serve NFS on loopback address
    24  and rely on secure tunnels (such as SSH). For this reason, by default, a random TCP port is chosen and loopback interface is used for the listening address;
    25  meaning that it is only available to the local machine. If you want other machines to access the
    26  NFS mount over local network, you need to specify the listening address and port using `--addr` flag.
    27  
    28  Modifying files through NFS protocol requires VFS caching. Usually you will need to specify `--vfs-cache-mode`
    29  in order to be able to write to the mountpoint (full is recommended). If you don't specify VFS cache mode,
    30  the mount will be read-only. Note also that `--nfs-cache-handle-limit` controls the maximum number of cached file handles stored by the caching handler.
    31  This should not be set too low or you may experience errors when trying to access files. The default is `1000000`, but consider lowering this limit if
    32  the server's system resource usage causes problems.
    33  
    34  To serve NFS over the network use following command:
    35  
    36      rclone serve nfs remote: --addr 0.0.0.0:$PORT --vfs-cache-mode=full
    37  
    38  We specify a specific port that we can use in the mount command:
    39  
    40  To mount the server under Linux/macOS, use the following command:
    41      
    42      mount -oport=$PORT,mountport=$PORT $HOSTNAME: path/to/mountpoint
    43  
    44  Where `$PORT` is the same port number we used in the serve nfs command.
    45  
    46  This feature is only available on Unix platforms.
    47  
    48  ## VFS - Virtual File System
    49  
    50  This command uses the VFS layer. This adapts the cloud storage objects
    51  that rclone uses into something which looks much more like a disk
    52  filing system.
    53  
    54  Cloud storage objects have lots of properties which aren't like disk
    55  files - you can't extend them or write to the middle of them, so the
    56  VFS layer has to deal with that. Because there is no one right way of
    57  doing this there are various options explained below.
    58  
    59  The VFS layer also implements a directory cache - this caches info
    60  about files and directories (but not the data) in memory.
    61  
    62  ## VFS Directory Cache
    63  
    64  Using the `--dir-cache-time` flag, you can control how long a
    65  directory should be considered up to date and not refreshed from the
    66  backend. Changes made through the VFS will appear immediately or
    67  invalidate the cache.
    68  
    69      --dir-cache-time duration   Time to cache directory entries for (default 5m0s)
    70      --poll-interval duration    Time to wait between polling for changes. Must be smaller than dir-cache-time. Only on supported remotes. Set to 0 to disable (default 1m0s)
    71  
    72  However, changes made directly on the cloud storage by the web
    73  interface or a different copy of rclone will only be picked up once
    74  the directory cache expires if the backend configured does not support
    75  polling for changes. If the backend supports polling, changes will be
    76  picked up within the polling interval.
    77  
    78  You can send a `SIGHUP` signal to rclone for it to flush all
    79  directory caches, regardless of how old they are.  Assuming only one
    80  rclone instance is running, you can reset the cache like this:
    81  
    82      kill -SIGHUP $(pidof rclone)
    83  
    84  If you configure rclone with a [remote control](/rc) then you can use
    85  rclone rc to flush the whole directory cache:
    86  
    87      rclone rc vfs/forget
    88  
    89  Or individual files or directories:
    90  
    91      rclone rc vfs/forget file=path/to/file dir=path/to/dir
    92  
    93  ## VFS File Buffering
    94  
    95  The `--buffer-size` flag determines the amount of memory,
    96  that will be used to buffer data in advance.
    97  
    98  Each open file will try to keep the specified amount of data in memory
    99  at all times. The buffered data is bound to one open file and won't be
   100  shared.
   101  
   102  This flag is a upper limit for the used memory per open file.  The
   103  buffer will only use memory for data that is downloaded but not not
   104  yet read. If the buffer is empty, only a small amount of memory will
   105  be used.
   106  
   107  The maximum memory used by rclone for buffering can be up to
   108  `--buffer-size * open files`.
   109  
   110  ## VFS File Caching
   111  
   112  These flags control the VFS file caching options. File caching is
   113  necessary to make the VFS layer appear compatible with a normal file
   114  system. It can be disabled at the cost of some compatibility.
   115  
   116  For example you'll need to enable VFS caching if you want to read and
   117  write simultaneously to a file.  See below for more details.
   118  
   119  Note that the VFS cache is separate from the cache backend and you may
   120  find that you need one or the other or both.
   121  
   122      --cache-dir string                     Directory rclone will use for caching.
   123      --vfs-cache-mode CacheMode             Cache mode off|minimal|writes|full (default off)
   124      --vfs-cache-max-age duration           Max time since last access of objects in the cache (default 1h0m0s)
   125      --vfs-cache-max-size SizeSuffix        Max total size of objects in the cache (default off)
   126      --vfs-cache-min-free-space SizeSuffix  Target minimum free space on the disk containing the cache (default off)
   127      --vfs-cache-poll-interval duration     Interval to poll the cache for stale objects (default 1m0s)
   128      --vfs-write-back duration              Time to writeback files after last use when using cache (default 5s)
   129  
   130  If run with `-vv` rclone will print the location of the file cache.  The
   131  files are stored in the user cache file area which is OS dependent but
   132  can be controlled with `--cache-dir` or setting the appropriate
   133  environment variable.
   134  
   135  The cache has 4 different modes selected by `--vfs-cache-mode`.
   136  The higher the cache mode the more compatible rclone becomes at the
   137  cost of using disk space.
   138  
   139  Note that files are written back to the remote only when they are
   140  closed and if they haven't been accessed for `--vfs-write-back`
   141  seconds. If rclone is quit or dies with files that haven't been
   142  uploaded, these will be uploaded next time rclone is run with the same
   143  flags.
   144  
   145  If using `--vfs-cache-max-size` or `--vfs-cache-min-free-size` note
   146  that the cache may exceed these quotas for two reasons. Firstly
   147  because it is only checked every `--vfs-cache-poll-interval`. Secondly
   148  because open files cannot be evicted from the cache. When
   149  `--vfs-cache-max-size` or `--vfs-cache-min-free-size` is exceeded,
   150  rclone will attempt to evict the least accessed files from the cache
   151  first. rclone will start with files that haven't been accessed for the
   152  longest. This cache flushing strategy is efficient and more relevant
   153  files are likely to remain cached.
   154  
   155  The `--vfs-cache-max-age` will evict files from the cache
   156  after the set time since last access has passed. The default value of
   157  1 hour will start evicting files from cache that haven't been accessed
   158  for 1 hour. When a cached file is accessed the 1 hour timer is reset to 0
   159  and will wait for 1 more hour before evicting. Specify the time with
   160  standard notation, s, m, h, d, w .
   161  
   162  You **should not** run two copies of rclone using the same VFS cache
   163  with the same or overlapping remotes if using `--vfs-cache-mode > off`.
   164  This can potentially cause data corruption if you do. You can work
   165  around this by giving each rclone its own cache hierarchy with
   166  `--cache-dir`. You don't need to worry about this if the remotes in
   167  use don't overlap.
   168  
   169  ### --vfs-cache-mode off
   170  
   171  In this mode (the default) the cache will read directly from the remote and write
   172  directly to the remote without caching anything on disk.
   173  
   174  This will mean some operations are not possible
   175  
   176    * Files can't be opened for both read AND write
   177    * Files opened for write can't be seeked
   178    * Existing files opened for write must have O_TRUNC set
   179    * Files open for read with O_TRUNC will be opened write only
   180    * Files open for write only will behave as if O_TRUNC was supplied
   181    * Open modes O_APPEND, O_TRUNC are ignored
   182    * If an upload fails it can't be retried
   183  
   184  ### --vfs-cache-mode minimal
   185  
   186  This is very similar to "off" except that files opened for read AND
   187  write will be buffered to disk.  This means that files opened for
   188  write will be a lot more compatible, but uses the minimal disk space.
   189  
   190  These operations are not possible
   191  
   192    * Files opened for write only can't be seeked
   193    * Existing files opened for write must have O_TRUNC set
   194    * Files opened for write only will ignore O_APPEND, O_TRUNC
   195    * If an upload fails it can't be retried
   196  
   197  ### --vfs-cache-mode writes
   198  
   199  In this mode files opened for read only are still read directly from
   200  the remote, write only and read/write files are buffered to disk
   201  first.
   202  
   203  This mode should support all normal file system operations.
   204  
   205  If an upload fails it will be retried at exponentially increasing
   206  intervals up to 1 minute.
   207  
   208  ### --vfs-cache-mode full
   209  
   210  In this mode all reads and writes are buffered to and from disk. When
   211  data is read from the remote this is buffered to disk as well.
   212  
   213  In this mode the files in the cache will be sparse files and rclone
   214  will keep track of which bits of the files it has downloaded.
   215  
   216  So if an application only reads the starts of each file, then rclone
   217  will only buffer the start of the file. These files will appear to be
   218  their full size in the cache, but they will be sparse files with only
   219  the data that has been downloaded present in them.
   220  
   221  This mode should support all normal file system operations and is
   222  otherwise identical to `--vfs-cache-mode` writes.
   223  
   224  When reading a file rclone will read `--buffer-size` plus
   225  `--vfs-read-ahead` bytes ahead.  The `--buffer-size` is buffered in memory
   226  whereas the `--vfs-read-ahead` is buffered on disk.
   227  
   228  When using this mode it is recommended that `--buffer-size` is not set
   229  too large and `--vfs-read-ahead` is set large if required.
   230  
   231  **IMPORTANT** not all file systems support sparse files. In particular
   232  FAT/exFAT do not. Rclone will perform very badly if the cache
   233  directory is on a filesystem which doesn't support sparse files and it
   234  will log an ERROR message if one is detected.
   235  
   236  ### Fingerprinting
   237  
   238  Various parts of the VFS use fingerprinting to see if a local file
   239  copy has changed relative to a remote file. Fingerprints are made
   240  from:
   241  
   242  - size
   243  - modification time
   244  - hash
   245  
   246  where available on an object.
   247  
   248  On some backends some of these attributes are slow to read (they take
   249  an extra API call per object, or extra work per object).
   250  
   251  For example `hash` is slow with the `local` and `sftp` backends as
   252  they have to read the entire file and hash it, and `modtime` is slow
   253  with the `s3`, `swift`, `ftp` and `qinqstor` backends because they
   254  need to do an extra API call to fetch it.
   255  
   256  If you use the `--vfs-fast-fingerprint` flag then rclone will not
   257  include the slow operations in the fingerprint. This makes the
   258  fingerprinting less accurate but much faster and will improve the
   259  opening time of cached files.
   260  
   261  If you are running a vfs cache over `local`, `s3` or `swift` backends
   262  then using this flag is recommended.
   263  
   264  Note that if you change the value of this flag, the fingerprints of
   265  the files in the cache may be invalidated and the files will need to
   266  be downloaded again.
   267  
   268  ## VFS Chunked Reading
   269  
   270  When rclone reads files from a remote it reads them in chunks. This
   271  means that rather than requesting the whole file rclone reads the
   272  chunk specified.  This can reduce the used download quota for some
   273  remotes by requesting only chunks from the remote that are actually
   274  read, at the cost of an increased number of requests.
   275  
   276  These flags control the chunking:
   277  
   278      --vfs-read-chunk-size SizeSuffix        Read the source objects in chunks (default 128M)
   279      --vfs-read-chunk-size-limit SizeSuffix  Max chunk doubling size (default off)
   280  
   281  Rclone will start reading a chunk of size `--vfs-read-chunk-size`,
   282  and then double the size for each read. When `--vfs-read-chunk-size-limit` is
   283  specified, and greater than `--vfs-read-chunk-size`, the chunk size for each
   284  open file will get doubled only until the specified value is reached. If the
   285  value is "off", which is the default, the limit is disabled and the chunk size
   286  will grow indefinitely.
   287  
   288  With `--vfs-read-chunk-size 100M` and `--vfs-read-chunk-size-limit 0`
   289  the following parts will be downloaded: 0-100M, 100M-200M, 200M-300M, 300M-400M and so on.
   290  When `--vfs-read-chunk-size-limit 500M` is specified, the result would be
   291  0-100M, 100M-300M, 300M-700M, 700M-1200M, 1200M-1700M and so on.
   292  
   293  Setting `--vfs-read-chunk-size` to `0` or "off" disables chunked reading.
   294  
   295  ## VFS Performance
   296  
   297  These flags may be used to enable/disable features of the VFS for
   298  performance or other reasons. See also the [chunked reading](#vfs-chunked-reading)
   299  feature.
   300  
   301  In particular S3 and Swift benefit hugely from the `--no-modtime` flag
   302  (or use `--use-server-modtime` for a slightly different effect) as each
   303  read of the modification time takes a transaction.
   304  
   305      --no-checksum     Don't compare checksums on up/download.
   306      --no-modtime      Don't read/write the modification time (can speed things up).
   307      --no-seek         Don't allow seeking in files.
   308      --read-only       Only allow read-only access.
   309  
   310  Sometimes rclone is delivered reads or writes out of order. Rather
   311  than seeking rclone will wait a short time for the in sequence read or
   312  write to come in. These flags only come into effect when not using an
   313  on disk cache file.
   314  
   315      --vfs-read-wait duration   Time to wait for in-sequence read before seeking (default 20ms)
   316      --vfs-write-wait duration  Time to wait for in-sequence write before giving error (default 1s)
   317  
   318  When using VFS write caching (`--vfs-cache-mode` with value writes or full),
   319  the global flag `--transfers` can be set to adjust the number of parallel uploads of
   320  modified files from the cache (the related global flag `--checkers` has no effect on the VFS).
   321  
   322      --transfers int  Number of file transfers to run in parallel (default 4)
   323  
   324  ## VFS Case Sensitivity
   325  
   326  Linux file systems are case-sensitive: two files can differ only
   327  by case, and the exact case must be used when opening a file.
   328  
   329  File systems in modern Windows are case-insensitive but case-preserving:
   330  although existing files can be opened using any case, the exact case used
   331  to create the file is preserved and available for programs to query.
   332  It is not allowed for two files in the same directory to differ only by case.
   333  
   334  Usually file systems on macOS are case-insensitive. It is possible to make macOS
   335  file systems case-sensitive but that is not the default.
   336  
   337  The `--vfs-case-insensitive` VFS flag controls how rclone handles these
   338  two cases. If its value is "false", rclone passes file names to the remote
   339  as-is. If the flag is "true" (or appears without a value on the
   340  command line), rclone may perform a "fixup" as explained below.
   341  
   342  The user may specify a file name to open/delete/rename/etc with a case
   343  different than what is stored on the remote. If an argument refers
   344  to an existing file with exactly the same name, then the case of the existing
   345  file on the disk will be used. However, if a file name with exactly the same
   346  name is not found but a name differing only by case exists, rclone will
   347  transparently fixup the name. This fixup happens only when an existing file
   348  is requested. Case sensitivity of file names created anew by rclone is
   349  controlled by the underlying remote.
   350  
   351  Note that case sensitivity of the operating system running rclone (the target)
   352  may differ from case sensitivity of a file system presented by rclone (the source).
   353  The flag controls whether "fixup" is performed to satisfy the target.
   354  
   355  If the flag is not provided on the command line, then its default value depends
   356  on the operating system where rclone runs: "true" on Windows and macOS, "false"
   357  otherwise. If the flag is provided without a value, then it is "true".
   358  
   359  The `--no-unicode-normalization` flag controls whether a similar "fixup" is
   360  performed for filenames that differ but are [canonically
   361  equivalent](https://en.wikipedia.org/wiki/Unicode_equivalence) with respect to
   362  unicode. Unicode normalization can be particularly helpful for users of macOS,
   363  which prefers form NFD instead of the NFC used by most other platforms. It is
   364  therefore highly recommended to keep the default of `false` on macOS, to avoid
   365  encoding compatibility issues.
   366  
   367  In the (probably unlikely) event that a directory has multiple duplicate
   368  filenames after applying case and unicode normalization, the `--vfs-block-norm-dupes`
   369  flag allows hiding these duplicates. This comes with a performance tradeoff, as
   370  rclone will have to scan the entire directory for duplicates when listing a
   371  directory. For this reason, it is recommended to leave this disabled if not
   372  needed. However, macOS users may wish to consider using it, as otherwise, if a
   373  remote directory contains both NFC and NFD versions of the same filename, an odd
   374  situation will occur: both versions of the file will be visible in the mount,
   375  and both will appear to be editable, however, editing either version will
   376  actually result in only the NFD version getting edited under the hood. `--vfs-block-
   377  norm-dupes` prevents this confusion by detecting this scenario, hiding the
   378  duplicates, and logging an error, similar to how this is handled in `rclone
   379  sync`.
   380  
   381  ## VFS Disk Options
   382  
   383  This flag allows you to manually set the statistics about the filing system.
   384  It can be useful when those statistics cannot be read correctly automatically.
   385  
   386      --vfs-disk-space-total-size    Manually set the total disk space size (example: 256G, default: -1)
   387  
   388  ## Alternate report of used bytes
   389  
   390  Some backends, most notably S3, do not report the amount of bytes used.
   391  If you need this information to be available when running `df` on the
   392  filesystem, then pass the flag `--vfs-used-is-size` to rclone.
   393  With this flag set, instead of relying on the backend to report this
   394  information, rclone will scan the whole remote similar to `rclone size`
   395  and compute the total used space itself.
   396  
   397  _WARNING._ Contrary to `rclone size`, this flag ignores filters so that the
   398  result is accurate. However, this is very inefficient and may cost lots of API
   399  calls resulting in extra charges. Use it as a last resort and only with caching.
   400  
   401  
   402  ```
   403  rclone serve nfs remote:path [flags]
   404  ```
   405  
   406  ## Options
   407  
   408  ```
   409        --addr string                            IPaddress:Port or :Port to bind server to
   410        --dir-cache-time Duration                Time to cache directory entries for (default 5m0s)
   411        --dir-perms FileMode                     Directory permissions (default 0777)
   412        --file-perms FileMode                    File permissions (default 0666)
   413        --gid uint32                             Override the gid field set by the filesystem (not supported on Windows) (default 1000)
   414    -h, --help                                   help for nfs
   415        --nfs-cache-handle-limit int             max file handles cached simultaneously (min 5) (default 1000000)
   416        --no-checksum                            Don't compare checksums on up/download
   417        --no-modtime                             Don't read/write the modification time (can speed things up)
   418        --no-seek                                Don't allow seeking in files
   419        --poll-interval Duration                 Time to wait between polling for changes, must be smaller than dir-cache-time and only on supported remotes (set 0 to disable) (default 1m0s)
   420        --read-only                              Only allow read-only access
   421        --uid uint32                             Override the uid field set by the filesystem (not supported on Windows) (default 1000)
   422        --umask int                              Override the permission bits set by the filesystem (not supported on Windows) (default 2)
   423        --vfs-block-norm-dupes                   If duplicate filenames exist in the same directory (after normalization), log an error and hide the duplicates (may have a performance cost)
   424        --vfs-cache-max-age Duration             Max time since last access of objects in the cache (default 1h0m0s)
   425        --vfs-cache-max-size SizeSuffix          Max total size of objects in the cache (default off)
   426        --vfs-cache-min-free-space SizeSuffix    Target minimum free space on the disk containing the cache (default off)
   427        --vfs-cache-mode CacheMode               Cache mode off|minimal|writes|full (default off)
   428        --vfs-cache-poll-interval Duration       Interval to poll the cache for stale objects (default 1m0s)
   429        --vfs-case-insensitive                   If a file name not found, find a case insensitive match
   430        --vfs-disk-space-total-size SizeSuffix   Specify the total space of disk (default off)
   431        --vfs-fast-fingerprint                   Use fast (less accurate) fingerprints for change detection
   432        --vfs-read-ahead SizeSuffix              Extra read ahead over --buffer-size when using cache-mode full
   433        --vfs-read-chunk-size SizeSuffix         Read the source objects in chunks (default 128Mi)
   434        --vfs-read-chunk-size-limit SizeSuffix   If greater than --vfs-read-chunk-size, double the chunk size after each chunk read, until the limit is reached ('off' is unlimited) (default off)
   435        --vfs-read-wait Duration                 Time to wait for in-sequence read before seeking (default 20ms)
   436        --vfs-refresh                            Refreshes the directory cache recursively in the background on start
   437        --vfs-used-is-size rclone size           Use the rclone size algorithm for Used size
   438        --vfs-write-back Duration                Time to writeback files after last use when using cache (default 5s)
   439        --vfs-write-wait Duration                Time to wait for in-sequence write before giving error (default 1s)
   440  ```
   441  
   442  
   443  ## Filter Options
   444  
   445  Flags for filtering directory listings.
   446  
   447  ```
   448        --delete-excluded                     Delete files on dest excluded from sync
   449        --exclude stringArray                 Exclude files matching pattern
   450        --exclude-from stringArray            Read file exclude patterns from file (use - to read from stdin)
   451        --exclude-if-present stringArray      Exclude directories if filename is present
   452        --files-from stringArray              Read list of source-file names from file (use - to read from stdin)
   453        --files-from-raw stringArray          Read list of source-file names from file without any processing of lines (use - to read from stdin)
   454    -f, --filter stringArray                  Add a file filtering rule
   455        --filter-from stringArray             Read file filtering patterns from a file (use - to read from stdin)
   456        --ignore-case                         Ignore case in filters (case insensitive)
   457        --include stringArray                 Include files matching pattern
   458        --include-from stringArray            Read file include patterns from file (use - to read from stdin)
   459        --max-age Duration                    Only transfer files younger than this in s or suffix ms|s|m|h|d|w|M|y (default off)
   460        --max-depth int                       If set limits the recursion depth to this (default -1)
   461        --max-size SizeSuffix                 Only transfer files smaller than this in KiB or suffix B|K|M|G|T|P (default off)
   462        --metadata-exclude stringArray        Exclude metadatas matching pattern
   463        --metadata-exclude-from stringArray   Read metadata exclude patterns from file (use - to read from stdin)
   464        --metadata-filter stringArray         Add a metadata filtering rule
   465        --metadata-filter-from stringArray    Read metadata filtering patterns from a file (use - to read from stdin)
   466        --metadata-include stringArray        Include metadatas matching pattern
   467        --metadata-include-from stringArray   Read metadata include patterns from file (use - to read from stdin)
   468        --min-age Duration                    Only transfer files older than this in s or suffix ms|s|m|h|d|w|M|y (default off)
   469        --min-size SizeSuffix                 Only transfer files bigger than this in KiB or suffix B|K|M|G|T|P (default off)
   470  ```
   471  
   472  See the [global flags page](/flags/) for global options not listed here.
   473  
   474  # SEE ALSO
   475  
   476  * [rclone serve](/commands/rclone_serve/)	 - Serve a remote over a protocol.
   477