Linux 101 : The ZFS filesystem - C.O.W system, Snapshots and clones.



COW (Copy-On-Write):




Filesystems store files as blocks on the disk. 

To avoid that the data blocks get corrupted during the writing process in case of a power failure for example, rendering a block of data unusable, the COW system never overwrites data. 

When we write to a block of data, COW makes a copy of that block leaving the original "safe", it then writes all the new data on the "copy block". 

When the writing finishes, the original block could be flagged as "free" to be reused by the system.

ZFS creates snapshots (see below) pointing to blocks that contain old versions of a file.


Datasets:


A dataset refers to any place where ZFS data is stored (filesystem, snapshots, clones,..).


ZFS Pools:


ZFS organizes its storage in pools not on the storage devices(drives,..). A ZFS storage pool, is a logical representation of the physical storage devices below.


Vdevs:


A virtual device (VDEV) is a aggregation of physical storage devices.




Snapshots:





A snapshot is a copy of data at a certain moment.

Snapshots are read-only. We could use them for example to have a copy of a boot environment before making changes to it to test a new feature.


The two snapshots (Snapshot1 and Snapshot2) both point to the shared data blocks to save space.




Creating a snapshot:







/filesystem/path : path to the snapshot location.



View all your snapshots:


With the -t snapshot (type of dataset : Snapshot)argument to zfs list.







Clones:

Snapshots are read-only, clones are a "read-write" version snapshot.

Clones could be used for example to test new environments since they allow "writes" as well as "reads".





Comments

Leave as a comment:

Archive