4

I am confused about how ZFS snapshots and rollback are supposed to work. I have a zpool containing a couple zvols (each made from partitions of a mirrorvdev). I make a snapshot like this:

~$ sudo zfs snapshot nvme-tank@roll_test

Then I boot a VM located on one of the zvols in the zpool and create a test file

~$ echo "This is a test of the rollback system" > rbtest.txt

Then I shut down the VM and do the rollback. As I understand the concept, the rollback should revert everything in nvme-tank to the state it was when I took the snapshot, before making rbtest.txt.

~$ sudo zfs rollback nvme-tank@roll_test

I then reboot the vm, check for rbtest.txt, and there it is, still there! enter image description here

The snapshot is there:

~$ zfs list -t all -r nvme-tank
NAME                  USED  AVAIL  REFER  MOUNTPOINT
nvme-tank             887G  12.1G    24K  /media/nvme-tank
nvme-tank@nov82018      0B      -    24K  -
nvme-tank@roll_test     0B      -    24K  -
nvme-tank/ext4-zvol   474G   449G  37.8G  -
nvme-tank/ntfs-zvol   413G  23.9G   401G  -

So, am I misunderstanding what snapshots are supposed to do, using them incorrectly, or is something broken with my zfs?

Stonecraft
  • 243
  • 2
  • 4
  • 15

1 Answers1

4

You only snapshotted nvme-tank, but you didn't snapshot either of nvme-tank/ext4-zvol or nvme-tank/ntfs-zvol, one of which contains the file you created. So nothing happened because you were snapshotting a different dataset than the one you created the file in.

If you want snapshots to be recursive to descendent datasets/zvols, you have to explicitly ask for recursive snapshots, with zfs snapshot -r. However, you can only rollback one specific dataset/zvol at a time with zfs rollback.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • 1
    Additionally, in OpenZFS a new feature [channel programs](https://www.delphix.com/blog/delphix-engineering/zfs-channel-programs) ([illumos version of the man page](https://illumos.org/man/1M/zfs-program)) will allow you to recursively rollback a bunch of datasets at once, but you'll have to write a short Lua script to implement that specific function. – Dan Nov 09 '18 at 01:06