HomeSolarisSolaris system administrationZFS: Create a Snapshot of a Filesystem

ZFS: Create a Snapshot of a Filesystem

Of the many cool features of the new ZFS filesystems, one of the coolest is taking snapshots of a live filesystem. This provides a read-only, point-in-time copy of the whole filesystem. While this sounds slow and expensive in disk usage, ZFS makes snapshots efficient in time and space.

To create a snapshot of my home directory in techrx/home/qmchenry with the name of today’s date (060614), I used the following command:

zfs shapshot techrx/home/[email protected]

Each snapshot has a name (which is useful since you could theoretically create 2^64 or more than 18 billion billion snapshots in each pool) and is referenced as [email protected]

Snapshots show up in a normal zfs list just as filesystems do:

zfs list
techrx 360M 18.8G 25.5K /techrx
techrx/home 360M 18.8G 25.5K /techrx/home
techrx/home/qmchenry 360M 18.8G 360M /techrx/home/qmchenry
.../[email protected] 0 - 360M -

At this point, the snapshot uses zero bytes of additional space as shown in the USED column (although there is some minor overhead in the pool). The REFER column shows the same size as the USED size of the original filesystem at the time of the snapshot. Note that there is no mount point for the filesystem. Snapshots are purposefully not intended to be accessed like a filesystem. To do that, you just need to clone the snapshot (which is another tech-recipe).

The reason that snapshots add no overhead in CPU load is because of the way that ZFS writes changes in data to the disk. ZFS writes its data in units called blocks (which are dynamically sized up to 128KB). When the data in an existing block is changed, ZFS writes the data to a new block on disk before it releases the old block. However, when a shapshot exists for the filesystem, the old block is not released. Instead, it remains as part of the snapshot. Therefore, the only increases in disk space used for snapshots are in keeping around old blocks.

Quinn McHenry
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.



Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments

Cleveland Furia on How to Clear Google Activity
Sid Wohlfarth on How to Clear Google Activity
Riley Magsayo on How to Clear Google Activity
สมัครรับเครดิตฟรี ทันที on How to improve Remote Desktop Protocol Performance
Neal Wangstad on How to Clear Google Activity
Slavcho Andov on How to install Ubuntu
Slavcho Andov on How to fix bad sectors
Sheraz Ali on How to Backup Android