Solved Can't create snapshots of /usr dataset on ZFS rooted system. Feels like I am in jail?

The core of my problem is that I can't create snapshots of my FreeBSD 10.0 /usr dataset.

I only have one zpool which is called "zroot" that is generated by FreeBSD on my rooted ZFS FreeBSD 10.0 installation on a single disk.

My disk layout is as follows gpart show
Code:
[NOPARSE]=>        34  2047999933  vtbd0  GPT  (977G)
          34        1024      1  freebsd-boot  (512K)
        1058    67108864      2  freebsd-swap  (32G)
    67109922  1980890045      3  freebsd-zfs   (945G)[/NOPARSE]

Thus it is not possible to create another pool. Which means I have to work with datasets like zroot/usr which are created at the installation by FreeBSD.

Now I want to be able to create a snapshot of zroot/usr because when I get, for example, problems with (an upgrade of) any of my installed user software, I just could do a rollback to return to the situation before the problem originated. This is one of the most important reasons why I started using ZFS.

But as I will show underneath, it seems to be impossible to create a snapshot of zroot/usr.

This is what happens:

First I will display all datasets in my system after a clean install: zfs list
Code:
[NOPARSE]NAME                 USED  AVAIL  REFER  MOUNTPOINT
zroot               2.65G   927G   148K  none
zroot/ROOT          1.49G   927G   144K  none
zroot/ROOT/default  1.49G   927G  1.49G  /
zroot/tmp            264K   927G   264K  /tmp
zroot/usr            813M   927G   144K  /usr
zroot/usr/home       196K   927G   196K  /usr/home
zroot/usr/ports      813M   927G   813M  /usr/ports
zroot/usr/src        144K   927G   144K  /usr/src
zroot/var            375M   927G   374M  /var
zroot/var/crash      148K   927G   148K  /var/crash
zroot/var/log        748K   927G   748K  /var/log
zroot/var/mail       216K   927G   216K  /var/mail
zroot/var/tmp        200K   927G   200K  /var/tmp[/NOPARSE]

Then: zfs mount
Code:
[NOPARSE]zroot/ROOT/default              /
zroot/tmp                       /tmp
zroot/usr/home                  /usr/home
zroot/usr/ports                 /usr/ports
zroot/usr/src                   /usr/src
zroot/var                       /var
zroot/var/crash                 /var/crash
zroot/var/log                   /var/log
zroot/var/mail                  /var/mail
zroot/var/tmp                   /var/tmp[/NOPARSE]

zroot/usr seems not to be mounted: zfs get mounted zroot/usr
Code:
[NOPARSE]NAME       PROPERTY  VALUE    SOURCE
zroot/usr  mounted   no       -[/NOPARSE]

which means: canmount=off

So now I do: zfs set canmount=on zroot/usr

see what is in /usr: ls /usr
Code:
bin    games    home    include    lib    lib32    libdata    libexec    local    obj    ports    sbin    share    src    tests

but when zroot/usr is not mounted I can not make a snapshot!
zfs snapshot -r zroot/usr/snap1
Code:
[NOPARSE]usage:

    snapshot [-r] [-o property=value] ... <filesystem@snapname|volume@snapname> ...

For the property list, run: zfs set|get

For the delegated permission list, run: zfs allow|unallow[/NOPARSE]

When I do: zfs mount -a zroot/usr will be mounted
zfs get mounted zroot/usr
Code:
[NOPARSE]NAME       PROPERTY  VALUE    SOURCE
zroot/usr  mounted   yes      -[/NOPARSE]

But now, when I do: ls /usr zroot/usr is completely empty and also lost the connections with all files in /usr

I really don't know what is the reason that I can't make a new dataset at zroot/usr
Also I don't understand, though zroot/usr is not mounted, everything is working normally in /usr. Could I be in a jail enviroment? Is there anywhere a manual how FreeBDS 10.0 installs the ZFS root enviroment?

Anybody who can tell me what I am doing wrong? As for me it does not make sense to work with rooted ZFS if it is not possible to make snapshots of my system files?

If that should be the case it is maybe better not to work with a ZFS rooted system, but install ZFS on UFS
 
Partly solved: How stupid can I be? What I wanted is that I can rollback to a point before a problem was originated.

I was trying to do this in the wrong directory. I tried to make a snapshot of
Code:
zroot/usr
But instead that can be done in
Code:
zroot/ROOT/default
zfs snapshot -r zroot/ROOT/default@snap1
Now I can anyway roll back to the complete root.

When I was trying to solve my problem because I wanted to make a rollback of a specific subdirectory, in this case
Code:
/usr
I also created a new child dataset like
Code:
zroot/ROOT/default/usr/
but this did not work either.

So I still have to find out how I can create a snapshot of a specific subdir.

But the most important thing is that I at least can make a rollback of the complete root!
 
What's going on here is part of the boot environment concept. If you've worked on recent Solaris you may have run across this. Take a look at the sysutils/beadm port to make more efficient use of the boot environments.

Did you work out "how I can create a snapshot of a specific subdir"?

The ZFS snapshot is the whole dataset. Generally, if it makes sense to be part of a boot environment then that is the default. Directories like /usr/home, /usr/ports, and so forth have their own dataset. If you need to make another, then follow their configuration. Otherwise, you can always go into the hidden .zfs directory to grab individual files from a snapshot like so: cd /.zfs/snapshot/20150510-snap.
 
Back
Top