How can you find the parent snapshot of a zfs clone?
Solution 1:
There is a special property called origin
which holds what you need. Let's assume we have a zpool tank
and a filesystem tank/f1
and we create a snapshot and a clone:
zfs snapshot tank/f1@s1
zfs clone tank/f1@s1 tank/f2
Let's check the origin of that clone:
zfs get origin tank/f2
Output:
NAME PROPERTY VALUE SOURCE
tank/f2 origin tank/f1@s1 -
Solution 2:
Depends on your zfs list output... but you can also look at the output of: zpool history
to see the command sequences and actions (manual and automated) performed on the pool. That may help refresh your memory. Filter for clone
commands if there's too much output.
[root@GreenLeaf ~]# zpool history
History for 'vol0':
2013-09-14.16:57:19 zpool create -o ashift=12 vol0 fioa
2013-09-14.16:57:26 zfs create vol0/ppro2
2013-09-14.16:57:32 zfs set recordsize=32K vol0/ppro2
2013-09-15.14:52:08 zfs create -s -V 750G vol0/pprovol
2013-09-15.14:55:23 zfs destroy vol0/pprovol
2013-09-15.14:58:06 zfs create -o volblocksize=64K -s -V 750G vol0/pprovol
History for 'vol1':
2012-12-31.16:13:01 zpool create -f vol1 /dev/sdb
2012-12-31.16:13:22 zfs create vol1/ppro
2012-12-31.16:13:47 zfs set atime=off vol1/ppro
2012-12-31.16:13:55 zfs set compress=on vol1/ppro
2012-12-31.16:15:05 zfs set mountpoint=/ppro vol1/ppro
2012-12-31.21:07:37 zfs create vol1/pproold
2012-12-31.21:08:17 zfs set compress=gzip-9 vol1/pproold
2012-12-31.21:08:53 zfs set mountpoint=/ppro/pproold vol1/pproold
2012-12-31.22:20:56 zfs create vol1/ppro1
2012-12-31.22:21:12 zfs set compress=gzip-9 vol1/ppro1
2012-12-31.22:21:32 zfs set mountpoint=/ppro/ppro1 vol1/ppro1
2013-01-01.11:15:07 zpool set autoexpand=on vol1
Solution 3:
Another simple method:
zfs list -o name,origin | egrep ".@."
and without rpool:
zfs list -o name,origin | egrep -v "^rpool" | egrep ".@."