5

How much space do snapshots use in ZFS?

I created a pool and want to create a volume. I don't know how much space snapshots will occupy. Is there any way or formula exist to compute space requirements for snapshots?

MadMike
  • 4,234
  • 8
  • 28
  • 50
saeed
  • 51
  • 1
  • 2

3 Answers3

4

The actual meta-data of snapshots are negligible.

As a copy-on-write file system, ZFS snapshots only require space for modified data; creating a snapshot does not immediately duplicate everything. If you have a snapshot of given size, and then add or modify files summing up to 100GB, the snapshot will "cost" you 100GB.

It might even be a little bit smaller because of compression and deduplication.

Jens Erat
  • 4,993
  • 7
  • 31
  • 37
  • Good point about compression/deduplication. Note that the snapshot might be anything between much smaller and much larger in that case, not only a little bit smaller. – jlliagre Mar 18 '15 at 08:33
  • For compression, there might be a _slight_ overhead on already compressed data, yes. I don't think it should grow beyond the amount of data changed because of deduplication, or am I missing something here? Ignoring any file system overhead, but this would have existed anyway. – Jens Erat Mar 18 '15 at 08:36
  • You are right, the snapshot size cannot (significantly) exceed the zvol size, here 100GB. I was thinking in term of comparing the parent dataset used size and the snapshot used size. A 100GB zvol can use much less than 100GB and then be smaller than its snapshot if the latter is less compressed. Measuring the size used by deduplicated data is even more confusing as it exists only in one dataset but might be referred to by several ones. – jlliagre Mar 18 '15 at 09:28
1

Prior to emperically testing this, I also believed what other answers said, namely that ZFS snapshots only consume disk space when blocks change, and snapshots taken where no blocks change at all consume no space (or only a very small amount of metadata for the snapshot name and an empty lst of changed blocks)

To my surprise when I tested this recently I discovered that the space usage was much larger than I expected: while still small, it was between 1.8 - 4 MiB per snapshot, which was significantly larger than I would have expected. (My guess would have been less than 1 KiB, so this result was over 4000x larger than I expected). See my Server Fault question for the details, but essentially I created a totally empty 200GiB zpool and was able to fill it up with 50,698 snapshots (and no data at all)

What everyone else says is accurate: ZFS snapshots only store changed blocks and their space consumed depends on how many blocks change. But the minimum is not zero bytes, is's a handful of megabytes. (Where "handful" translates" to "somewhere between 1 and 10 depending on pool size and other factors")

Whether or not this amount is "very negligible" or not is an opinion question.

Josh
  • 463
  • 3
  • 19
1

A snapshot initially takes a very negligible amount of space.

Its size grows later when existing data in the snapshotted dataset is updated or deleted.

The maximum size of a snapshot is the size of the original dataset unless compression and/or deduplication is enabled in which case you might have a snapshot smaller or larger than its parent dataset.

jlliagre
  • 5,693
  • 1
  • 24
  • 28