Inserting Filesystem into Existing Dataset

Is there a trick for adding a ZFS filesystem to an existing filesystem that’s already full of data? I have a few folders that contain the majority of the data in their respective filesystems and would like to turn them into real ZFS filesystems so I can send/receive them and possibly change settings independently of their parent filesystems.

E.g. ‘tank/deptX’ has a directory named teamY with a few million files. Can I define tank/deptX/teamY without having to copy all the files and lose the snapshot history?

Maybe you could send | receive from tank/deptX into tank/deptX/teamY? Or maybe clone?

Start with a different mountpoint for tank/.../teamY while you arrange everything.

Then after, you could delete just the teamY directory from the tank/deptX dataset, and similarly, delete everything except the teamY directory in the tank/.../teamY dataset.

Then move the files from the tank/.../teamY/teamY directory up a level, so that the files are in the root of the tank/.../teamY dataset instead of nested inside a second teamY directory. Then rmdir the tank/.../teamY/teamY directory. Then change the mountpoint of the tank/.../teamY dataset to be in/under tank/deptX.

Encryption may cause trouble, and there may also be another tool besides send | receive and/or clone that may be better. Those are the only ones I know about, but I’ve also never actually used clone, only read about it.

I’m also not sure how snapshot history behaves for files moving directories, never had to pay attention to it. It is possible it is just a lightweight metadata change, and the snapshot would be small, which is probably what you are looking for.

But at any rate, this is the procedure I can see for bringing your snapshot history of teamY files into the new dataset. Just beware, tank/deptX snapshot history will include teamY files for the duration of your “keep history” policy, if you are trying to restrict access to those files.