Creating file clones

File clones can be created from a regular file or a file in a snapshot using the mmclone command.

Creating a file clone from a regular file is a two-step process using the mmclone command with the snap and copy keywords:
  1. Issue the mmclone snap command to create a read-only snapshot of the file to be cloned. This read-only snapshot becomes known as the clone parent. For example, the following command creates a clone parent called snap1 from the original file file1:
    mmclone snap file1 snap1
    Alternately, if only one file is specified with the mmclone snap command, it will convert the file to a read-only clone parent without creating a separate clone parent file. When using this method to create a clone parent, the specified file cannot be open for writing or have hard links. For example, the following command converts file1 into a clone parent.
    mmclone snap file1
  2. Issue the mmclone copy command to create a writable clone from a clone parent. For example, the following command creates a writable file clone called file2 from the clone parent snap1:
    mmclone copy snap1 file2
Creating a file clone where the source is in a snapshot only requires one step using the mmclone command with the copy keyword. For example, the following command creates a writable file clone called file3.clone from a file called file3 in a snapshot called snap2:
mmclone copy /fs1/.snapshots/snap2/file3 file3.clone
In this case, file3 becomes the clone parent.
Note: Extended attributes of clone parents are not passed along to file clones.

After a clone has been created, the clone and the file that it was cloned from are interchangeable, which is similar to a regular copy (cp) command. The file clone will have a new inode number and attributes that can be modified independently of the original file.

Additional clones can be created from the same clone parent by issuing additional mmclone copy commands, for example:
mmclone copy snap1 file3
File clones of clones can also be created, as shown in the following example:
mmclone snap file1 snap1
mmclone copy snap1 file2
echo hello >> file2
mmclone snap file2 snap2
mmclone copy snap2 file3
The echo command updates the last block of file clone file2. When file2 is snapped to snap2, the mmclone snap operation is performed as described previously. When a block in file3 is read, the clone parent inode is found first. For the case of the last block, with the hello text, the disk address will be found in snap2. However, for other blocks, the disk address will be found in snap1.

For complete usage information, see mmclone command .