是否存在 ZFS 感知差异?

是否存在 ZFS 感知差异?

我经常制作 ZFS 卷(包含 AOSP)的快照并进行一些更改(通常在其顶部提取 ZIP 文件或运行脚本),然后运行diff以查看发生了什么变化。

使用 ZFS 确实很容易:

diff /mnt/vol /mnt/vol/.zfs/2017-10-18_snapshot

当“vol”包含 63GB 且大多为小文件时,需要很长时间。

ZFS 显然具有关于哪些文件不同的信息,因为快照是写时复制的。

是否存在 ZFS 感知差异,可以直接向 ZFS 询问答案?

答案1

事实上有,它甚至被命名为zfs diff文档和示例

$ zfs diff tank/home/tim@snap1 tank/home/tim@snap2
M       /tank/home/tim/
+       /tank/home/tim/fileB

您还可以在快照和实时数据集之间进行比较,但只能在同一数据集和后代中,并且只能按照有效的时间顺序(即从旧到新而不是从新到旧,如果一开始不起作用,只需交换参数即可)。可能的结果是:

M : File or directory has been modified or file or directory link has changed
- : File or directory is present in the older snapshot but not in the more recent snapshot
+ : File or directory is present in the more recent snapshot but not in the older snapshot
R : File or directory has been renamed

对于过滤结果并在脚本中使用它们,另请参见注释中的示例我的其他答案在 StackOverflow 上。

相关内容