Why ZFS “snapshots” don’t make sense
A children’s book for dummies, by a dummy
“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:
It’s not a technical explanation of ZFS, snapshots, or any related technology
It’s not meant to cover all uses and nuances of snapshots
It’s not meant for experienced users or admins of ZFS or TrueNAS
What this illustrative walkthrough is:
A way to understand ZFS snapsots from a layperson’s view
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?
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…
…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!”
Let’s go back again to try something else instead.
Here we are again. You have four boxes with white stickers. Nothing was ever removed.
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…
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.
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.”
Let’s go back again to try something else instead.
Here we are again. You have eight boxes. Nothing was ever removed.
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…
…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”.
Let’s go back again to try something else instead.
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…
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…
…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.
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.
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…
…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?
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.
What if you were to rip off the red sticker set? How much room would free up?
Only two?
Let’s go back again to try something else instead.
What if you were to rip off the blue sticker set? How much room would free up?
Only one?
Let’s go back again to try something else instead.
What if you were to rip off the green sticker set? How much room would free up?
Only one?
Let’s go back again to try something else instead.
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?
Let’s go back again to try something else instead.
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?
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.