I was using zfs list -t snapshot to identify if the pool was changed. If the last snapshot was showing that it uses some space then I was sure that pool was changed and I(actually a script) did another snapshot.
What I noticed that if I move a file from 1 folder to another folder in the pool than the command zfs list -t snapshot still returns 0 as a size of the last snapshot. That's not good for me as I need to identify if my pool was changed. What do I do wrong? Is there any other more reliable way of identifying if the pool was actually changed?
Snapshots show how your file system looked at a specific point in the past (including its size). If you remove or modify a file afterwards, the blocks that are different (meaning the blocks that are now deleted or modified) will remain on the filesystem (think of them as locked; or similar to how hard links work on Unix, as long as a reference to a file exists, it will not be deleted).
On the contrary, if you just add a new file, the old blocks stay the same, so the snapshot will not differ in size. Moving your folder inside the same file system does not add new data, so it will not show in size.
To view the differences, you can compare the current state with the last snapshot by using zfs diff pool/dataset@snapshot pool/dataset. For details on using the output in scripts, see my other answer here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With