Convert folder to dataset

Hello,

I have a dataset rpool/stuff which has a folder media in it. How can convert this folder into a dataset like rpool/stuff/media ?

Thanks

You can’t “convert” it, but you can copy the stuff in.

root@box:~# mv /rpool/stuff/media /rpool/stuff/media-old
root@box:~# zfs create rpool/stuff/media
root@box:~# rsync -ha /rpool/stuff/media-old/ /rpool/stuff/media/
root@box:~# rm -r /rpool/stuff/media-old

Pretty much any way to copy files from one place to another works, but I’d recommend rsync -ha for this (rsync -hav --progress if you want to see what’s happening while it goes, if there’s a whole lot of data).

1 Like

I always use the partial flag too, just in case it gets interrupted some how and I have to resume the transfer. I use -P for both partial and progress in one go. But that’s just me.

`rsync -avhP /source/stuff /destination/`
1 Like

I use rsync -Phhav /path/to/source/ /path/to/destination/

Be aware the trailing slashes matter.

1 Like

For rsync, I typically also use the -H, -S and -X options to preserve hard links, sparse files and xattrs. For an initial population to an empty target, tar create piped to tar extract is faster. And for this particular use case of moving files into a new dataset, I would try to use something that will not actually cause the data to be re-written such as by using copy_file_range(2) underneath. mv on FreeBSD seems to manage this even when moving files across datasets on the same pool, not sure if that needs block cloning to be turned on. Using mv will also be better if your media directory is too big for your pool to hold two copies of it.