I am trying to make cow-copies of some files/directories, but of the several ways I know of, all seem sub-optimal.
For example, btrfs can, with the use of cp --reflink=auto
quickly generate cow-copies of files.
What I have tried:
- Symlinks: No good. Renamed file, broken link.
- Hardlinks: Better, but still no good. Changes to one file will change the other, and I don't necessarily want the other file changed.
- Create a snapshot of the dataset, then clone the snapshot: This can work, but not well. Often I'm not looking for a copy of the whole dataset, or for the copies to act like another dataset. Then there are the parent/child relationships between the clone/snapshot/original, which as I understand it are hard, if not impossible to break.
- Using
zfs send/receive
, and enabled dedup, replicate the dataset to a new dataset: This avoids the parent/child relationships of using a clone, but still needlessly creates another dataset, and still suffers from the slowness involved in the files having to be read 100% and the blocks referenced again instead of written. - Copy files and let dedup do its job: This works, but is slow because the file(s) have to be 100% read and then the blocks referenced again instead of writing.
Slowness of zfs send/receive and physically copying or rsyncing is further exacerbated because most things are stored compressed, and have to be decompressed during read, then compressed before dedup kicks in to reference duplicate blocks.
In all of my research, I have not been able to find anything remotely resembling the simplicity of --reflink in btrfs.
So, is there a way to create cow-copies in ZFS? Or is "physically" copying and letting dedup do its job the only real option?