ZFS How to rebase clones onto a new snapshot while preserving data?

· I installed a base system on zroot/ROOT/base
· I took a snapshot of it: zroot/ROOT/base@snap
· I created two clones from that snapshot:
· zroot/ROOT/default (mounted at /, used for daily driver software)
· zroot/ROOT/build (used for installing compilers and dependencies like FreeBSD-set-devel)

· zroot/ROOT/base contains only the FreeBSD-set-optional and kernel. I use it for quick dependency tests and then rollback to @snap to stay clean.

I recently performed system updates inside zroot/ROOT/base and created a new snapshot: zroot/ROOT/base@snap_new.

Goal:
I want both zroot/ROOT/default and zroot/ROOT/build to be rebased on base@snap_new.

If I update the system in the three database, it will take three times space.
 
Name "rebase" does exist for git but not for zfs.
What are you trying to do ?
Rename ?
zfs rename -r tank/home@monday tuesday

I think you did not make a clone, (not necessary)

Note , snapshot is read only ;
clone is read write made out of read only snapshot

just snapshot recursively zroot ; all one in a go. Then you can send any sub-datasets to any destination.

After backup i do sometimes :
zfs list zroot | grep "@"
----> give me all snapshots of zroot
| awk '{print $1}'
----> give me column 1
| xargs -I {} zfs destroy {}
---> destroy all and only all snapshots of zroot

[USE with care]
 
Name "rebase" does exist for git but not for zfs.
What are you trying to do ?
Rename ?
zfs rename -r tank/home@monday tuesday

I think you did not make a clone, (not necessary)

Note , snapshot is read only ;
clone is read write made out of read only snapshot
zroot/ROOT/default is based on zroot/ROOT/base@snap before,I want zroot/ROOT/default to be based on zroot/ROOT/base@snap_new
 
All speculation on my part, i'll talk about things based on my understanding of ZFS, which may be entirely wrong.
  1. Snapshots are immutable, they are read only, static references/copies of a dataset at a given point in time. So one cannot change a snapshot by design.
  2. A Clone is a writeable entity on top of a snapshot and basically represents the changes to the snapshot.
If we assume/agree on those 2 facts, then looking at what you are trying to do is take two clones which are differences from snapshot A and apply those differences to snapshot B (similar to the way git rebase works: figure out diffs from current to branch point, replay those diffs to current position).

Is that a reasonably correct understanding of what you have and what you want?
If so, I don't think it's possible (but I don't know everything) but perhaps someone else knows
 
All speculation on my part, i'll talk about things based on my understanding of ZFS, which may be entirely wrong.
  1. Snapshots are immutable, they are read only, static references/copies of a dataset at a given point in time. So one cannot change a snapshot by design.
  2. A Clone is a writeable entity on top of a snapshot and basically represents the changes to the snapshot.
If we assume/agree on those 2 facts, then looking at what you are trying to do is take two clones which are differences from snapshot A and apply those differences to snapshot B (similar to the way git rebase works: figure out diffs from current to branch point, replay those diffs to current position).

Is that a reasonably correct understanding of what you have and what you want?
If so, I don't think it's possible (but I don't know everything) but perhaps someone else knows
Clone 1 is A@snap +B
I want it to become A@snap_new +B
 
Just delete A@snap clone
Just delete A at snap snapshot.
Just clone A at snap_new ?

Current
Code:
zfs list | sort
Could give insight into current situation.

But be carefull you dont want unbootable system
Code:
kenv | grep mount
 
It means comparing the differences between two snapshots. Remove the differing parts from the clone, and copy the remaining parts to a new clone based on the new snapshot.
 
Poor man solution could be :
Code:
mount snapshot old to /A
mount snapshot new to /B
create mountpoint /C (union)
use "clone" to copy all from /A to /C
overwrite with "clone" /B to /C
You have union in /C
Now you can unmount /A /B and delete snapshots.
Might take some time or I miss understood question.
 
The only real difference between 'build' and 'default' environments seems to be a bunch of additional packages. Make a note of what you installed there; pkg prime-list is useful. Then nuke the 'old' build environment and create a new one based on the current 'base' BE. Add the packages from the 'prime-list'.

There is no 'data' to preserve, only installed packages. Those are easily reinstalled. Just make sure your home directories are stored outside the BE. Which the current installer should set up in a separate dataset (zroot/home).
 
There is /usr/local.
I've put /usr/local/etc & /usr/local/www softlinks.
I ditch remove everything from /usr/local , at once quick , lost nothing. But like SirDice says have pkg prime-list. Run , Done.
 
Back
Top