Destroy a range of ZFS snapshots with a single command

When you have a number of old ZFS snapshots to destroy, it can be useful to see if you can delete a complete range.

A range of snapshots can be destroyed with a single command.

This is what the man page says:

An inclusive range of snapshots may be specified by separating the first and last snapshots with a percent sign. The first and/or last snapshots may be left blank, in which case the filesystem's oldest or newest snapshot will be implied.

This requires some careful reading.

When omitting the begin or end of the range, it comes down to this:

  • zfs destroy zroot/path/to/set@%snap will destroy all snapshots from the oldest to and including zroot/path/to/set@snap
  • zfs destroy zroot/path/to/set@snap% will destroy all snapshots starting from zroot/path/to/set@snap to and including the newest

Destroy old snapshosts

When you want to destroy all older snapshots of a data set and only keep the newer ones, just pick the newest snapshot you don't want to keep,
say zroot/path/to/set@2026-09-01.

Now add a percent sign before the snapname (the part after the @): zroot/path/to/set@%2026-09-01

This will destroy all the snapshots older than this one and also this one.

Check before destroying

Be careful, and first check that your command does indeed what you want.

For this, use the -n and -v flags:

zfs destroy -nv zroot/path/to/set@%2026-09-01

zfs will report what snapshots will be destroyed if you omit the -n flag.

Better safe than sorry!

Tags:

Share this page via XMPP

⇽ Books and some interesting stuff I read in August 2026 Books and some interesting stuff I read in September 2026 ⇾


Webrings

netizen-ring-button

<<- random ->>


100% made with ♥ by a human — no cookies, no trackers.
Proud member of the 250kb.club, the no-JS.club, the Blogroll.Club, and the Bukmark.Club.
Don’t let a billionaire’s algorithm control what you read — use an RSS feed reader.