Sun Solaris 10 : Creating snapshots with ZFS

ZFS is a great filesystem. Amongst its many features, it has snapshots. Let’s see how to use them.

What are snapshots ?

Snapshots are instant copies of your filesystem at a fixed past time. They are designed so that they are lightning fast to create, and they use a minimal amount of disk thanks to the COW (Copy On Write) optimization.

Basically, when you take a snapshot of a ZFS filesystem, only the filesystem structure is copied, not the file data blocks. Afterwards, anytime the data of a file is going to be modified, the data block is copied first the snapshot will reference the copy instead of the current data block. This is the Copy-On-Write.

The volume occupied by the snapshot is merely the volume of the data blocks which have been modified since the snapshot was taken.

Snapshots in ZFS

To create a snapshot, issue the following command :
prodigy# zfs snapshot poolName/fileSystem@labelName

You can see that the snapshot was taken with zfs list :
prodigy# zfs list
poolName 5.63G 141G 27.5K /poolName
poolName/fileSystem 2.97G 141G 1.92G /poolName/fileSystem
poolName/fileSystem@label 0 - 1.92G -

To access the files of the snapshot, you can simply go in the .zfs/snapshot directory which is at the top level of your fileSystem. Take care, the .zfs directory is invisible by default.

At last, to delete the snapshot, simply use the zfs destroy command :
prodigy# zfs destroy poolName/fileSystem@label

2 thoughts on “Sun Solaris 10 : Creating snapshots with ZFS”

Leave a Reply

Your email address will not be published. Required fields are marked *