Table of Contents
A snapshot is a read-only copy of a file system or volume. Snapshots can be created almost instantly, and initially consume no additional disk space within the pool. However, as data within the active dataset changes, the snapshot consumes disk space by continuing to reference the old data and so prevents the space from being freed.
ZFS snapshots include the following features:
Provides persistence across system reboots.
The theoretical maximum number of snapshots is 264.
Uses no separate backing store. Snapshots consume disk space directly from the same storage pool as the file system from which they were created.
Snapshots of volumes cannot be accessed directly, but they can be cloned, backed up, rolled back to, and so on. For information about backing up a ZFS snapshot, see.
Snapshots are created by using the zfs snapshot command, which takes as its only argument the name of the snapshot to create. The snapshot name is specified as follows:
The snapshot name must satisfy the naming conventions defined in.
zfs snapshot tank/home/ahrens@friday
Snapshots have no modifiable properties. Nor can dataset properties be applied to a snapshot.
# zfs set compression=on tank/home/ahrens@tuesday cannot set compression property for 'tank/home/ahrens@tuesday': snapshot properties cannot be modified
Snapshots are destroyed by using the zfs destroy command. For example:
zfs destroy tank/home/ahrens@friday
A dataset cannot be destroyed if snapshots of the dataset exist. For example:
zfs destroy tank/home/ahrenscannot destroy 'tank/home/ahrens': filesystem has children use '-r' to destroy the following datasets: tank/home/ahrens@tuesday tank/home/ahrens@wednesday tank/home/ahrens@thursday
For more information about the destroy subcommand, see .
# zfs rename tank/home/cindys@031306 tank/home/cindys@today
The following snapshot rename operation is not supported because the target pool and file system name are different from the pool and file system where the snapshot was created.
# zfs rename tank/home/cindys@today pool/home/cindys@saturday cannot rename to 'pool/home/cindys@today': snapshots must be part of same dataset
Snapshots of file systems are accessible in the
within the root of the containing file system. For example, if
tank/home/ahrens is mounted on
/home/ahrens, then the
tank/home/ahrens@thursday snapshot data is accessible in the
ls /home/ahrens/.zfs/snapshottuesday wednesday thursday
You can list snapshots as follows:
zfs list -t snapshotNAME USED AVAIL REFER MOUNTPOINT pool/home/anne@monday 0 - 780K - pool/home/bob@monday 0 - 1.01M - tank/home/ahrens@tuesday 8.50K - 780K - tank/home/ahrens@wednesday 8.50K - 1.01M - tank/home/ahrens@thursday 0 - 1.77M - tank/home/cindys@today 8.50K - 524K -
You can list snapshots that were created for a particular file system as follows:
zfs list -r -t snapshot -o name,creation pool/homeNAME CREATION pool/home/anne@monday Mon Mar 13 11:46 2006 pool/home/bob@monday Mon Mar 13 11:46 2006
When a snapshot is created, its space is initially shared between the snapshot and the file system, and possibly with previous snapshots. As the file system changes, space that was previously shared becomes unique to the snapshot, and thus is counted in the snapshot's used property. Additionally, deleting snapshots can increase the amount of space unique to (and thus used by) other snapshots.
The zfs rollback command can be used to discard all changes made since a specific snapshot. The file system reverts to its state at the time the snapshot was taken. By default, the command cannot roll back to a snapshot other than the most recent snapshot.
To roll back to an earlier snapshot, all intermediate snapshots must
be destroyed. You can destroy earlier snapshots by specifying the
If clones of any intermediate snapshots exist, the
must be specified to destroy the clones as well.
The file system that you want to roll back must be unmounted and
remounted, if it is currently mounted. If the file system cannot be unmounted,
the rollback fails. The
f option forces the file system to
be unmounted, if necessary.
zfs rollback tank/home/ahrens@tuesdaycannot rollback to 'tank/home/ahrens@tuesday': more recent snapshots exist use '-r' to force deletion of the following snapshots: tank/home/ahrens@wednesday tank/home/ahrens@thursday #
zfs rollback -r tank/home/ahrens@tuesday
In the above example, the
thursday snapshots are removed because you rolled back to the previous tuesday
zfs list -r -t snapshot -o name,creation tank/home/ahrensNAME CREATION tank/home/ahrens@tuesday Mon Mar 13 11:05 2006