Solved Unable to diff ZFS snapshot

Hello,

I'm trying to discover ZFS snapshots, and found an issue:
zfs list -t all
Code:
zroot/var
zroot/var@before_mysql
zroot/var/audit
zroot/var/crash
zroot/var/log
zroot/var/tmp

And below command returns me an error:
zfs diff zroot/var@before_mysql
Code:
Cannot diff an unmounted snapshot: operation not applicable to datasets of this type

But if I tried to (before snaphot destroyed)
zfs diff zroot/var/log@before_mysql
I worked properly.

What am I doing wrong?
 
But if I tried to (before snaphot destroyed)
What do you mean by this?

I get exactly the same error if I try and diff a snapshot that doesn't exist, which of course would be impossible.
Code:
# zfs diff sys@this_doesnt_exist
Cannot diff an unmounted snapshot: operation not applicable to datasets of this type
 
But my snapshot exists. Please look at the 2nd position.
Code:
zroot/var
zroot/var@before_mysql
zroot/var/audit
zroot/var/crash
zroot/var/log
zroot/var/tmp
 
Yeah I saw that, it's just this bit further down your post reads to me like you're saying "it used to work before I destroyed the snapshot".
But if I tried to (before snaphot destroyed)
zfs diff zroot/var/log@before_mysql
I worked properly.
 
Yes, because I initially had:
Code:
zroot/var
zroot/var@before_mysql
zroot/var/audit
zroot/var/audit@before_mysql
zroot/var/crash
zroot/var/crash@before_mysql
zroot/var/log
zroot/var/log@before_mysql
zroot/var/tmp
zroot/var/tmp@before_mysql
And every diff worked properly, just only with zroot/var I have a problem.
 
zfs get all zroot/var@before_mysql
Code:
NAME  PROPERTY  VALUE  SOURCE
zroot/var@before_mysql  type  snapshot  -
zroot/var@before_mysql  creation  Tue Nov  3 11:24 2015  -
zroot/var@before_mysql  used  0  -
zroot/var@before_mysql  referenced  96K  -
zroot/var@before_mysql  compressratio  1.00x  -
zroot/var@before_mysql  devices  on  default
zroot/var@before_mysql  exec  on  default
zroot/var@before_mysql  setuid  on  default
zroot/var@before_mysql  xattr  on  default
zroot/var@before_mysql  version  5  -
zroot/var@before_mysql  utf8only  off  -
zroot/var@before_mysql  normalization  none  -
zroot/var@before_mysql  casesensitivity  sensitive  -
zroot/var@before_mysql  nbmand  off  default
zroot/var@before_mysql  primarycache  all  default
zroot/var@before_mysql  secondarycache  all  default
zroot/var@before_mysql  defer_destroy  off  -
zroot/var@before_mysql  userrefs  0  -
zroot/var@before_mysql  mlslabel  -
zroot/var@before_mysql  refcompressratio  1.00x  -
zroot/var@before_mysql  written  96K  -
zroot/var@before_mysql  clones  -
zroot/var@before_mysql  logicalused  0  -
zroot/var@before_mysql  logicalreferenced  9.50K  -
zroot/var@before_mysql  volmode  default  default
 
Hmm well ZFS obviously has no problem accessing the snapshot.
The only other possibility I can see is if zroot/var itself isn't mounted. It seems the snapshot's parent dataset must be mounted for zfs diff to work.

Have a look in mount output and confirm it's definitely mounted. If not, but it should be (has mountpoint set and canmount=yes), you can probably just reboot. Otherwise you can possibly temporarily mount it on /mnt.

Code:
# mount -t zfs zroot/var /mnt
# zfs diff zroot/var@before_mysql
 
Oh, that's right, mount said:
Code:
zroot/tmp on /tmp (zfs, local, noatime, nosuid, nfsv4acls)
zroot/usr/home on /usr/home (zfs, local, noatime, nfsv4acls)
zroot/usr/ports on /usr/ports (zfs, local, noatime, nosuid, nfsv4acls)
zroot/usr/src on /usr/src (zfs, local, noatime, nfsv4acls)
zroot/var/audit on /var/audit (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/crash on /var/crash (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/log on /var/log (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/mail on /var/mail (zfs, local, nfsv4acls)
zroot/var/tmp on /var/tmp (zfs, local, noatime, nosuid, nfsv4acls)
But I don't understand why, because: zfs get mountpoint zroot/var
Code:
NAME  PROPERTY  VALUE  SOURCE
zroot/var  mountpoint  /var  local
But ls /var
returns all files should be there. That's weird.
 
Just because is has mountpoint=/var doesn't mean it's mounted. What does the canmount property say?

It's entirely possible the zroot/var dataset is there purely to create the correct structure for the datasets underneath it - zroot/var/log, zroot/var/mail, etc, and has never actually been mounted or contained any data.

I'm pretty sure the BSD installer does this for /usr. It creates zroot/usr, but doesn't mount it. It's only there so that it can create zroot/usr/home, zroot/usr/local, etc, and have them all inherit the correct mount point automatically. It helps keep the datasets tidy and logical. Anything that goes into /usr, but not into one of the child datasets actually ends up in a /usr directory on the zroot dataset.
 
I see it, that's right.
zfs get all zroot/var | grep mount
Code:
zroot/var  mounted  no  -
zroot/var  mountpoint  /var  local
zroot/var  canmount  off  local
zfs get all zroot/usr | grep mount
Code:
zroot/usr  mounted  no  -
zroot/usr  mountpoint  /usr  local
zroot/usr  canmount  off  local

When zroot/var/(log|mail|tmp|...) are inherited from zroot/var and I will take snapshot of zroot/var, will it be automatically taken for children too?
 
No, by default zfs snapshot only takes a snapshot of the dataset that is supplied.
To do all the children you'd need to use the recursive option:

Code:
zfs snapshot -r zroot/var
 
Yeah, that created all snapshots. Is it possible to destroy them with one command, or should I do it manually for everyone?
 
Code:
zfs destroy -r zroot/var@snapshot
Just be careful not to run it without the snapshot name, as it may destroy the actual datasets as well.
 
Back
Top