How do I mount a snapshot?

KevDog

Patron
Joined
Nov 26, 2016
Messages
462
I've looked for this answer awhile and I'm just confused about snapshots in general

1. I have a bunch of snapshots of a particular dataset and I'd like to recover a file from the dataset, however I'm not sure which snapshot I need to access
2. In order to access a particular snapshot - I went to gui->Storage->Snapshots and the Cloned one of the snapshots. This created a Zvol.

So how exactly do I see what's in this Zvol?
 

kdragon75

Wizard
Joined
Aug 7, 2016
Messages
2,457
I've looked for this answer awhile and I'm just confused about snapshots in general

1. I have a bunch of snapshots of a particular dataset and I'd like to recover a file from the dataset, however I'm not sure which snapshot I need to access
2. In order to access a particular snapshot - I went to gui->Storage->Snapshots and the Cloned one of the snapshots. This created a Zvol.

So how exactly do I see what's in this Zvol?
You could setup a SMB share pointed to that zvol or poke around via console.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Is this a ZVOL you use as a disk image inside a VM? In that case you cannot see the files from FreeNAS. The guest operating system put its own filesystem in there while FreeNAS sees only a single blob of size X. You would need to copy the snapshot to a separate ZVOL that is read/write, then add a new disk device to your VM and look from inside. Alternatively you can just rollback your VM, of course.

I'm not quite sure if the copying is strictly necessary or if you could create a disk device from the snapshot directly. Related to that I don't know from the top of my head if you could just promote the snapshot. IIRC that turns the original ZVOL into a snapshot and the snapshot into a ZVOL. I'm always careful messing around with that and stick to copying via zfs send/receive ...

HTH,
Patrick
 

KevDog

Patron
Joined
Nov 26, 2016
Messages
462
@Patrick -- question since I'm playing around with my zvols -- and yes the zvol is a disk image inside a VM.
I don't think from within the FreeNAS middleware I'm able to mount a snapshot. I understand snapshots are read-only and that would be great since I'm not really interested in writing to the zvol rather just retrieving.

In terms of create a clone from snapshot and comparing this to a zfs send/receive -- the clone's are linked to the snapshot correct? That means you can't delete the snapshot without deleting the clone? I believe clones are created r/w. Does the zfs send/received command unlink the "clone" from the parent snapshot? or is it similar to just creating a clone. I'm talking about doing a zfs send/receive locally and not sending the copy to a remote archive. Also can I use the ZFS diff command to compare the snapshot(ZVOLs)? I'd like to skip over snapshots that haven't changed if possible.

If you rollback to a specific snapshot (say not the most recent but a snapshot that was 3 or "x" snapshots prior to the most recent -- do you have to manually delete the more recent snapshots or does FreeNAS take care of deleting these for you? Also what if you've done a zfs send/receive to a remote archive -- I'm betting it's probably best to manually delete the intermediate snapshots as well.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Hi!

You are confusing a couple of things.

You can mount snapshots in FreeNAS. But only snapshots of mountable things, e.g. datasets/filesystems. You cannot mount ZVOLs. That's why you cannot mount snapshots of ZVOLs, either. ZVOLs are byte-by-byte images of "hard disks" in your use case. Or iSCSI LUNs exported to VMware. Or database table space. All of which cannot be mounted but need to be accessed by the right application. So in your case you need to connect them to a VM running the matching guest operationg system to make sense of the data inside.

In terms of create a clone from snapshot and comparing this to a zfs send/receive -- the clone's are linked to the snapshot correct? That means you can't delete the snapshot without deleting the clone?
Yes. Thanks for refreshing my memory. You can create a r/w clone from an r/o snapshot. And then you can make that cloned ZVOL appear as a second (third, fourth, ...) hard disk in your VM via the "Devices" menu. Need to shutdown the VM first.

Does the zfs send/received command unlink the "clone" from the parent snapshot?
A zfs send creates a bytestream of the snapshot's contents. A zfs receive creates a completely new ZVOL with the contents sent to it. You could just redirect the contents of a zfs send to a file to store it for later, copy over a slow and flaky connection to the other side of the world, then do a zfs receive over there locally ... stuff like that.

If you rollback to a specific snapshot (say not the most recent but a snapshot that was 3 or "x" snapshots prior to the most recent -- do you have to manually delete the more recent snapshots or does FreeNAS take care of deleting these for you? Also what if you've done a zfs send/receive to a remote archive -- I'm betting it's probably best to manually delete the intermediate snapshots as well.
If you rollback to snapshot X, all snapshots younger than X are lost, if I am not mistaken. That would make sense, at least. A copy made by the means of zfs send/receive is not affected by anything you do to the snapshot. That's why I prefer creating copies this way, better safe than sorry.

HTH,
Patrick
 

KevDog

Patron
Joined
Nov 26, 2016
Messages
462
@Patrick M. Hausen
So when I take snapshots of ZVOLs, why aren't they listed in the .zfs directory -- or is this only mountable/readable data? Where are the snapshots located? Certainly should should be able to do a byte comparison between two ZVOLs to see if they differ.

Ok --- no need to answer this question since I think I found the answer here: https://www.reddit.com/r/zfs/comments/4oe037/psa_zvols_and_snapshots/

Can't say I knew that. Thanks for the explanation.
 
Top