# ZFS snapshots + ezjail link directories



## blazingice (Apr 29, 2013)

I have created two jails on separate ZFS filesystems using ezjail. I created one snapshot for each jail, but when I list ZFS snapshots I get three snapshots. Two belong to the jails that were created and a third one to the basejail which is shared among the created jails. I was expecting only two snapshots. 

The fact that a third snapshot was created automatically of the filesystem where the links point to, made me think if there is a mother-daughter relationship between the jail snapshot and the basejail snapshot. However when I delete the jail snapshots the basejail snapshot is not removed automatically.

So is the third snapshot (basejail) linked to the other two or is it completely independent? If it is independent why did it get created? Basically, if I were to roll-back to the jail snapshot will the roll-over happen automatically even with the basejail snapshot, or will that stay untouched?


----------



## redw0lfx (Apr 29, 2013)

Did you perhaps use the recursive option for snapshots? 

`man 8 zfs`

```
zfs snapshot [-r] [-o property=value] ...
         filesystem@snapname|volume@snapname

         Creates a snapshot with the given name. All previous modifications by
         successful system calls to the file system are part of the snapshot.
         See the "Snapshots" section for details.

         -r      Recursively create snapshots of all descendent datasets.
                 Snapshots are taken atomically, so that all recursive snap-
                 shots correspond to the same moment in time.
```


----------



## blazingice (Apr 29, 2013)

No. All I did was 
`# zfs snapshot tank0/usr/jails/jail1@freshinstall`
`# zfs snapshot tank0/usr/jails/jail2@freshinstall`


----------



## fonz (Apr 29, 2013)

blazingice said:
			
		

> So is the third snapshot (basejail) linked to the other two or is it completely independent?


I'm not entirely certain because I tend to do things manually instead of using sysutils/ezjail, but most likely the basejail is nullfs(5)-mounted into both of your jail directories. Does that answer your question?


----------



## blazingice (Apr 29, 2013)

Yes, that's correct. Basejail is nullfs-mounted into both jails, but I am still not sure how ZFS snapshots work in this situation. So, how do these snapshots relate to each other?

Model A
Jail snapshot (mother)
     Basejail snapshot (daughter)

Model B
Jail snapshot (independent)
Basejail snapshot (independent)

If it is Model B, why did basejail snapshot get created automatically when I create snapshot for jail filesystem?
If it is Model A, why doesn't it get deleted when I delete the jail snapshot?

What happens to Basejail snapshot when you clone and promote the jail snapshot? Does it follow the jail snapshot as if it was Model A or it stays untouched as if it is Model B?

Am I making sense?


----------



## fonz (Apr 29, 2013)

Your thread has been moved from the "General" section to the "Storage" section, where hopefully it will get more attention from ZFS experts.


----------



## t1066 (Apr 29, 2013)

I am no expert. But maybe you can show us the output of 

`zfs list -t snapshot`


----------



## blazingice (Apr 29, 2013)

Here is my snapshot list

```
NAME                                         USED  AVAIL  REFER  MOUNTPOINT
tank0/usr/jails/basejail@20130421_00:42:15   104K      -   144K  -
tank0/usr/jails/jail1@freshinstall              0      -  3.33M  -
tank0/usr/jails/jail2@freshinstall              0      -  3.33M  -
```

However, I found that the first snapshot is being created automatically when installing the basejail. I had already checked the list of the snapshots before installing ezjail, and nothing was showing. I wasn't aware that `#ezjail-admin install` would create an automatic snapshot of the basejail, hence the confusion. It's all clear now.

Thanks.


----------

