Home / Reference / Copy-on-write & snapshots

Copy-on-write and snapshots: the ONTAP mechanics

ONTAP snapshots are nearly free because of copy-on-write (CoW): a snapshot is a saved root pointer, and blocks are only duplicated when they change after the snapshot exists. This page covers the mechanics, the space accounting (including why deleted files can still consume space), the snapshot reserve, policies and schedules, restore and FlexClone, and the exact commands to manage all of it.

Copy-on-write shared blocks until modification

How CoW makes a snapshot instant

On the WAFL page you saw that every metadata update builds a new tree and flips a root pointer atomically at a consistency point (CP). A snapshot creation uses exactly that machinery:

  1. ONTAP forces a CP so the filesystem is quiescent on disk.
  2. The current root of the volume's WAFL tree is marked as a snapshot and kept alive.
  3. The filesystem continues from a new root.

Nothing is copied. Creation time is a few seconds at most (the CP), regardless of volume size — a 100 TB volume snapshots as fast as a 1 GB one. The space cost shows up only later, when blocks change:

So the real cost of snapshots is a function of your change rate, not your capacity: an overwrite-heavy database volume with long snapshot retention burns far more snapshot space than a static archive volume.

Reading the space: what's snapshot vs live

ONTAP reports snapshot space at both volume and aggregate level:

volume show -vserver vs1 -volume vol1 -fields used,used-percent,snapshot-used,\
  snapshot-reserve,percent-snapshot-space
df -h                                    # from a node shell: capacity + snapshot reserve
volume snapshot show -vserver vs1 -volume vol1   # list snapshots + size

Two concepts that trip people up:

Common surprise: you delete 2 TB of files, and df barely moves. Check volume snapshot show — snapshots are holding the old blocks. This is the number-one "where did my space go" investigation on real systems, and the fix is usually retention policy, not a panic.

Policies and schedules

Snapshots are driven by snapshot policies — named sets of schedules + retention counts that you attach to volumes:

snapshot policy create -vserver vs1 -policy prod_backup \
  -schedule hourly -count 12 -schedule daily -count 7 -schedule weekly -count 4
snapshot policy show -vserver vs1 -policy prod_backup
volume modify -vserver vs1 -volume vol1 -snapshot-policy prod_backup \
  -percent-snapshot-space 10

Notes from the field:

Autodelete: the safety net

When snapshots push the volume against its space limits, ONTAP can delete them automatically — if you've enabled it and set the commitment level:

volume snapshot autodelete show -vserver vs1 -volume vol1
volume snapshot autodelete modify -vserver vs1 -volume vol1 \
  -enabled on -commitment try -delete-order oldest_first -trigger volume

Key parameters:

Autodelete is a last-line defense, not a retention strategy — if it's firing regularly, your policy or reserve is wrong.

Restore: file-level and volume-level

Restores come in three flavors:

# 1. Client-visible: browse the ~snapshot directory (NAS) and copy files back
#    (e.g. \\server\share\~snapshot\hourly.0\... or /vol/.snapshot/hourly.0/...)

# 2. File-level restore via CLI
volume snapshot restore-file -vserver vs1 -volume vol1 -snapshot snap1 \
  -path /dir/file.txt -restore-path /dir/file.txt.restored

# 3. Volume-level rollback (destructive: volume is rolled back to the snapshot)
volume snapshot restore -vserver vs1 -volume vol1 -snapshot snap1

For "restore that file from 3 hours ago," the ~snapshot directory or snapshot restore-file is the answer 95% of the time. Volume restore is for disasters.

FlexClone: CoW's productivity trick

FlexClone is the same CoW machinery pointed at a snapshot: a clone volume shares all its blocks with the parent snapshot and only copies blocks it writes to afterward:

volume snapshot create -vserver vs1 -volume vol1 -snapshot pre_patch
volume clone create -vserver vs1 -flexclone vol1_patch_test -type flexclone \
  -parent-volume vol1 -parent-snapshot pre_patch
volume clone split start -vserver vs1 -flexclone vol1_patch_test   # optional full split

Practical uses: instant test/dev copies of production volumes, patch-test environments, per-branch database clones, and safe pre-change baselines. The clone consumes only changed blocks until you run volume clone split, which physically copies everything (that's the expensive, hours-long operation — avoid it unless you truly need independence).

Snapshots and the bigger picture

Command quick reference

TaskCommand
Create a snapshotvolume snapshot create -vserver vs1 -volume vol1 -snapshot snap1
List snapshots + sizevolume snapshot show -vserver vs1 -volume vol1
Delete a snapshotvolume snapshot delete -vserver vs1 -volume vol1 -snapshot snap1
Set the policy + reservevolume modify -vserver vs1 -volume vol1 -snapshot-policy prod -percent-snapshot-space 10
Restore one filevolume snapshot restore-file -vserver vs1 -volume vol1 -snapshot snap1 -path /d/f -restore-path /d/f.new
Roll back a volumevolume snapshot restore -vserver vs1 -volume vol1 -snapshot snap1
Clone from a snapshotvolume clone create -vserver vs1 -flexclone cl1 -type flexclone -parent-volume vol1 -parent-snapshot snap1
Autodelete safety netvolume snapshot autodelete modify -vserver vs1 -volume vol1 -enabled on -commitment try

This closes the "How ONTAP actually works" series — start again at WAFL or continue with the FlexGroup deep-dive for the scale-out angle.