Replacing a ZFS File System With a ZFS Clone

To replace an active ZFS file system with a clone of that file system, use the zfs promote command. This feature enables you to clone and replace file systems so that the original file system becomes the clone of the specified file system. In addition, you can destroy the file system from which the clone was originally created. Without clone promotion, you cannot destroy an original file system of active clones. For more information, see Destroying a ZFS Clone.

In the following example, the system1/test/productA file system is cloned and then the clone file system, system1/test/productAbeta, becomes the original system1/test/productA file system.

$ zfs create system1/test
$ zfs create system1/test/productA
$ zfs snapshot system1/test/productA@today
$ zfs clone system1/test/productA@today system1/test/productAbeta
$ zfs list -r system1/test
NAME                          USED  AVAIL  REFER  MOUNTPOINT
system1/test                  104M  66.2G    23K  /system1/test
system1/test/productA         104M  66.2G   104M  /system1/test/productA
system1/test/productA@today      0      -   104M  -
system1/test/productAbeta        0  66.2G   104M  /system1/test/productAbeta
$ zfs promote system1/test/productAbeta
$ zfs list -r system1/test
NAME                              USED  AVAIL  REFER  MOUNTPOINT
system1/test                      104M  66.2G    24K  /system1/test
system1/test/productA                0  66.2G   104M  /system1/test/productA
system1/test/productAbeta         104M  66.2G   104M  /system1/test/productAbeta
system1/test/productAbeta@today      0      -   104M  -

In this zfs list output, note that the disk space accounting information for the original productA file system has been replaced with the productAbeta file system.

You can complete the clone replacement process by renaming the file systems. For example:

$ zfs rename system1/test/productA system1/test/productAlegacy
$ zfs rename system1/test/productAbeta system1/test/productA
$ zfs list -r system1/test

Optionally, you can remove the legacy file system. For example:

$ zfs destroy system1/test/productAlegacy