Getting the ZFS file size including all its snapshots

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

hatchi

Member
Nov 8, 2014
59
20
8
43
Hi All,
in ZFS is there any way to calculate snapshot sizes per file, the "per file" is the important part here

lets say i have ZFS pool that have 10 vm images (vm image is just a big file from ZFS perspective) and i am snapshoting the whole pool once per day

now lets say we have 10 snapshots and I wish to know the total size the vm image used including all its snapshot

one important factor that I think can make getting this info possible is that the vm image never shirnk in size . they always increase never decrease.


I have searched but couldnt find any information about that


Thanks
 

gea

Well-Known Member
Dec 31, 2010
3,140
1,182
113
DE
Not possible as a snapshot creation is not a result of a filecopy but a freeze of ZFS blocks when they are created newly on a modification. You can only get the used space for all snaps or the space that a snap uses uniquely (not shared with other snaps) - not per file.

If you would want to know space per VM you would need a ZFS filesystem per VM.
see this video about "How ZFS snapshots really work" from Matt Ahrens,
 
  • Like
Reactions: hatchi

hatchi

Member
Nov 8, 2014
59
20
8
43
yeah thats what i was afraid of
I was hoping zfs keep table of all blocks(inodes) belonging to a file somewhere
and on each snapshot they they have a new table with the updated blocks or new blocks

so if someone manage to access those tables that can check all the changed blocks and add their size plus check if any new blocks added to the file

I still think it may be possible programmatically but the feature not implemented in ZFS

anyway for my issue the solution you suggested is the only solution which is a new filesystem per vm which is overkill on both omniOS and the hypervisor but it seems if I really need that feature that would be the only way