ZFS snapshot zd0 block device

snapshotxfszfsonlinux

I'm trying to make use of the ability of zfs snapshots.
To explain a little how it's configured on my end:

zpool create vol0 mirror /dev/sda /dev/sdb
zfs create -o volblocksize=128K -V 15T vol0/pprovol

I got my ZFS volumes:

NAME           USED  AVAIL  REFER  MOUNTPOINT
vol0          15.0T  16.6T   100K  /vol0
vol0/pprovol  15.0T  31.6T  1.99G  -

And I have a block device on:

Disk /dev/zd0: 15 TiB, 16492674416640 bytes, 32212254720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 131072 bytes
I/O size (minimum/optimal): 131072 bytes / 131072 bytes

I formated it as xfs with: mkfs.xfs /dev/zd0 and mounted it on my mounted point

Now I would like to create snapshots for this zd0 device.
So that I could rollback changes made on the xfs filesystem.

Is this possiable? And how can I do this?

It does work for my /vol0 but that isn't what I need.
Hope to get some help around here! Thanks.

Best Answer

Here's how to manage snapshots on an XFS on top of ZFS setup.
(a disclaimer: there are safer and more intelligent ways to store (ppro) data on ZFS)

  • Take a snapshot.
  • Identify the snapshot.
  • Clone the snapshot.
  • Mount the cloned block device.

When you run the ZFS snapshot, the snapshot will appear in your snapshot lists:

enter image description here

From there, you have to clone the snapshot to make it visible as a block device.

zfs clone vol1/pprovol2@snap_daily-2016-12-23-2359 vol1/recovery

This creates a new zfs filesystem named vol1/recovery, and simultaneously creates a new /dev/zdX device. dmesg | tail will reveal the actual device name. It will likely be /dev/zd16.

This is your clone. If you want to mount it, you just run:

mount -t xfs -o nouuid /dev/zd16 /mountpoint

The nouuid is needed because the cloned device has the name UUID as the original XFS filesystem.

Related Topic