github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/vfs/vfs.md (about)

     1  ### VFS - Virtual File System
     2  
     3  This command uses the VFS layer. This adapts the cloud storage objects
     4  that rclone uses into something which looks much more like a disk
     5  filing system.
     6  
     7  Cloud storage objects have lots of properties which aren't like disk
     8  files - you can't extend them or write to the middle of them, so the
     9  VFS layer has to deal with that. Because there is no one right way of
    10  doing this there are various options explained below.
    11  
    12  The VFS layer also implements a directory cache - this caches info
    13  about files and directories (but not the data) in memory.
    14  
    15  ### VFS Directory Cache
    16  
    17  Using the `--dir-cache-time` flag, you can control how long a
    18  directory should be considered up to date and not refreshed from the
    19  backend. Changes made through the VFS will appear immediately or
    20  invalidate the cache.
    21  
    22      --dir-cache-time duration   Time to cache directory entries for (default 5m0s)
    23      --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)
    24  
    25  However, changes made directly on the cloud storage by the web
    26  interface or a different copy of rclone will only be picked up once
    27  the directory cache expires if the backend configured does not support
    28  polling for changes. If the backend supports polling, changes will be
    29  picked up within the polling interval.
    30  
    31  You can send a `SIGHUP` signal to rclone for it to flush all
    32  directory caches, regardless of how old they are.  Assuming only one
    33  rclone instance is running, you can reset the cache like this:
    34  
    35      kill -SIGHUP $(pidof rclone)
    36  
    37  If you configure rclone with a [remote control](/rc) then you can use
    38  rclone rc to flush the whole directory cache:
    39  
    40      rclone rc vfs/forget
    41  
    42  Or individual files or directories:
    43  
    44      rclone rc vfs/forget file=path/to/file dir=path/to/dir
    45  
    46  ### VFS File Buffering
    47  
    48  The `--buffer-size` flag determines the amount of memory,
    49  that will be used to buffer data in advance.
    50  
    51  Each open file will try to keep the specified amount of data in memory
    52  at all times. The buffered data is bound to one open file and won't be
    53  shared.
    54  
    55  This flag is a upper limit for the used memory per open file.  The
    56  buffer will only use memory for data that is downloaded but not not
    57  yet read. If the buffer is empty, only a small amount of memory will
    58  be used.
    59  
    60  The maximum memory used by rclone for buffering can be up to
    61  `--buffer-size * open files`.
    62  
    63  ### VFS File Caching
    64  
    65  These flags control the VFS file caching options. File caching is
    66  necessary to make the VFS layer appear compatible with a normal file
    67  system. It can be disabled at the cost of some compatibility.
    68  
    69  For example you'll need to enable VFS caching if you want to read and
    70  write simultaneously to a file.  See below for more details.
    71  
    72  Note that the VFS cache is separate from the cache backend and you may
    73  find that you need one or the other or both.
    74  
    75      --cache-dir string                     Directory rclone will use for caching.
    76      --vfs-cache-mode CacheMode             Cache mode off|minimal|writes|full (default off)
    77      --vfs-cache-max-age duration           Max time since last access of objects in the cache (default 1h0m0s)
    78      --vfs-cache-max-size SizeSuffix        Max total size of objects in the cache (default off)
    79      --vfs-cache-min-free-space SizeSuffix  Target minimum free space on the disk containing the cache (default off)
    80      --vfs-cache-poll-interval duration     Interval to poll the cache for stale objects (default 1m0s)
    81      --vfs-write-back duration              Time to writeback files after last use when using cache (default 5s)
    82  
    83  If run with `-vv` rclone will print the location of the file cache.  The
    84  files are stored in the user cache file area which is OS dependent but
    85  can be controlled with `--cache-dir` or setting the appropriate
    86  environment variable.
    87  
    88  The cache has 4 different modes selected by `--vfs-cache-mode`.
    89  The higher the cache mode the more compatible rclone becomes at the
    90  cost of using disk space.
    91  
    92  Note that files are written back to the remote only when they are
    93  closed and if they haven't been accessed for `--vfs-write-back`
    94  seconds. If rclone is quit or dies with files that haven't been
    95  uploaded, these will be uploaded next time rclone is run with the same
    96  flags.
    97  
    98  If using `--vfs-cache-max-size` or `--vfs-cache-min-free-size` note
    99  that the cache may exceed these quotas for two reasons. Firstly
   100  because it is only checked every `--vfs-cache-poll-interval`. Secondly
   101  because open files cannot be evicted from the cache. When
   102  `--vfs-cache-max-size` or `--vfs-cache-min-free-size` is exceeded,
   103  rclone will attempt to evict the least accessed files from the cache
   104  first. rclone will start with files that haven't been accessed for the
   105  longest. This cache flushing strategy is efficient and more relevant
   106  files are likely to remain cached.
   107  
   108  The `--vfs-cache-max-age` will evict files from the cache
   109  after the set time since last access has passed. The default value of
   110  1 hour will start evicting files from cache that haven't been accessed
   111  for 1 hour. When a cached file is accessed the 1 hour timer is reset to 0
   112  and will wait for 1 more hour before evicting. Specify the time with
   113  standard notation, s, m, h, d, w .
   114  
   115  You **should not** run two copies of rclone using the same VFS cache
   116  with the same or overlapping remotes if using `--vfs-cache-mode > off`.
   117  This can potentially cause data corruption if you do. You can work
   118  around this by giving each rclone its own cache hierarchy with
   119  `--cache-dir`. You don't need to worry about this if the remotes in
   120  use don't overlap.
   121  
   122  #### --vfs-cache-mode off
   123  
   124  In this mode (the default) the cache will read directly from the remote and write
   125  directly to the remote without caching anything on disk.
   126  
   127  This will mean some operations are not possible
   128  
   129    * Files can't be opened for both read AND write
   130    * Files opened for write can't be seeked
   131    * Existing files opened for write must have O_TRUNC set
   132    * Files open for read with O_TRUNC will be opened write only
   133    * Files open for write only will behave as if O_TRUNC was supplied
   134    * Open modes O_APPEND, O_TRUNC are ignored
   135    * If an upload fails it can't be retried
   136  
   137  #### --vfs-cache-mode minimal
   138  
   139  This is very similar to "off" except that files opened for read AND
   140  write will be buffered to disk.  This means that files opened for
   141  write will be a lot more compatible, but uses the minimal disk space.
   142  
   143  These operations are not possible
   144  
   145    * Files opened for write only can't be seeked
   146    * Existing files opened for write must have O_TRUNC set
   147    * Files opened for write only will ignore O_APPEND, O_TRUNC
   148    * If an upload fails it can't be retried
   149  
   150  #### --vfs-cache-mode writes
   151  
   152  In this mode files opened for read only are still read directly from
   153  the remote, write only and read/write files are buffered to disk
   154  first.
   155  
   156  This mode should support all normal file system operations.
   157  
   158  If an upload fails it will be retried at exponentially increasing
   159  intervals up to 1 minute.
   160  
   161  #### --vfs-cache-mode full
   162  
   163  In this mode all reads and writes are buffered to and from disk. When
   164  data is read from the remote this is buffered to disk as well.
   165  
   166  In this mode the files in the cache will be sparse files and rclone
   167  will keep track of which bits of the files it has downloaded.
   168  
   169  So if an application only reads the starts of each file, then rclone
   170  will only buffer the start of the file. These files will appear to be
   171  their full size in the cache, but they will be sparse files with only
   172  the data that has been downloaded present in them.
   173  
   174  This mode should support all normal file system operations and is
   175  otherwise identical to `--vfs-cache-mode` writes.
   176  
   177  When reading a file rclone will read `--buffer-size` plus
   178  `--vfs-read-ahead` bytes ahead.  The `--buffer-size` is buffered in memory
   179  whereas the `--vfs-read-ahead` is buffered on disk.
   180  
   181  When using this mode it is recommended that `--buffer-size` is not set
   182  too large and `--vfs-read-ahead` is set large if required.
   183  
   184  **IMPORTANT** not all file systems support sparse files. In particular
   185  FAT/exFAT do not. Rclone will perform very badly if the cache
   186  directory is on a filesystem which doesn't support sparse files and it
   187  will log an ERROR message if one is detected.
   188  
   189  #### Fingerprinting
   190  
   191  Various parts of the VFS use fingerprinting to see if a local file
   192  copy has changed relative to a remote file. Fingerprints are made
   193  from:
   194  
   195  - size
   196  - modification time
   197  - hash
   198  
   199  where available on an object.
   200  
   201  On some backends some of these attributes are slow to read (they take
   202  an extra API call per object, or extra work per object).
   203  
   204  For example `hash` is slow with the `local` and `sftp` backends as
   205  they have to read the entire file and hash it, and `modtime` is slow
   206  with the `s3`, `swift`, `ftp` and `qinqstor` backends because they
   207  need to do an extra API call to fetch it.
   208  
   209  If you use the `--vfs-fast-fingerprint` flag then rclone will not
   210  include the slow operations in the fingerprint. This makes the
   211  fingerprinting less accurate but much faster and will improve the
   212  opening time of cached files.
   213  
   214  If you are running a vfs cache over `local`, `s3` or `swift` backends
   215  then using this flag is recommended.
   216  
   217  Note that if you change the value of this flag, the fingerprints of
   218  the files in the cache may be invalidated and the files will need to
   219  be downloaded again.
   220  
   221  ### VFS Chunked Reading
   222  
   223  When rclone reads files from a remote it reads them in chunks. This
   224  means that rather than requesting the whole file rclone reads the
   225  chunk specified.  This can reduce the used download quota for some
   226  remotes by requesting only chunks from the remote that are actually
   227  read, at the cost of an increased number of requests.
   228  
   229  These flags control the chunking:
   230  
   231      --vfs-read-chunk-size SizeSuffix        Read the source objects in chunks (default 128M)
   232      --vfs-read-chunk-size-limit SizeSuffix  Max chunk doubling size (default off)
   233  
   234  Rclone will start reading a chunk of size `--vfs-read-chunk-size`,
   235  and then double the size for each read. When `--vfs-read-chunk-size-limit` is
   236  specified, and greater than `--vfs-read-chunk-size`, the chunk size for each
   237  open file will get doubled only until the specified value is reached. If the
   238  value is "off", which is the default, the limit is disabled and the chunk size
   239  will grow indefinitely.
   240  
   241  With `--vfs-read-chunk-size 100M` and `--vfs-read-chunk-size-limit 0`
   242  the following parts will be downloaded: 0-100M, 100M-200M, 200M-300M, 300M-400M and so on.
   243  When `--vfs-read-chunk-size-limit 500M` is specified, the result would be
   244  0-100M, 100M-300M, 300M-700M, 700M-1200M, 1200M-1700M and so on.
   245  
   246  Setting `--vfs-read-chunk-size` to `0` or "off" disables chunked reading.
   247  
   248  ### VFS Performance
   249  
   250  These flags may be used to enable/disable features of the VFS for
   251  performance or other reasons. See also the [chunked reading](#vfs-chunked-reading)
   252  feature.
   253  
   254  In particular S3 and Swift benefit hugely from the `--no-modtime` flag
   255  (or use `--use-server-modtime` for a slightly different effect) as each
   256  read of the modification time takes a transaction.
   257  
   258      --no-checksum     Don't compare checksums on up/download.
   259      --no-modtime      Don't read/write the modification time (can speed things up).
   260      --no-seek         Don't allow seeking in files.
   261      --read-only       Only allow read-only access.
   262  
   263  Sometimes rclone is delivered reads or writes out of order. Rather
   264  than seeking rclone will wait a short time for the in sequence read or
   265  write to come in. These flags only come into effect when not using an
   266  on disk cache file.
   267  
   268      --vfs-read-wait duration   Time to wait for in-sequence read before seeking (default 20ms)
   269      --vfs-write-wait duration  Time to wait for in-sequence write before giving error (default 1s)
   270  
   271  When using VFS write caching (`--vfs-cache-mode` with value writes or full),
   272  the global flag `--transfers` can be set to adjust the number of parallel uploads of
   273  modified files from the cache (the related global flag `--checkers` has no effect on the VFS).
   274  
   275      --transfers int  Number of file transfers to run in parallel (default 4)
   276  
   277  ### VFS Case Sensitivity
   278  
   279  Linux file systems are case-sensitive: two files can differ only
   280  by case, and the exact case must be used when opening a file.
   281  
   282  File systems in modern Windows are case-insensitive but case-preserving:
   283  although existing files can be opened using any case, the exact case used
   284  to create the file is preserved and available for programs to query.
   285  It is not allowed for two files in the same directory to differ only by case.
   286  
   287  Usually file systems on macOS are case-insensitive. It is possible to make macOS
   288  file systems case-sensitive but that is not the default.
   289  
   290  The `--vfs-case-insensitive` VFS flag controls how rclone handles these
   291  two cases. If its value is "false", rclone passes file names to the remote
   292  as-is. If the flag is "true" (or appears without a value on the
   293  command line), rclone may perform a "fixup" as explained below.
   294  
   295  The user may specify a file name to open/delete/rename/etc with a case
   296  different than what is stored on the remote. If an argument refers
   297  to an existing file with exactly the same name, then the case of the existing
   298  file on the disk will be used. However, if a file name with exactly the same
   299  name is not found but a name differing only by case exists, rclone will
   300  transparently fixup the name. This fixup happens only when an existing file
   301  is requested. Case sensitivity of file names created anew by rclone is
   302  controlled by the underlying remote.
   303  
   304  Note that case sensitivity of the operating system running rclone (the target)
   305  may differ from case sensitivity of a file system presented by rclone (the source).
   306  The flag controls whether "fixup" is performed to satisfy the target.
   307  
   308  If the flag is not provided on the command line, then its default value depends
   309  on the operating system where rclone runs: "true" on Windows and macOS, "false"
   310  otherwise. If the flag is provided without a value, then it is "true".
   311  
   312  The `--no-unicode-normalization` flag controls whether a similar "fixup" is
   313  performed for filenames that differ but are [canonically
   314  equivalent](https://en.wikipedia.org/wiki/Unicode_equivalence) with respect to
   315  unicode. Unicode normalization can be particularly helpful for users of macOS,
   316  which prefers form NFD instead of the NFC used by most other platforms. It is
   317  therefore highly recommended to keep the default of `false` on macOS, to avoid
   318  encoding compatibility issues.
   319  
   320  In the (probably unlikely) event that a directory has multiple duplicate
   321  filenames after applying case and unicode normalization, the `--vfs-block-norm-dupes`
   322  flag allows hiding these duplicates. This comes with a performance tradeoff, as
   323  rclone will have to scan the entire directory for duplicates when listing a
   324  directory. For this reason, it is recommended to leave this disabled if not
   325  needed. However, macOS users may wish to consider using it, as otherwise, if a
   326  remote directory contains both NFC and NFD versions of the same filename, an odd
   327  situation will occur: both versions of the file will be visible in the mount,
   328  and both will appear to be editable, however, editing either version will
   329  actually result in only the NFD version getting edited under the hood. `--vfs-block-
   330  norm-dupes` prevents this confusion by detecting this scenario, hiding the
   331  duplicates, and logging an error, similar to how this is handled in `rclone
   332  sync`.
   333  
   334  ### VFS Disk Options
   335  
   336  This flag allows you to manually set the statistics about the filing system.
   337  It can be useful when those statistics cannot be read correctly automatically.
   338  
   339      --vfs-disk-space-total-size    Manually set the total disk space size (example: 256G, default: -1)
   340  
   341  ### Alternate report of used bytes
   342  
   343  Some backends, most notably S3, do not report the amount of bytes used.
   344  If you need this information to be available when running `df` on the
   345  filesystem, then pass the flag `--vfs-used-is-size` to rclone.
   346  With this flag set, instead of relying on the backend to report this
   347  information, rclone will scan the whole remote similar to `rclone size`
   348  and compute the total used space itself.
   349  
   350  _WARNING._ Contrary to `rclone size`, this flag ignores filters so that the
   351  result is accurate. However, this is very inefficient and may cost lots of API
   352  calls resulting in extra charges. Use it as a last resort and only with caching.