Clone Files or Directories
This command makes a 1:1 clone of your data by creating a mere metadata copy, without duplicating any new data in the object storage. Thus cloning is very fast, regardless of target file/directory size. In JuiceFS, this command is a better alternative to cp
. Moreover, for Linux clients using kernels with copy_file_range
support, the cp
command achieves the same result as juicefs clone
.
The clone result is a metadata copy only, where all the files still reference the same underlying object storage blocks. That is why a clone behaves the same in every way as its originals. When either of them go through actual file data modification, the affected data blocks are copied on write and become new blocks after write, while the unchanged part of the files remains the same, still referencing the original blocks.
Please note that system tools like disk-free (df
) or disk-usage (du
) report space usage for the cloned data, but the underlying object storage space does not grow as blocks remain the same. In the same way, as metadata is actually replicated, the clone takes the same metadata engine storage space as the original.
Clones take up both file system storage space (including inodes) and metadata engine storage space. Pay special attention when making clones on large-size directories.
juicefs clone SRC DST
# Clone a file
juicefs clone /mnt/jfs/file1 /mnt/jfs/file2
# Clone a directory
juicefs clone /mnt/jfs/dir1 /mnt/jfs/dir2