ZFS: Create a Writable Clone of a Filesystem

A ZFS clone is a writable copy of a snapshot of a filesystem. Fortunately, a ZFS clone is much simpler than its definition sounds. While a filesystem snapshot is read-only, a writable version can be created through cloning. Just like snapshots, clones are quick to create and use no additional space when they are created.

To create a clone, you must first create a snapshot. If you already have a snapshot, you can skip the first command in the example below. To create a snapshot and then a clone called “polly” from the filesystem techrx/rex, use these commands:

zfs snapshot techrx/[email protected]
zfs clone techrx/[email protected] techrx/polly

The new filesystem techrx/polly is mounted at /techrx/polly and is a normal ZFS filesystem. (It is just populated with the files of the original filesystem.)

Both clones and snapshots show up in a ‘zfs list’ command:

zfs list
techrx 472M 18.7G 28.5K /techrx
techrx/polly 0 18.7G 12.0M /techrx/polly
techrx/rex 12.0M 18.7G 12.0M /techrx/rex
techrx/[email protected] 0 - 12.0M -

At this point (nothing done with the original or clone filesystems after their creating the snapshot and clone), both the snapshot and clone use no additional disk space. (The USED columns show 0.)


About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.