ZFS Can't access zfs snapshot

I was looking to recover one file so I did
zfs list -t snapshot

This shows among other things
zroot/ROOT/default@2024-12-03-07:36:32-0 3.26M - 10.4G -

I thought the way to mount it was
zfs mount zroot/ROOT/default@2024-12-03-07:36:32-0
But got the message
cannot open 'zroot/ROOT/default@2024-12-03-07:36:32-0': snapshot delimiter '@' is not expected here
Doing some more web searching indicated that this might mean it was already mounted so I went into /zroot/.zfs/snapshot and did ls -a but
there was nothing there. To make this more aggravating, at some point, playing with the syntax, I did find the snapshot in /zroot/.zfs/snapshot,
but trying to mount another snapshot, I couldn't, I got the same error as above. And being aggravated at this point, I don't know what I did to actually correctly mount the snapshot once and couldn't repeat it.

My second question--and mods, if this should be a separate thread, please let me know and I'll do so---is that, with the one successfully mounted snapshot, I thought that home would contain my home directory and the files, however when I cd'd into the snapshot/home, there was nothing there.
My main question is the first one though, how do I mount an existing snapshot to look at it, and, if needed, copy a file from it. Looking at the handbook, and web searching, I can't figure out where my error is.

Thanks for any input.
 
Check zfs list or mount to see where that dataset is mounted. Given that it's zroot/ROOT/default, I suspect it's mounted at /. As such, you should be able to go into /.zfs/snapshot/ to see the snapshots of that dataset. They will be mounted automatically if you access them.

/zroot/.zfs/snapshot will contain snapshots of your zroot dataset, which you are more than likely not using.

Each snapshot will appear to contain a complete copy of the relevant dataset at the time the snapshot was taken. Usually, not seeing the expected files is due to not correctly understanding what dataset your data is actually on, or where those datasets are mounted. Data is accessed via the mountpoint, not the ZFS dataset name; These are often the same, but not always.
 
To view and access snapshots in the .zfs/snapshot directory you need to have the snapdir property enabled:

zfs get snapdir zroot/ROOT/default

If its value is hidden you will not be able to see anything, if so change it to visible:

zfs set snapdir=visible zroot/ROOT/default

With that I should be able to see the content of the snap, for your first question I am with the user usdmatt
 
The snapshot you try to mount might be created by bectl, therefore in order to mount it you need to pick "the clone's name", to list the name I use this:
~ : zfs list -t snapshot -o name,clones | grep ROOT
zroot/ROOT/default@2024-10-30-17:16:53-0 zroot/ROOT/13.3-RELEASE-p7_2024-10-30_171653
zroot/ROOT/default@2024-10-30-17:27:54-0 zroot/ROOT/13.3-RELEASE-p8_2024-10-30_172754
zroot/ROOT/default@2024-10-30-17:30:18-0 zroot/ROOT/13.4-RELEASE-p1_2024-10-30_173018
zroot/ROOT/default@2025-01-30-00:37:32-0 zroot/ROOT/13.4-RELEASE-p2_2025-01-30_003732


Or since it's only BE snapshots bectl is more appropriate, it shows all the corresponding names:
~ : doas bectl list -a
BE/Dataset/Snapshot Active Mountpoint Space Created

13.3-RELEASE-p7_2024-10-30_171653
zroot/ROOT/13.3-RELEASE-p7_2024-10-30_171653 - - 176K 2024-10-30 17:16
zroot/ROOT/default@2024-10-30-17:16:53-0 - - 78.4M 2024-10-30 17:16

13.3-RELEASE-p8_2024-10-30_172754
zroot/ROOT/13.3-RELEASE-p8_2024-10-30_172754 - - 8K 2024-10-30 17:27
zroot/ROOT/default@2024-10-30-17:27:54-0 - - 7.04M 2024-10-30 17:27

13.4-RELEASE-p1_2024-10-30_173018
zroot/ROOT/13.4-RELEASE-p1_2024-10-30_173018 - - 8K 2024-10-30 17:30
zroot/ROOT/default@2024-10-30-17:30:18-0 - - 6.74M 2024-10-30 17:30

13.4-RELEASE-p2_2025-01-30_003732
zroot/ROOT/13.4-RELEASE-p2_2025-01-30_003732 - - 8K 2025-01-30 00:37
zroot/ROOT/default@2025-01-30-00:37:32-0 - - 13.4G 2025-01-30 00:37

default
zroot/ROOT/default NR / 65.6G 2024-06-14 18:35


Then to mount a snapshot, I just use bectl:
~ : doas bectl mount zroot/ROOT/13.3-RELEASE-p7_2024-10-30_171653
Successfully mounted zroot/ROOT/13.3-RELEASE-p7_2024-10-30_171653 at /tmp/be_mount.ZWlR



My second question--and mods, if this should be a separate thread, please let me know and I'll do so---is that, with the one successfully mounted snapshot, I thought that home would contain my home directory and the files, however when I cd'd into the snapshot/home, there was nothing there.
From what I've read in the bectl manpage only few directories are saved, home is not one of them, those included in bectl snapshots have to property canmount set to off.
~ : zfs list -o name,canmount | grep off
zroot/usr off
zroot/var off


So in order to have snapshots of the home directory you have to take those manually, or change the property of the home dataset but I am not sure if it's a good idea or even convenient in a long run.
 
Back
Top