ZFS Need a little guidence re clones before I shoot myself in the foot

I have a clone that I would like to turn into a 'real' filesystem', which I understand is accomplished by zfs promote cloned. The situation that exists is this:
Code:
# zfs get origin zroot/iocage/jails/smb4-1c
NAME                        PROPERTY  VALUE                               SOURCE
zroot/iocage/jails/smb4-1c  origin    zroot/iocage/jails/smb4-1b@smb4-1c  -

# zfs get origin zroot/iocage/jails/smb4-1b
NAME                        PROPERTY  VALUE   SOURCE
zroot/iocage/jails/smb4-1b  origin    -       -

Now, what I want to do is to promote smb4-1c and leave smb4-1b alone. The snapshot zroot/iocage/jails/smb4-1b@smb4-1c I do not need. The dataset zroot/iocage/jails/smb4-1b@smb4-1b I must keep. What I want to end up with is:
Code:
# zfs get origin zroot/iocage/jails/smb4-1c
NAME                        PROPERTY  VALUE   SOURCE
zroot/iocage/jails/smb4-1c  origin    -       -

# zfs get origin zroot/iocage/jails/smb4-1b
NAME                        PROPERTY  VALUE   SOURCE
zroot/iocage/jails/smb4-1b  origin    -       -

My question is: will running the command zfs promote zroot/iocage/jails/smb4-1c give me that result?
 
Well, this little experiment shows that what I feared was the case is indeed the case:
This is the initial state:
Code:
[root@vhost04 ~ (master)]# zfs get origin /var/original*
NAME                      PROPERTY  VALUE                         SOURCE
zroot/var/original        origin    -                             -
zroot/var/original_copy1  origin    zroot/var/original@firstsnap  -
zroot/var/original_copy2  origin    zroot/var/original@firstsnap  -

Promote clone 1:
Code:
[root@vhost04 ~ (master)]# zfs promote zroot/var/original_copy1

[root@vhost04 ~ (master)]# zfs get origin /var/original*
NAME                      PROPERTY  VALUE                               SOURCE
zroot/var/original        origin    zroot/var/original_copy1@firstsnap  -
zroot/var/original_copy1  origin    -                                   -
zroot/var/original_copy2  origin    zroot/var/original_copy1@firstsnap  -

Promote clone 2:
Code:
[root@vhost04 ~ (master)]# zfs promote zroot/var/original_copy2

[root@vhost04 ~ (master)]# zfs get origin /var/original*
NAME                      PROPERTY  VALUE                               SOURCE
zroot/var/original        origin    zroot/var/original_copy2@firstsnap  -
zroot/var/original_copy1  origin    zroot/var/original_copy2@firstsnap  -
zroot/var/original_copy2  origin    -                                   -

So my question is: How to create a separate filesystem from the clones without turning the original filesystem into one?
 
With zfs send/recv.

zfs snapshot/clone works by storing only the changed blocks. This obviousely requires an origin from which the blocks are changed.
 
Ah, zfs send / receive is the answer that I found. I presume that there are other simplier ways to do this but it works:
Code:
zfs send -R zroot/iocage/jails/smb4-1c@send_rcv_host_xfr_2020-06-18_15-33-26 | zfs receive -s zroot/iocage/jails/smb4-1
 
This does not seem to work for me so I am missing something. The objective is to take a cloned filesystem and copy that to a new uncloned file system, leaving the clone intact.

Given:
Code:
zfs get origin zroot/iocage/jails/smb4-1b
NAME                        PROPERTY  VALUE   SOURCE
zroot/iocage/jails/smb4-1b  origin    -       -

zfs get origin zroot/iocage/jails/smb4-1c
NAME                        PROPERTY  VALUE                               SOURCE
zroot/iocage/jails/smb4-1c  origin    zroot/iocage/jails/smb4-1b@smb4-1c  -

zfs snapshot -r zroot/iocage/jails/smb4-1c@smb4-1_source2

zfs send -R zroot/iocage/jails/smb4-1c@smb4-1_source2 | zfs receive zroot/iocage/jails/smb4-1
zfs get origin zroot/iocage/jails/smb4-1
NAME                       PROPERTY  VALUE                               SOURCE
zroot/iocage/jails/smb4-1  origin    zroot/iocage/jails/smb4-1b@smb4-1c  -

That looks to me an awful lot like a clone and not a filesystem. What am I doing wrong? Is it the -R on send? But I have used that to transmit filesystems to other hosts and do not see this problem. Those all have origins like smb4-1b.

If I do not use the -R switch on send then descendant datasets are not transferred:

With the -R switch:
Code:
zroot/iocage/jails/smb4-1                     401M   399G    92K  /zroot/iocage/jails/smb4-1
zroot/iocage/jails/smb4-1/root                401M   399G  2.58G  /zroot/iocage/jails/smb4-1/root
zroot/iocage/jails/smb4-1b                   2.35G   399G    92K  /zroot/iocage/jails/smb4-1b
zroot/iocage/jails/smb4-1b/root              2.35G   399G  2.35G  /zroot/iocage/jails/smb4-1b/root
zroot/iocage/jails/smb4-1c                    401M   399G    92K  /zroot/iocage/jails/smb4-1c
zroot/iocage/jails/smb4-1c/root               401M   399G  2.55G  /zroot/iocage/jails/smb4-1c/root

Without the -R switch:
Code:
zroot/iocage/jails/smb4-1                     152K   400G    92K  /zroot/iocage/jails/smb4-1
zroot/iocage/jails/smb4-1b                   2.35G   400G    92K  /zroot/iocage/jails/smb4-1b
zroot/iocage/jails/smb4-1b/root              2.35G   400G  2.35G  /zroot/iocage/jails/smb4-1b/root
zroot/iocage/jails/smb4-1c                    401M   400G    92K  /zroot/iocage/jails/smb4-1c
zroot/iocage/jails/smb4-1c/root               401M   400G  2.55G  /zroot/iocage/jails/smb4-1c/root

Dataset zroot/iocage/jails/smb4-1/root is missing after the send if -R is not specified.
 
In the absence of knowledge of any other way to do this I ended up issuing two sends:
Code:
# zfs send zroot/iocage/jails/smb4-1c@smb4-1_source2 | zfs receive zroot/iocage/jails/smb4-1
# zfs send zroot/iocage/jails/smb4-1c/root@smb4-1_source2 | zfs receive zroot/iocage/jails/smb4-1/root

# zfs get origin zroot/iocage/jails/smb4-1
NAME                       PROPERTY  VALUE   SOURCE
zroot/iocage/jails/smb4-1  origin    -       -

# zfs get origin zroot/iocage/jails/smb4-1/root
NAME                            PROPERTY  VALUE   SOURCE
zroot/iocage/jails/smb4-1/root  origin    -       -

Is there no way to recurse a send without a complete replication?
 
zfs send -R zroot/iocage/jails/smb4-1c@smb4-1_source2 | zfs receive zroot/iocage/jails/smb4-1
zfs get origin zroot/iocage/jails/smb4-1
NAME PROPERTY VALUE SOURCE
zroot/iocage/jails/smb4-1 origin zroot/iocage/jails/smb4-1b@smb4-1c -
[/CODE]

That looks to me an awful lot like a clone and not a filesystem.

Probably, if it is copying a clone, it will result in a copy of a clone, which then is a clone. Never tried that.
According to the manual:
-R, --replicate
[...]When received, all properties,
snapshots, descendent file systems, and clones are preserved.

If I do not use the -R switch on send then descendant datasets are not transferred:

That's correct. Use -R to copy the whole tree.
 
Back
Top