1

I have an Ubuntu 16.04 box running ZFS. I'm using the zfs-auto-snapshot script to create regular snapshots. Included in my ZFS setup is a ZVOL block device. I want to access (read-only) a snapshot of this ZVOL, but I'm unable to find the resource.

When I do a zfs list -t snapshot, I see a number of snapshots of this block device like

zfspool/folio_drbd@zfs-auto-snap_monthly-2017-12-01-1711 2.59G
- 178G - zfspool/folio_drbd@zfs-auto-snap_weekly-2017-12-08-1511 31.3G - 207G - zfspool/folio_drbd@zfs-auto-snap_weekly-2017-12-22-1511 1.97G
- 194G - zfspool/folio_drbd@zfs-auto-snap_weekly-2017-12-29-1511 908M - 197G -

These do not appear in /zfspool/.zfs/snapshot/zfs-auto-snap-* - How can I access the ZVOL snapshot ?

2

Snapshots of zvols are not automatically displayed inside the file system hierarchy like file system snapshots are (because they can contain any other file system), but you can mount and access them at your chosen destination (again, depending on the content of the zvol). If mounting fails, you may try to first clone and then mount the clone, as detailed in this mailing list post:

did you run dmesg | tail? My GUESS is that the fs needs journal reply, which fails because snapshots are immutable. Mounting the clone would fix this issue.

Try cloning it first, e.g. zfs clone tank/vmdk1@ckpnt2 tank/vmdk1-ckpnt2-clone, then mount /dev/zvol/tank/vmdk1-ckpnt2-clone /mnt/snap1

0
0

A bit late to the party, but ...

I just stumbled across the same problem. Slightly different from the OP, I didn't expect my ZVOL snapshots in /zfspool/.zfs, but somewhere in the /dev tree.

Originally, I couldn't find them there. After reading man zfs, the subject became clear. They are hidden by default, but we can easily make them visible by setting the snapdev property accordingly. In my case, I have a ZVOL rpool/vm-temp. To make its snapshots visible, I just had to do

zfs set snapdev=visible rpool/vm-temp

However, I reverted this setting, because I have several thousands of snapshots which are visible in at least two places: In numbered notation directly in /dev (example: /dev/zd9984p1), and with symbolic names in /dev/zvol/rpool/ (example: /dev/zvol/rpool/vm-temp@Y-2020-06-29-13-44-12-part1), where the latter are just symbolic links to the former.

As one may imagine, several thousands of snapshot devices directly in /dev make /dev somehow unusable, so I make the ZVOL snapshot devices visible only temporarily in case of problems and leave them hidden otherwise.

A very interesting additional aspect:

If you have a ZVOL which acts as (let's say) disk for a VM, you likely have several partitions in it. If there are N partitions, you will get N+1 additional snapshot devices with each snapshot, because the ZVOL itself is treated as disk device, and the partitions are recognized as, well, partitions. Hence, as it would be the case with a bare metal disk with multiple partitions, you get 1 + number of partitions new block devices per ZVOL snapshot.

You can see this from my example above: I have vm-temp@Y-2020-06-29-13-44-12-part1, but also a device with -part2 instead of -part1 (because I have two partitions in this ZVOL), plus one device without the trailing -part... at all, representing the ZVOL itself.

So the answer to the question is:

You can access the snapshots using the devices in /dev/zvol/zfspool or those in /dev, provided you have made them visible by setting the snapdev property for the ZVOL in question to visible.

Unfortunately, you can actually use these snapshot devices only if they are visible, so the way shown in the other answer (clone a snapshot, use the clone) might be the better way, depending on the number of snapshots you have and depending on whether you can or cannot live with them cluttering the /dev directory. Cloning a snapshot works regardless of whether or not the snapshot device is visible in the /dev tree.

So the other answer so far is correct. I just wanted to add an explanation of how you actually can show these devices, enabling you to use them directly without having to clone them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.