Snapshots defy math and logic. "THEY DON'T MAKE SENSE!"

Why ZFS “snapshots” don’t make sense
A children’s book for dummies, by a dummy :nerd_face: :+1:


“I don’t really understand how snapshots work.”

“Why doesn’t destroying my snapshot free up more space?”

“How come these numbers don’t add up?”

Does this sound like you? Stop thinking about ZFS, pools, datasets, blocks, and snapshots.

You want to demystify snapshots? Think about trucks, boxes, and colored stickers.


What this illustrative walkthrough is not:

:x: It’s not a technical explanation of ZFS, snapshots, or any related technology
:x: It’s not meant to cover all uses and nuances of snapshots
:x: It’s not meant for experienced users or admins of ZFS or TrueNAS

What this illustrative walkthrough is:

:white_check_mark: A way to understand ZFS snapsots from a layperson’s view
:white_check_mark: To help demystify snapshots for users new to ZFS or TrueNAS


You own a truck. It only has so much room for boxes. Twelve boxes is its maximum capacity. You like to use your truck to store things for yourself and for others.

Right from the start, your truck is empty. Say “hello” to your new truck.

As Confucius said in ancient China, “A truck is most useful when it is empty.”

There are some rules about your truck, and how to add, remove, and tag boxes.

Here are the rules:

  • When you add a new box, it has a white sticker on it
  • If you want to remove a box, you must first rip off its white sticker
  • To tag colored stickers on your boxes, they must have existing white stickers
  • When you tag with a color, all boxes with white stickers must be color-tagged
  • You cannot use the same color to create another “color tag set”
  • When you rip off a colored tag, all stickers of this color must be ripped off
  • A box cannot be removed if it has at least one sticker on it
  • Unlike colored stickers, you can rip off the desired number of individual white stickers

Please read these rules again. They are very important. As a new truck owner, you are bound to these rules like the laws of nature.


You decide to add some boxes inside your truck.

Notice how they all come pre-tagged with white stickers?

01-save-some-data-live-filesystem


Let’s get rid of a couple of these boxes! Remember the rules? First rip off their white stickers!

If we slow things down, you can see that there is nothing to “protect” these boxes from removal!

Which means…

02-prep-delete-no-snaps


…they are removed!

Good for you! You just made space for two more boxes by ripping off those two particular white stickers. (Not that you really needed the extra room.)

This concludes the basics of: “If you want to remove boxes, you must first rip off their white stickers. If a box has no more remaining stickers on it? It gets removed!”

03-delete-no-snaps


Let’s go back again to try something else instead. :clock1030:

Here we are again. You have four boxes with white stickers. Nothing was ever removed.

01-save-some-data-live-filesystem


You add several more boxes inside your truck. All come pre-tagged with white stickers, as expected.

The truck isn’t full, but space is getting limited…

05-add-more-new-files


You like the way things are with your white sticker boxes. Just like this. Nothing more, nothing less.

You’re so satisfied with the current inventory of white sticker boxes that you decide to commemorate this occasion by applying a red sticker to all boxes that currently have a white sticker.

It’s at this point you realize that no matter what happens to any of your white stickers, you know exactly what this “beautiful set” of boxes was at this exact point in time, since they all have a red sticker on them.

06-red-snapshot-taken


To test this theory out, you rip off the white stickers from two boxes that aren’t so important.

Lo’ and behold. They are not removed from the truck! Why? Remember the rules? As long as a box has even just one sticker, it cannot be removed.

If you wanted to free up the space of two boxes, that’s too bad. They’re not going anywhere!

This concludes the basics of: “If a box has even a single sticker on it, whether white or colored, it cannot be removed from the truck.”

07-deleting-some-blocks


Let’s go back again to try something else instead. :clock1030:

Here we are again. You have eight boxes. Nothing was ever removed.

06-red-snapshot-taken


You add a few more boxes in your truck.

Notice how these newly added boxes have no red stickers on them?

Unfortunately, you cannot use the same color again if you want to preserve this lovely “set of boxes” that currently have white stickers.

But wait! You know of a brilliant way to commemorate this “lovely set”. You can tag all white sticker boxes with a new color!

How about…

09-some-more-new-blocks


…blue!

Yes, that’ll do.

Every existing white sticker box gets a nice blue sticker! Good thinking!

You don’t have to worry about how the “red sticker set” does not include those three new boxes. You have them protected with your “blue sticker set”.

10-blue-snapshot-taken


Let’s go back again to try something else instead. :clock1030:

Remember how you got to this point? Eleven boxes in total, eight of which have the protection of the “red sticker set”.

Oh dear. Your truck is getting full. You better remove some boxes…

09-some-more-new-blocks


Simple! You’ll just rip off the white stickers from two boxes that really aren’t so important upon reviewing your inventory. That should free up some room to…

Hey, wait a minute! That didn’t remove the boxes? That didn’t free up some extra room?

It’s those stupid red stickers! You could remove the entire “red sticker set”, but you don’t want to lose the protection on all your white sticker boxes.

What to do? What to do? You want to preserve the current state of your white sticker boxes.

Oh, of course, there is a solution…

12-deleting-blocks-red-snap-protection


…blue sticker set to the rescue!

By tagging all existing white sticker boxes, you get to preserve this current set of white sticker boxes.

This means that if you want to free up some space later, you can simply remove the entire red sticker set, while you get to keep a nice blue sticker set for future protection, since you totally like this current white sticker set.

13-blue-snap-taken


In all your excitement, you forgot that the box in the bottom left corner is actually not important.

You rip off the white sticker!

Of course, this box stays in the truck because it still has at least one sticker on it. A blue one. If only you hadn’t rushed things.

14-deleting-blocks-blue-snap-protection


You don’t have time to think. A friend needs you to add a new box to your truck.

Now it’s at full capacity!

But your friend doesn’t stop there…

15-yet-more-blocks-capacity-getting-full


…he wants to protect his box! So he tags all white sticker boxes with a green sticker set!

What is his deal? How is he even your friend?

16-green-snap-taken


You’ve had it. You feel your blood boiling. You go into a mad rage!

You want to remove all boxes from the truck, move to another city, and start over with an empty truck.

You rip off all the white stickers. It’s time to say “bye bye” to all remaining boxes!

What’s this? The truck remains full? Not a single box was removed?

Oh, that’s right. Every box has at least one sticker on it.

17-rage-delete


What if you were to rip off the red sticker set? How much room would free up?

Only two?

18-red-snap-destroyed


Let’s go back again to try something else instead. :clock1030:

17-rage-delete


What if you were to rip off the blue sticker set? How much room would free up?

Only one?

20-blue-snap-destroyed


Let’s go back again to try something else instead. :clock1030:

17-rage-delete


What if you were to rip off the green sticker set? How much room would free up?

Only one?

22-green-snap-destroyed


Let’s go back again to try something else instead. :clock1030:

17-rage-delete


What if you were to rip off the red and green sticker sets? How much room would free up?

Only three?

Well, I guess that makes sense?

24-red-and-green-snaps-destroyed


Let’s go back again to try something else instead. :clock1030:

17-rage-delete


What if you were to rip off the red, blue, and green sticker sets? How much room would free up?

Let’s do the math.

Ripping off the red sticker set would supposedly free up two boxes.

Ripping off the blue sticker set would supposedly free up one box.

Ripping off the green sticker set would supposedly free up one box.

2 + 1 + 1 = 4

Therefor, ripping off the red, blue, and green sticker sets will obviously free up four boxes.

Let’s try it now!

What’s this?! IT FREED UP TWELVE BOXES?

26-all-snaps-destroyed


The end.

If you found this helpful, please “like” this post.

If you ended up even more confused after this, please “like” this post.

If you think this post was pointless, please “like” this post.

If you want to offend me and make me cry, please “like” this post.

18 Likes

Definitely my reason to do it. Seriously, though, this breaks it down about as simply as it can be explained–I think it’ll help a lot of people.

Edit: would you mind if I put this into Fester’s Guide? With attribution, of course.

2 Likes

I am offended. (While crying, too!) :+1:

I had considered providing the relevant zfs commands with each illustration, as well as adding footnotes with “exceptions to the rule”, or overlaying it with the nuance of replications and how “the order of snapshots matters”[1], and explaining the differences between a pool, dataset, and vdev.

But I think that would have worked against new users, since it’s better for them to have their own “aha!” moment.

I wanted this to remain as “dumbed down” and simple as possible.


  1. I intentionally placed the white stickers in the top corner of each box, and kept a consistent left-to-right placement for the colored stickers, which sort of reiterates the order of “old to new”. ↩︎

@dan, You may!

No attribution needed. I’ll leave that up to you. It doesn’t matter to me either way. :+1:

1 Like

Lunacy…Sheer Lunacy…

1 Like

Instea how about a littel addendum that lists the most important commands with an example. (not graphical but fully working command…)

1 Like

This ‘dumbed down’ version could certainly be referenced with other information such as you suggest, without directly tying it to it which might have the potential for confusion simply due to some persons choosing to read every single thing (even when it could go against them and their newness), best to let the new information settle.

1 Like

@tigersharke and @Haldi, agreed and agreed, with a caveat:

Perhaps I can include a hidden “spoiler” at the very end, which injects some examples and explains “nuance”, without getting too cluttered.

This is what I found to be the case with other guides (not just software, but any topic).

In my humble opinion, sometimes it’s better to give only the minimum amount of “understanding”, and allow the new user to explore further on their own.

To use this “dumbed down” picture guide as an example: The new user will immediately realize that snapshots don’t “duplicate” or “copy” data. So right from the start, they’ve already demystified an important fundamental about ZFS snapshots.


EDIT: I’m thinking of adding another picture with a pair of “red tinted” eye glasses. So that when you view the truck wearing these special glasses, you will only see the red sticker boxes. (To demonstrate how a “snapshot” is in fact a complete filesystem.) Then maybe another example with “green tinted” glasses.

Clearly this truck is a flatbed — we didn’t have to move any boxes to remove the deep ones.

(Rumors that a helicopter was involved have not been independently confirmed.)

1 Like

I submitted a PR to the OpenZFS GitHub to switch to trailer trucks, but they insisted that flatbeds are cross-platform compatible.

1 Like